Skip to content

Hosted Checkout

How-to for merchant backends: create an order, redirect the customer, verify server-to-server, then fulfill. Amounts are integers in minor units (paisa for NPR, cents for USD). amount is tax-inclusive. JSON is camelCase. Machine-readable: /openapi.json, /llms.txt.

How it works

  1. Customer is ready to pay on your site.
  2. Your backend creates an order via POST /api/orders and receives a checkoutUrl.
  3. You redirect the customer to that checkout URL.
  4. They pick a gateway and pay on the hosted page.
  5. They return to your success/failure URL with ?id=&status= (UX only; id is our order UUID).
  6. Your backend calls POST /api/orders/{id}/verify (or handles a signed webhook, then still verifies).
  7. Fulfill only when fulfilled: true.

Create → pay → verify

No SDK: any backend that can HTTPS POST works. You need a merchant account and an API key (ps_…) from Thuprai Pay.

  1. Create: POST /api/orders → store id, redirect to checkoutUrl.
  2. Pay: customer completes payment on hosted checkout (you never talk to the gateway).
  3. Return / webhook: treat browser ?id=&status= as UX only; optional signed webhook is a hint, not proof.
  4. Verify: POST /api/orders/{id}/verify. Fulfill only when fulfilled: true. Re-verify is safe.
Tip
Request access from the landing page if you do not have credentials yet. Jump to Quick curl at the bottom for a copy-paste smoke test.

Merchant configuration

Configure these on your merchant in Thuprai Pay. API keys and the webhook signing secret are minted there (key shown once as ps_…; secret is rotatable).

FieldRequiredNotes
Success / failure redirect URLs Fallbacks when an order omits per-order redirects. If every create sends successRedirectUrl / failureRedirectUrl, these are unused for that order - any absolute URL works as placeholder.
Success / failure webhook URLsnopayment_success → success URL; payment_failed → failure URL. Same URL for both is fine; branch on event. With Awecount: also receipt_synced / exchange_fulfilled (checkout settle) on the success URL.
Voucher enabled + apply URLno Hosted checkout voucher field. When on, voucherApplyUrl is required. Same HMAC secret as webhooks.
Payment methods (Cash / offline / custom)no Names on GET /api/payment-methods for create+method and record-payment. Cash also required for return / exchange cash legs. Configure under Merchant → Payment methods (or Admin).

API Authorization

Pass your merchant API key as a Bearer token on every request:

Authorization: Bearer ps_...
Content-Type: application/json
StatusMeaning
401Bad / missing / revoked key
403Merchant disabled

API Endpoints

EnvironmentBase URL
Productionhttps://pay.awecode.com
Staginghttps://ps-stg.awecode.workers.dev

Staging API keys and gateway sandbox credentials are issued in Thuprai Pay on the staging merchant (same form as production).

MethodPathPurpose
POST/api/ordersCreate checkout order
GET/api/orders/{id}Read order status
POST/api/orders/{id}/verifyVerify before fulfillment
POST/api/orders/{id}/cancelCancel open order
POST/api/orders/bulk-cancelCancel up to 5,000 open orders (per-order outcomes)
GET/api/payment-methodsNames you may pass as method (Cash, gateways, customs)
POST/api/orders/{id}/record-paymentMark Open order paid with a method name (any offered method)
POST/api/orders/{id}/returnCash sales return (credit note)
POST/api/orders/{id}/exchangeCN + INV + optional net settle

Create order

Every payment starts as a server-side create. On success you get a checkoutUrl - redirect the customer there.

POST /api/orders

Request body

{
  "amount": 150000,
  "tax": 0,
  "shipping": 0,
  "currency": "NPR",
  "orderId": "1000123",
  "orderNumber": "1000123",
  "reference": "1000123",
  "message": "Order #1000123",
  "products": [
    {
      "name": "Seto Dharti",
      "quantity": 1,
      "amount": 80000,
      "description": "Ebook"
    }
  ],
  "data": { "yourOrderPk": 12345 },
  "tags": ["vip", "color:red"],
  "gateways": ["fonepay_qr", "esewa"]
}

JSON payload details

