Payment flow
This page explains what happens between creating a charge and fulfilling an order, and how to handle each outcome.
Sequence
Section titled “Sequence”Your server NogorPay API Customer Hosted checkout | | | | |-- POST /charge/create -> | | |<-- payment_url -------| | | |------------- redirect to payment_url ------->|------------------------>| | | | pays with bKash/Nagad | | |<----------------- TrxID submitted --------------| |<- webhook charge.completed | | | | |<-- redirect_url --------| |-- GET /charge/verify -> (optional check) | |Charge lifecycle
Section titled “Charge lifecycle”pending ──► verifying ──► completed │ ├──► cancelled (customer cancelled) └──► expired (checkout closed before payment)| Status | Webhook | Final? |
|---|---|---|
pending |
None | No |
verifying |
None | No |
completed |
charge.completed |
Yes |
cancelled |
charge.cancelled |
Yes |
expired |
None | Yes |
Recommended integration
Section titled “Recommended integration”- Create the order first in your database with status
awaiting_payment. - Create the charge with your
order_idand awebhook_url. Store the returnedinvoice_idon the order. - Redirect the customer to
payment_url. - Handle the webhook. On
charge.completed, verify the signature, check thatamountequals the order total, and mark the order as paid. Ignore duplicates. - Handle the return. When the customer lands on your
redirect_url, show the order status from your database. If the webhook hasn’t arrived yet, call Verify a charge once and show “Payment processing” if it’s stillverifying. - Handle cancel and expiry. On
cancel_urlor afterexpires_at, offer a Try again button that creates a new charge.
Pre-selecting a payment method
Section titled “Pre-selecting a payment method”To show your own bKash and Nagad buttons:
- Call List payment methods and render a button for each method, using
logoandname. - Hide or disable a method if the order total is below
min_amountor abovemax_amount. - When the customer picks one, create the charge with
payment_methodset to the method’sprovider, for examplebkash. The checkout opens directly on that method.
Brands
Section titled “Brands”If you run more than one store or website, create a brand for each in the dashboard. Pass brand_id when you create a charge so the checkout shows the right name and logo and uses that brand’s gateways. Without brand_id, NogorPay uses your default brand.
