Callback payload
Billions sends an HTTPPOST request with a JSON body:
The request uses the
Content-Type: application/json header.
Safe callback algorithm
1
Accept the request
Parse only enough data to identify the invoice. Reject malformed requests
without exposing internal error details.
2
Retrieve the invoice
Call the authenticated Billions API with the invoice ID.
3
Match your records
Confirm the retrieved invoice belongs to the expected
order_no and payment
attempt.4
Apply the transition once
Update the order in a database transaction and make side effects idempotent.
5
Return promptly
Respond successfully after durable processing, or enqueue slow work for a
background worker.
Security checklist
- Keep API keys in server-side secret storage.
- Require HTTPS for the callback endpoint.
- Retrieve invoice state from the API before fulfillment.
- Compare the invoice to the stored order and expected amount.
- Treat all callback fields as untrusted input.
- Avoid logging API keys or complete sensitive payloads.
- Rate-limit the callback endpoint.
- Make duplicate delivery harmless.
Response behavior
Your endpoint should acknowledge a callback only after the event is stored or processed durably.TODO: Add the delivery timeout, retry schedule, expected HTTP success codes,
signature mechanism if applicable, and source IP policy after the callback
delivery implementation is finalized.