FieldTypeRequiredNotes
amountintegeryesMinor units. Tax- and shipping-inclusive.
currencystringnoISO 4217. Default NPR.
tax / shippingintegerno Default 0. tax = product VAT only; shipping = incl. shipping VAT (gateway slice). Must satisfy tax + shipping <= amount. For a bill/checkout shipping row, also put it in products[].
orderIdstringnoYour order id. Echoed on verify / webhooks (browser return uses our id).
referencestringno Unique per merchant. If omitted: {orderNumber||orderId||"order"}::{ourUuid}. Reuse → 409.
messagestringnoShown on checkout.
productsarrayno Line items on checkout / the bill (name, quantity, amount = VAT-inclusive line gross). Include shipping here when it should show as its own row. Product code / category / line tax are only required when Awecount sync is on; skip that section otherwise.
discountintegerno Order-level commercial discount (tax-inclusive). Payable amount is already net. Default 0.
dataobjectno Opaque pass-through only: echoed on verify / webhooks, not shown on checkout. Typed create fields (customer, remarks, products, discount, awecountSync, …) must be top-level; values stuffed here are ignored for checkout and Awecount.
tagsstring[]noDashboard labels. Immutable after create.
gatewaysstring[]no Restrict hosted checkout by PS id (e.g. ["fonepay_qr", "esewa"]). Same ids as verify / webhook gateway. Still intersected with what you have enabled. Omit → all enabled. Ignored when method is set (create+record). See table below.
successRedirectUrl / failureRedirectUrlurino Per-order override of merchant defaults. If set, merchant-level redirects are unused for that order.
expiresAtdatetimeno Optional. Must be in the future. Null = no expiry. Past → checkout refuses; status may move to Expired.

Gateway ids

Same value on create gateways[], verify, and webhooks. Checkout UI shows the label.

IdLabel
esewaeSewa
khaltiKhalti
fonepay_qrFonepay QR
fonepay_bankFonepay Bank
connectipsConnect IPS
paypalPayPal
stripeStripe

Success response

{
  "id": "019f8c2a-7b1e-7000-8000-abcdef012345",
  "reference": "1000123",
  "checkoutUrl": "https://pay.awecode.com/xY9kQm2..."
}

Redirect the customer to checkoutUrl. Store id for verify / cancel.

Get order

GET /api/orders/{id}

Returns current status, latest transaction pointers, and your data / tags. Also includes refunds and refundedTotal; the original order keeps its status and payable amount (returns are recorded separately). For fulfillment, call verify - do not fulfill from get alone.

Cancel order

POST /api/orders/{id}/cancel

Only while Open. Already paid orders cannot be canceled (409).

Bulk cancel orders

POST /api/orders/bulk-cancel

Cancel 1–5,000 open orders in one call. Only Open orders are canceled; duplicate ids are dropped. The batch never fails as a whole: HTTP 200 with one outcome per id, in request order.

{
  "ids": [
    "019f8c2a-7b1e-7000-8000-abcdef012345",
    "019f8c2b-1111-7000-8000-abcdef012345",
    "019f8c2c-2222-7000-8000-abcdef012345"
  ]
}
{
  "results": [
    { "id": "019f8c2a-7b1e-7000-8000-abcdef012345", "ok": true, "status": "Canceled" },
    { "id": "019f8c2b-1111-7000-8000-abcdef012345", "ok": false, "status": "Success", "error": "Order cannot be canceled (status=Success)" },
    { "id": "019f8c2c-2222-7000-8000-abcdef012345", "ok": false, "error": "Order not found" }
  ]
}

ok: false with status → the order exists but is not Open. ok: false without status → unknown id or another merchant's order (existence never leaks). Same caveat as single cancel: a late gateway Success can still promote a Canceled order on verify.

Browser return

After payment, the customer is redirected to the order's success/failure URL (per-order override, else merchant default). Params are appended with URLSearchParams (existing ?… becomes &…, never a second ?):

?id={our order UUID}&status={Success|Failed|Canceled|Expired}

Use id for POST /api/orders/{id}/verify. Order statuses: Open, Success, Failed, Canceled, Expired (American spelling).

Important
Never trust the browser redirect alone. Query params can be spoofed. Always call verify before fulfillment.

Verify payment

