Refund
Returns a receipt that was sold earlier. You need the saleId from that sale.
POSThttps://localhost:26496/service·command: Refund
Request
json
{
"id": "2",
"method": "send",
"data": {
"command": "Refund",
"payload": {
"saleId": 142,
"amount": 12500,
"shouldPrintReceipt": true,
"products": [
{
"id": "p_1001",
"name": "Espresso",
"barcode": null,
"units": "шт",
"price": 12500,
"vat": 0.12,
"amount": 1,
"isDecimalUnits": false,
"labels": [],
"psid": "10112001001000000",
"packageCode": 1512472,
"unitCode": null,
"discountAmount": 0,
"commissionTIN": null,
"commissionPINFL": null
}
],
"payments": [{ "paymentType": "Cash", "amount": 12500 }]
}
}
}Response
json
{ "id": "2", "success": true, "data": { } }payload
| Field | Type | Description |
|---|---|---|
saleId | integer | From the Sale response |
amount | integer | Amount being returned, in tiyin |
products | array | The lines being returned — same format as in Sale |
payments | array | How the money goes back — same format as in Sale |
shouldPrintReceipt | boolean | true — print on paper |
There is no saleType, no discountAmount and no totalAmount here.
Save the sale, replay it
The simplest way to refund: when you send a Sale, save the payload you sent together with the saleId. To refund, send those same products and payments back.
js
// on sale
const { saleId } = await send('Sale', payload)
await db.save(orderId, { saleId, payload })
// on refund
const { saleId, payload } = await db.load(orderId)
await send('Refund', {
saleId,
amount: payload.totalAmount,
shouldPrintReceipt: true,
products: payload.products,
payments: payload.payments
})If you rebuild the lines from your order instead, prices or tax settings may have changed since the sale, and the amounts will no longer match the original receipt — the device will reject it.
Partial refund
Send only the lines you are returning, and lower their amount (quantity). Keep price as it was:
json
{
"saleId": 142,
"amount": 12500,
"shouldPrintReceipt": true,
"products": [ /* one line, amount: 1 */ ],
"payments": [{ "paymentType": "Cash", "amount": 12500 }]
}No saleId, no refund
If you did not save the saleId, the receipt cannot be refunded through the API. It has to be refunded on the device by hand.