Pay a quote
POST/api/quotes/:id/pay
Creates the order (waybill and delivery) from the quote, marks the quote accepted, then starts the payment. Creating the order is idempotent: calling Pay again reuses it, so a failed payment can be retried with another method. The order stays when the payment step fails.
qr and app pay through FlashPay, which settles in THB: the gateway amount is converted, the payment itself stays in the quote's currency. bank_transfer returns a receiving account and a reference code. wallet pays from the sender's prepaid balance and dispatches the order at once.
An ownerless quote must be opened with Get a quote first; Pay does not claim it.
Signature only; a user session is not accepted. The sender account is named in X-Sender-Account-Id, which is outside the signature: it must belong to the organization of the API key. Missing header: 401 unauthenticated. Malformed, unknown or another organization's account: 403 forbidden (the same answer for all three).
Request
Responses
- 200
- 400
- 401
- 403
- 404
- 409
- 500
- 503
Payment started (or, for wallet, completed).
type is not one of the allowed values. Here error is a sentence, not a code.
Signature missing or invalid (Unauthorized), or X-Sender-Account-Id missing (unauthenticated).
forbidden: the quote is not this sender's (including an ownerless quote), or X-Sender-Account-Id is malformed, unknown or belongs to another organization.
not_found: no such quote (including a malformed id) or order.
payment_method_not_allowed: the organization or the quote's service does not accept this method (allowed lists what it does). not_payable: the quote is not active or is past expires_at (it is then marked expired), or its order is no longer awaiting payment. An order already created from the quote stays payable after expires_at: its price was fixed when it was created. no_bank_account_available: no receiving account can take this payment. insufficient_balance: the wallet does not cover it.
pay_failed: anything else, e.g. bank_code missing for app, or the order's invoice not payable (detail explains).
flashpay_not_configured: the organization has no FlashPay setup. exchange_rate_not_configured: the quote's currency cannot be converted to THB.