Required before fulfillment. Re-checks the gateway when needed and returns whether you may fulfill.

POST /api/orders/{id}/verify
Rule
Deliver only when fulfilled is true.

Success response

{
  "id": "019f8c2a-7b1e-7000-8000-abcdef012345",
  "orderId": "1000123",
  "reference": "1000123",
  "amount": 150000,
  "currency": "NPR",
  "status": "Success",
  "verified": true,
  "fulfilled": true,
  "verificationResult": "Success",
  "transactionId": "019f8c2b-1111-7000-8000-abcdef012345",
  "gateway": "esewa",
  "gatewayReference": "000ABC"
}

Webhooks

Optional. Set your success / failure webhook URLs and signing secret on your merchant in Thuprai Pay. Same URL for both is fine; branch on event. Still call verify before fulfillment.

  • payment_success → success webhook URL
  • payment_failed → failure webhook URL
  • receipt_synced → success webhook URL : Awecount only (ignore if sync is off)
  • exchange_fulfilled → success webhook URL : checkout settle on /exchange only (amend complete; not the same as payment_success)

Headers

Content-Type: application/json
X-Event-ID: <uuid, stable across retries>
X-Webhook-Signature: sha256=<hex HMAC of raw body>

HMAC key = your webhook signing secret as UTF-8 (do not base64-decode). Respond 2xx. Use X-Event-ID as an idempotency key across retries.

Retries

Up to 6 attempts. Backoff after failure: 1m, 5m, 15m, 1h, 4h, then Exhausted.

Webhook body

{
  "event": "payment_success",
  "id": "019f8c2a-7b1e-7000-8000-abcdef012345",
  "orderId": "1000123",
  "transactionId": "019f8c2b-1111-7000-8000-abcdef012345",
  "amount": 150000,
  "currency": "NPR",
  "status": "Success",
  "gateway": "esewa",
  "gatewayReference": "000ABC",
  "data": { "yourOrderPk": 12345 },
  "tags": ["vip", "color:red"]
}

id is our order UUID (use for verify). orderId is your create-time id if set, otherwise our UUID. amount is minor units.

Vouchers

Optional. Enable vouchers and set your voucherApplyUrl on your merchant in Thuprai Pay. Hosted checkout then shows a voucher field. You own the codes; we call your URL on apply / remove.

Tip
Same HMAC secret as webhooks. Verify X-Webhook-Signature on the raw body before trusting the request.

Only one voucher at a time. To change code, remove first, then apply again. Stacking discounts is not supported.

Apply request (us → you)

POST {your voucherApplyUrl}
Content-Type: application/json
X-Webhook-Signature: sha256=<hex HMAC of raw body>
{
  "action": "apply",
  "orderId": "019f8c2a-7b1e-7000-8000-abcdef012345",
  "merchantOrderId": "1000123",
  "reference": "1000123",
  "checkoutToken": "xY9kQm2...",
  "code": "SAVE20",
  "amount": 150000,
  "originalAmount": 150000,
  "currency": "NPR",
  "tax": 0,
  "shipping": 0,
  "data": { "yourOrderPk": 12345 }
}

You can ignore fields you do not need. Typical use:

  • code - voucher to apply
  • merchantOrderId / data - find the order in your system
  • originalAmount - create-time total (baseline for % off / min-order rules)
  • amount - current payable (same as originalAmount on apply, since only one voucher is allowed)

orderId, reference, checkoutToken, tax, shipping, currency are context if you want them.

Success response (you → us)

{
  "ok": true,
  "amount": 120000,
  "code": "SAVE20"
}

Return the new payable in amount (minor units). It must be <= originalAmount. We store that as the order payable and keep the create-time total so remove can restore it.

Failure response

{
  "ok": false,
  "error": "invalid_code",
  "detail": "Optional short message shown to the customer"
}

Common error values: invalid_code, expired, already_used, not_applicable.

Remove

Same URL with "action": "remove". Reply { "ok": true }. We restore the create-time amount locally.

100% off

If apply returns amount: 0, checkout completes without a gateway: order becomes Success, we send a payment_success webhook (gateway: "voucher"), and the customer is redirected to your success URL. Still call verify and deliver only when fulfilled: true.

