Payments overview

The whole payment flow — Localoy opens a session, your checkout charges through your gateway, your server reports the result, and refunds are recorded.

With Open Network payments you collect the money through your own gateway and Localoy records the outcome against the order. Localoy never handles card or wallet details. Every call here needs the PAYMENT scope.

EndpointWhat it does
GET /payments/sessions/:idReads the session: amount, customer, returnUrl.
POST …/:id/resultReports PROCESSING, SUCCEEDED, FAILED or CANCELLED.
POST …/:id/refundRecords a full refund of a succeeded session.

The flow#

Paying, then refunding
Paying, then refundingCustomerLocaloyYour serverYour gateway1. Pay for an order2. Open a payment session3. Redirect ?session_id=…4. GET /payments/sessions/{id}5. amountMinor, returnUrl6. Charge amountMinor7. Transaction ID8. POST …/result SUCCEEDEDAmount and currency checked; order marked paid9. 200 + webhook payment.updated10. Redirect to returnUrlLater, if you refund11. Refund the charge12. POST …/refund13. 200 session REFUNDED
  1. Customer → Localoy: Pay for an order
  2. Localoy → Localoy: Open a payment session
  3. Localoy → Your server: Redirect ?session_id=…
  4. Your server → Localoy: GET /payments/sessions/{id}
  5. Localoy → Your server: amountMinor, returnUrl
  6. Your server → Your gateway: Charge amountMinor
  7. Your gateway → Your server: Transaction ID
  8. Your server → Localoy: POST …/result SUCCEEDED
  9. Note: Amount and currency checked; order marked paid
  10. Localoy → Your server: 200 + webhook payment.updated
  11. Your server → Customer: Redirect to returnUrl
  12. — Later, if you refund —
  13. Your server → Your gateway: Refund the charge
  14. Your server → Localoy: POST …/refund
  15. Localoy → Your server: 200 session REFUNDED
  1. Read the session. Your checkout page receives only session_id. Take the amount from the API, never from the browser. Refuse unless status is PENDING or PROCESSING and isExpired is false.
  2. Charge exactly amountMinor in BDT and keep your gateway's transaction ID.
  3. Report the result with an Idempotency-Key. SUCCEEDED marks the order paid. FAILED (with failureCode and failureReason) marks it failed and the customer can retry. A SUCCEEDED whose amount or currency differs from the session is refused with 409 and the order is not paid.
  4. Send the customer back to returnUrl exactly as the session gives it. Nothing in the browser can change a payment.
  5. Refund through your gateway first, then record it. A refund is always for the full amount and only a SUCCEEDED session can be refunded.

Session statuses#

FromCan become
PENDINGPROCESSING, SUCCEEDED, FAILED, CANCELLED, EXPIRED
PROCESSINGSUCCEEDED, FAILED, CANCELLED, EXPIRED
FAILEDPROCESSING, SUCCEEDED
EXPIREDSUCCEEDED (a charge that completes after expiry is still accepted)
SUCCEEDEDREFUNDED (refund endpoint only)
CANCELLED, REFUNDEDFinal

Rules to remember#

  • Which orders go through your checkout: event ticket orders, activity bookings, dining reservations, tour bookings, food and store orders, catalogue bookings and package purchases, while your production checkout is enabled.
  • A sandbox key sees only sandbox sessions; test sessions change no order and fire no webhook.

Guide: Accept payments, including the checkout settings.