unPLUGDevelopers

Orders and refunds API

Create a refund

POST/v1/orders/{id}/refunds

Records a refund you already made to the guest's card, so unPLUG takes back the points the refunded part earned. Send one call per refund, partial or full.

Permissions: Secret key with checkout:write.

Request headers#

  • Idempotency-KeystringRequired
    Required on this endpoint. Any string up to 255 characters; use a UUID v4. Missing returns 400 idempotency_key_required.
    Max Length 255

Path parameters#

  • idstring (uuid)Required

Request body#

  • external_refund_idstringRequired
    Your refund id.
  • amount_centsinteger
    For a partial refund: the part of the subtotal after discounts that you refunded. Leave out tax and tip. Send this or full.
    Min 1
  • fullboolean
    true to refund everything not yet refunded.
  • reasonstring
    Your reason, for example requested_by_customer.

Response fields#

Returns 201 with Refund

  • idstring (uuid)
  • order_idstring (uuid)
  • external_refund_idstring
    Your refund id.
  • amount_centsinteger
    The part of the subtotal after discounts that was refunded. For a full refund, everything not refunded before.
    Min 0
  • fullboolean
    true for a full refund.
  • reasonstringNullable
    As you sent it.
  • points_reversedinteger
    Earned points taken back.
  • points_shortfallinteger
    Points that couldn't be taken back because the member had already spent them. The balance stops at zero.
  • order_statusstring
    The order's status after this refund: partially_refunded or refunded.
    One of partially_refunded, refunded
  • member_idstring (uuid)Nullable
    The order's member. null for a guest order.
  • memberobjectNullable
    { "points_balance" } after the refund. null for a guest order.
    Show attributesHide attributes
    • points_balanceinteger
  • created_atstring (date-time)

What a refund does#

  • Earned points are reversed in proportion: points_earned × amount_cents ÷ the order's subtotal after discounts, rounded down. The member gets a reverse activity entry.
  • Partial refunds keep the redemption captured. The guest keeps the reward.
  • A full refund also reverses the redemption: points spent on a points reward come back, and a wallet item or unique code returns to the member if it hasn't expired.
  • The balance never goes below zero. If the member already spent the points, the part that can't be taken back is reported in points_shortfall.

Maya's latte was made with the wrong milk, and you refund $5.00:

The order earned 90 Beans on $9.00, so $5.00 reverses 90 × 500 ÷ 900 = 50 Beans. Maya goes from 510 to 460. The pastry stays used. If you later send "full": true, the other $4.00 and 40 Beans are reversed, the redemption becomes reversed, and the pastry goes back to her wallet if it hasn't expired. The Checkout guide shows a full refund with a points_shortfall.

Warning Send every refund you make. If you skip them, guests keep points for food they got back, and the program's reports overstate sales.

Error descriptions#

400Bad request
idempotency_key_required

The Idempotency-Key header is missing.

400Bad request
invalid_request

Both or neither of amount_cents and full were sent.

404Not found
not_found

No order with this id in your brand.

422Unprocessable
refund_exceeds_order

This refund plus earlier ones would be more than the order's subtotal after discounts, or the order is already fully refunded.

422Unprocessable
idempotency_key_reused

This key was used with a different body.

Any endpoint can also return the common errors.