Errors

{
  "statusCode": 409,
  "statusMessage": "Order reference already exists for this merchant",
  "message": "Order reference already exists for this merchant"
}

Quick curl

BASE=https://pay.awecode.com
KEY=ps_...

curl -sS -X POST "$BASE/api/orders" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount":150000,"currency":"NPR","orderId":"1000123"}'

curl -sS "$BASE/api/orders/$ORDER_ID" -H "Authorization: Bearer $KEY"
curl -sS -X POST "$BASE/api/orders/$ORDER_ID/verify" -H "Authorization: Bearer $KEY"

Security

Payment integration bugs become money bugs. Treat fulfillment as a security boundary: only your backend, only after server-to-server verify, only when fulfilled: true.

Non-negotiable
Browser return and unsigned webhooks are not proof of payment. Always verify server-to-server before shipping or granting access.

Checklist

Tick each item as you implement. Saved in this browser only.

Awecount (optional)

Skip this whole group if sync is off
You do not need Awecount for create → pay → verify.

When sync is on, a successful payment creates an Awecount sales voucher. You never call Awecount; send the fields below on POST /api/orders; we sync the sales voucher to Awecount after the order is Success.

Payment modes

Create modes in Awecount first
We only look up payment modes; we never create them. Add eSewa, Khalti, Fonepay, PayPal, etc. In Awecount (exact spelling below), or map each method → mode id in admin. Missing mode → sync failure (HTTP 5xx).

Prefer optional mode ids when your company PaymentMode names differ. Otherwise we match the mode by its exact name, and Awecount must already have a payment mode with that name.

Payment methodFallback Awecount name
Cash, Voucher (100% off)Cash
eSewaeSewa
KhaltiKhalti
Fonepay QR, Fonepay BankFonepay
Connect IPSConnect IPS
PayPalPayPal
StripeStripe

Checkout + Awecount sync

Create without method. Sync on requires coded products and customer.name (usually also tax, remarks, discount):

POST /api/orders

Request body

{
  "amount": 55000,
  "tax": 7200,
  "currency": "NPR",
  "orderId": "10001234",
  "orderNumber": "10001234",
  "message": "Table 4",
  "discount": 20000,
  "remarks": "Order #10001234",
  "customer": {
    "name": "Ram Bahadur",
    "email": "ram@example.com",
    "phone": "9800000000"
  },
  "products": [
    {
      "name": "Veg Biryani",
      "quantity": 1,
      "amount": 30000,
      "discount": 5000,
      "code": "FOOD-biryani-01",
      "category": { "name": "Food" },
      "tax": { "rate": 13 },
      "description": "NPR 300 each"
    },
    {
      "name": "General ticket",
      "quantity": 1,
      "amount": 50000,
      "code": "TIX-general-01",
      "category": { "name": "Tickets" },
      "tax": { "rate": 13 },
      "description": "Entry"
    }
  ],
  "data": { "yourOrderPk": 12345 },
  "tags": ["store:counter"]
}
  1. Redirect to checkoutUrl → customer pays.
  2. POST /api/orders/{id}/verify: redirect, webhook fulfill, and S2S verify all await Awecount before responding.
  3. Fulfill when fulfilled: true. Read receipt when status: "synced".

Sync failure → HTTP 5xx. Order Success stays (money captured) but verify/redirect still error until a later verify succeeds. receipt_synced fires to your success webhook after Awecount succeeds.

Tax, shipping, currency
Money fields already include VAT. Order tax is product VAT only (shipping VAT stays inside shipping). To show shipping as its own line on checkout or the bill, add it as a product line — the shipping field alone will not. With Awecount sync, that line needs an item code (and usually 13% tax). Use the same currency as your Awecount company — we do not convert.

receipt_synced webhook

Posted to your success webhook URL after Awecount succeeds (same HMAC as payment_success). Includes the bill number (and date / lines) for printing or display. Still call verify before fulfillment.

Webhook body

