Skip to content

Refunds and mistakes

A refund needs no card. Your till already knows the invoice, and POST /awards/{reference}/reverse takes back what that invoice earned.

Every guide starts here
export PASSKAAR_API=https://api.passkaar.com/integrations/v1
printf 'Your key: '; read -rs PASSKAAR_KEY; echo; export PASSKAAR_KEY
Terminal window
INVOICE_1=$(cat invoice-1.txt); INVOICE_2=$(cat invoice-2.txt); RUN=$(date +%s)

Invoice 1 was Rs 2,450 and earned 245 beans. The customer returns Rs 490 of it. Send that amount, and the number of your refund slip:

Terminal window
curl -sS "$PASSKAAR_API/awards/$INVOICE_1/reverse" \
-H "Authorization: Bearer $PASSKAAR_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d "{\"refund\": {\"total\": 490, \"currency\": \"PKR\"}, \"refund_reference\": \"RET-$RUN-1\"}" | jq .
{
"id": "41fd4da2-f452-4c27-ae1c-85ddc5d3c515",
"award": {
"id": "da5a0ed7-1c76-4190-894c-5b71c1cc058c",
"reference": "INV-1795596390-1"
},
"card": {
"id": "7ded17c2-4c34-45ff-925f-548564d12560",
"card_id": null
},
"kind": "partial",
"reversed": {
"points": 49
},
"shortfall": null,
"balance": {
"type": "points",
"points": 256,
"unit_name": "beans",
"next_reward": null,
"expiring": null
},
"occurred_at": "2026-11-25T08:46:50.279Z",
"recorded_at": "2026-11-25T08:46:50.279Z",
"replayed": false
}

A fifth of the bill, so a fifth of the beans: 49. A part of a point or a stamp is never taken, so a small refund on a stamps card may take back nothing.

  • Each part refund needs its own refund_reference. The same one again answers the first result.
  • refund.total is measured against the bill.total you sent. Returning all of a bill the customer paid Rs 1,100 for is Rs 1,100, not the Rs 1,200 before the discount. More than is left answers reversal_exceeds_award.
  • An invoice number with a / in it is percent-encoded in the address: INV/24-25/001 is sent as INV%2F24-25%2F001.

Send an empty body. All that is left of what the invoice earned is taken back:

Terminal window
curl -sS "$PASSKAAR_API/awards/$INVOICE_2/reverse" \
-H "Authorization: Bearer $PASSKAAR_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}' | jq '{kind, reversed, shortfall, balance}'
{
"kind": "full",
"reversed": {
"points": 110
},
"shortfall": null,
"balance": {
"type": "points",
"points": 146,
"unit_name": "beans",
"next_reward": null,
"expiring": null
}
}

A wrong sale is undone the same way: reverse it and record the right one under a new invoice number. The old number never earns again.

Reversing gives nothing back to the customer: Ayesha also spent 100 beans on invoice 2, and those stay spent. The API has no call to undo a redemption. The shop’s owner or an admin opens the customer’s card in the Passkaar portal and chooses Undo on that line. Tell the cashier so on the void screen. This is why the till redeems only when the bill is final.

Now the rest of invoice 1 comes back. 196 of its beans are left to take, but the card holds fewer:

Terminal window
curl -sS "$PASSKAAR_API/awards/$INVOICE_1/reverse" \
-H "Authorization: Bearer $PASSKAAR_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{}' | jq '{kind, reversed, shortfall, balance}'
{
"kind": "full",
"reversed": {
"points": 146
},
"shortfall": {
"points": 50
},
"balance": {
"type": "points",
"points": 0,
"unit_name": "beans",
"next_reward": null,
"expiring": null
}
}

A card never goes below zero. Passkaar took what there was, and shortfall is what it could not take. The shop decides what to do with it: show it to the cashier, for example 50 beans already used, worth Rs 50, and let them keep that off the refund or let it go.

code Means
not_found This connection recorded no sale under that number: it earned nothing, is still in your queue, or another connection recorded it.
already_reversed Nothing is left of it. Treat the refund as done.
reversal_exceeds_award The refunds add up to more than the bill you sent.
reference_reused That refund_reference was used for a different refund.
operation_not_allowed A part refund of a sale sent with no bill, of a membership sold by time, or of a check-in. Reverse all of it instead.

None of these stops the cashier from giving the money back.

Next: bad internet and going live.