{
  "event": "receipt_synced",
  "orderId": "10001234",
  "transactionId": "019f8c2b-1111-7000-8000-abcdef012345",
  "amount": 55000,
  "currency": "NPR",
  "status": "Success",
  "gateway": "cash",
  "gatewayReference": null,
  "data": { "yourOrderPk": 12345 },
  "tags": ["store:counter", "tender:cash"],
  "receipt": {
    "billNo": "SV-1042",
    "status": "synced",
    "syncedAt": "2026-10-14T06:00:00.000Z",
    "invoice": {
      "id": 1042,
      "billNo": "SV-1042",
      "fiscalYear": "2082/83",
      "date": "2026-10-14",
      "customerName": "Ram Bahadur",
      "lines": [
        {
          "name": "Veg Biryani",
          "hsCode": null,
          "quantity": 1,
          "rate": 265.49,
          "description": "NPR 300 each"
        }
      ]
    }
  }
}

Record payment

Money collected outside hosted checkout (Cash, Upaya, store QR, or a gateway offered for recording). List offered names, then create+record or record an Open order.

GET /api/payment-methods
→ { "methods": ["Cash", "Fonepay QR", "Upaya"] }

Create+record (one shot, checkoutUrl: null) — method must be a list name ("Cash"; legacy "cash" on create still works):

POST /api/orders

Request body

{
  "amount": 55000,
  "tax": 7200,
  "currency": "NPR",
  "orderId": "10001234",
  "orderNumber": "10001234",
  "message": "Table 4",
  "discount": 20000,
  "remarks": "Order #10001234",
  "customer": {
    "name": "Ram Bahadur",
    "email": "ram@example.com",
    "phone": "9800000000"
  },
  "products": [
    {
      "name": "Veg Biryani",
      "quantity": 1,
      "amount": 30000,
      "discount": 5000,
      "code": "FOOD-biryani-01",
      "category": { "name": "Food" },
      "tax": { "rate": 13 },
      "description": "NPR 300 each"
    },
    {
      "name": "General ticket",
      "quantity": 1,
      "amount": 50000,
      "code": "TIX-general-01",
      "category": { "name": "Tickets" },
      "tax": { "rate": 13 },
      "description": "Entry"
    }
  ],
  "data": { "yourOrderPk": 12345 },
  "tags": ["store:counter"],
  "method": "Cash"
}

Success response

{
  "id": "019f8c2a-7b1e-7000-8000-abcdef012345",
  "orderId": "10001234",
  "orderNumber": "10001234",
  "reference": "10001234",
  "amount": 55000,
  "currency": "NPR",
  "status": "Success",
  "data": { "yourOrderPk": 12345 },
  "tags": ["store:counter", "tender:cash"],
  "customer": {
    "name": "Ram Bahadur",
    "email": "ram@example.com",
    "phone": "9800000000"
  },
  "verified": true,
  "fulfilled": true,
  "verificationResult": "Success",
  "transactionId": "019f8c2b-1111-7000-8000-abcdef012345",
  "gateway": "cash",
  "gatewayReference": null,
  "checkoutUrl": null,
  "receipt": {
    "billNo": "SV-1042",
    "status": "synced",
    "syncedAt": "2026-10-14T06:00:00.000Z",
    "invoice": {
      "id": 1042,
      "billNo": "SV-1042",
      "fiscalYear": "2082/83",
      "date": "2026-10-14",
      "customerName": "Ram Bahadur",
      "lines": [
        {
          "name": "Veg Biryani",
          "hsCode": null,
          "quantity": 1,
          "rate": 265.49,
          "description": "NPR 300 each"
        },
        {
          "name": "General ticket",
          "hsCode": null,
          "quantity": 1,
          "rate": 442.48,
          "description": "Entry"
        }
      ]
    }
  }
}

Existing Open order → POST /api/orders/{id}/record-payment{ "method": "Cash" } (or "Upaya", "Fonepay QR", …). Awecount sync on → await receipt; failure → 5xx and Success reverted to Open so you can retry.

receipt.invoice.lines is the print-ready line list (not Partner rows).

Product fields (sync on)

FieldRequiredNotes
amountyesLine gross, VAT-inclusive (not unit price). Same for shipping lines.
codeyes*Stable item code (1-64). Same SKU → same code forever. Shipping needs a code too.
categoryno{ name, hsCode? }. Omit → uncategorized.
taxno{ rate: 13 }. Omit → untaxed row. Use on Shipping if that line should book 13%.
remarks / discountnoVoucher remarks, order-level discount.
Create rejects (sync on)
Empty products or missing code → 400. Missing customer.name → 400. Method not offered for merchant → 403.

Buyer & VAT-claimable party

Send customer on create. When sync is on, customer.name is required.

  1. Walk-in / B2C: name (optional email/phone). Bill issues under that name. Buyer cannot claim input VAT.
  2. B2B / VAT-claimable: same fields plus taxId (Nepal PAN, 9 digits; hyphens ok; we strip non-digits). That attaches the buyer party so they can claim input VAT.

Request body (customer fragment)

{
  "customer": {
    "name": "Thuprai Solutions",
    "email": "accounts@example.com",
    "phone": "9800000000",
    "taxId": "601-855-494"
  }
}
FieldRequiredNotes
nameyes*Max 120. Required when sync on.
emailnoMax 254.
phonenoMax 32.
taxIdno9-digit PAN. Wrong length → ignored (name-only bill).

Opt-out & force receipt

Merchant sync is on, but this one order should skip Awecount? Send "awecountSync": false on create. Product codes and customer.name are not required, and Success will not wait on Awecount. You can still create a receipt later with the endpoint below (then both are required).

Backfill / retry after Success without a voucher (or receipt.status=failed):

POST /api/orders/{id}/receipt

Body may supply products / tax / discount / customer / remarks / shipping. Payable amount is never rewritten. Already synced → returns stored receipt.

Sales return (credit note)

Cash refund against a paid order (partial or full). Needs Cash payments enabled. The original sale stays Success; we record the return separately. Works with or without Awecount:

  • Sync off: no Awecount credit note; response has no receipt.
  • Sync on: we also create an Awecount credit note and include its receipt in the response (product codes required; parent receipt must already be synced).
POST /api/orders/{id}/return

{id} is the original paid order id.

Request body

{
  "method": "cash",
  "amount": 28000,
  "tax": 3212,
  "discount": 0,
  "reference": "019f-adjustment-uuid",
  "remarks": "Return Veg Biryani",
  "products": [
    {
      "name": "Veg Biryani",
      "quantity": 1,
      "amount": 28000,
      "code": "FOOD-biryani-01",
      "category": { "name": "Food" },
      "tax": { "rate": 13 }
    }
  ]
}
FieldRequiredNotes
methodyesMust be "cash".
amount / productsyesReturned lines only. Product codes required when sync is on.
referenceyesUnique per merchant. Same ref + different body → 409.

Success response

{
  "id": "019f-refund-uuid",
  "orderId": "019f-parent-sale-uuid",
  "reference": "019f-adjustment-uuid",
  "amount": 28000,
  "tax": 3212,
  "currency": "NPR",
  "status": "Success",
  "gateway": "cash",
  "fulfilled": true,
  "verificationResult": "Success",
  "receipt": {
    "billNo": "CN-88",
    "status": "synced",
    "syncedAt": "2026-10-14T06:00:00.000Z",
    "invoice": { "id": 88, "billNo": "CN-88" }
  }
}

With sync off, receipt is null / omitted. Cancel does not replace a return.

Order exchange (CN + INV + net settle)

Paid-order amend: optional cash return (credit note) + optional cash sale (tax invoice at the full add amount) + optional net settle for whatever the customer still owes. Accounting bills use full line amounts; the till / QR only collects the difference.

POST /api/orders/{id}/exchange

Request body

{
  "reference": "019f-adjustment-uuid",
  "remarks": "Order #48291365 adjustment",
  "return": {
    "amount": 28000,
    "tax": 3212,
    "products": [
      { "name": "Veg Biryani", "quantity": 1, "amount": 28000, "code": "FOOD-biryani-01" }
    ]
  },
  "sale": {
    "amount": 30000,
    "tax": 3442,
    "products": [
      { "name": "Samosa (2 pc)", "quantity": 3, "amount": 30000, "code": "FOOD-samosa-01" }
    ]
  },
  "settle": {
    "method": "checkout",
    "successRedirectUrl": "https://pos.example/adjust?paid=1",
    "failureRedirectUrl": "https://pos.example/adjust?status=Failed"
  }
}

When receipts post

CaseCN / INV timing
Sync on + checkout settle + net > 0After settle pays. POST returns fulfilled: false and receipt: null.
Counter settle / net = 0 / return-onlyOn POST /exchange (immediate).
Sync offNever: no Awecount CN/INV for the exchange.

Checkout net > 0 with sync on: customer pays the settle checkout → we post CN then INV → exchange Fulfilled → exchange_fulfilled webhook → success redirect. Confirm the amend on fulfilled: true / that webhook, not settle payment_success alone. See Checkout settle checklist.

What settle means

We compute settleAmount = max(0, sale.amount − return.amount). Example above: return Rs 280, add Rs 300 → settle is Rs 20 (Awecount still gets CN 280 + INV 300; settle never creates a third bill).

Net changesettleAmountWhat you do
New total > old (customer owes more)> 0 Send settle. Collect the net via QR/gateway or cash at the till.
New total = old0 Omit settle. Exchange is auto-fulfilled (fulfilled: true).
New total < old (customer is owed money)0 Omit settle. Also auto-fulfilled. Hand the difference back at the till yourself; we do not pay out via gateway.

settle.method and redirect URLs

FieldWhenMeaning
method: "checkout"Net due > 0, pay by QR / wallet / card Opens hosted checkout for settleAmount only. Response includes checkoutUrl.
method: "counter"Net due > 0, already taken at till Marks settle paid immediately (no checkout URL).
successRedirectUrl / failureRedirectUrlOnly for checkout Where the customer lands after paying (or failing) the net checkout. Success redirect runs only when books also succeed. Query id is checkoutOrderId from the exchange response (same role as a normal create id). Ignored for counter settle.

Response uses exchangeId (amend) and checkoutOrderId (net-payment order; verify / receipt / cancel). Confirm the amend with exchange_fulfilled or re-POST same reference, not from the browser redirect alone.

LegAwecount (sync on)Money
ReturnCredit noteTill handback when returning items
SaleSales voucher (cash)Full add amount on the bill, not the QR amount
SettleNoneGateway / till collects net only (when > 0)

Success response

{
  "exchangeId": "019f-exchange-uuid",
  "reference": "019f-adjustment-uuid",
  "parentOrderId": "019f-parent-sale-uuid",
  "status": "Open",
  "settleAmount": 2000,
  "checkoutOrderId": "019f-checkout-uuid",
  "checkoutUrl": "https://pay.awecode.com/…",
  "fulfilled": false,
  "return": { "id": "019f-refund-uuid", "amount": 28000, "receipt": null },
  "sale": { "id": "019f-sale-uuid", "amount": 30000, "receipt": null }
}

Checkout settle right after POST: receipts still null. Counter / net 0 returns fulfilled: true with receipts when sync is on.

  • fulfilled: true when settleAmount is 0, settle was cash, or settle Success and required CN/INV are synced.
  • Checkout settle: two webhooks on the settle order when books succeed : payment_success (money) then exchange_fulfilled (amend done).
  • Same reference resumes / polls; different payload → 409. After expire/cancel (Failed), use a new reference.

Checkout settle checklist

Only if you use settle.method: "checkout" with net > 0. Counter / net 0 / return-only can ignore this.

  1. Keep the amend pending until fulfilled: true.
  2. Confirm via poll (re-POST same reference) and/or exchange_fulfilled.
  3. Do not confirm on that order’s payment_success or the browser redirect alone (money / UX only; redirect can be spoofed). After pay + books OK the customer does land on settle.successRedirectUrl (id = checkoutOrderId).
  4. Unwind pending UI when settle expires or is cancelled (exchange Failed; no CN/INV). Past expiresAt with a stale checkoutUrl → treat as expired.
  5. After abandon/cancel, a late pay does not book the amend; keep UI unwound; start a new amend with a new reference.
  6. If books fail after money Success: verify/redirect return an error (no success redirect). Retry: settle verify or POST /api/orders/{checkoutOrderId}/receipt (checkoutOrderId from the exchange response).

Thuprai Pay

Every payment method in one checkout. Money settles to your own accounts.

© 2026 Awecode