Payment flow at a glance
- Load the Payment Element script in the browser.
- Create an Elements instance with your public key.
- Mount the hosted card field.
- Submit through
elements.submit(...). - Your backend creates
POST /v2/transactions. - The SDK handles 3DS automatically or returns
requires_action. - Your backend finalizes the order through webhooks and reconciliation.
Frontend example
What elements.submit() does
When a card element is mounted, elements.submit():
- creates an Elements session if one does not already exist
- associates the session with the card field
- tokenizes the card
- calls your
createTransactioncallback with the tokenized data - inspects the returned transaction payload
- continues 3DS automatically if
next_actionis present and auto modal is enabled - otherwise returns
requires_actionso your code can callPagou.handleNextAction(...)
elements.submit() expects your createTransaction callback to return the transaction object itself, with top-level status and next_action.
Backend example
Backend contract rules
Your backend should:- create the transaction with your secret credentials
- return a shape the frontend can use directly
- preserve
id,status, andnext_action - store the transaction ID for reconciliation
next_action object before the browser receives it.
Result handling
Treat the immediate browser result as an integration result, not a fulfillment decision.| Browser outcome | Meaning | What to do |
|---|---|---|
error | submit or tokenization failed | show retry UI |
requires_action | manual continuation is required | call Pagou.handleNextAction(...) |
transaction status such as pending or authorized | payment flow advanced but may not be final | show pending UI |
succeeded from challenge handling | challenge completed | still wait for backend-confirmed final state |
failed, canceled, timed_out from challenge handling | challenge did not complete successfully | allow retry and reconcile if needed |
Fulfillment model
Your backend should own the final payment decision. Recommended rule:- browser starts the payment
- webhook confirms the final business-safe state
- reconciliation handles missing or uncertain webhook timing
Webhook pattern
Production checklist
- disable duplicate submit while the flow is in progress
- use a stable
external_refper order attempt - store the Pagou transaction ID
- preserve
next_actionfor the browser - fulfill only from final backend-confirmed states
- reconcile uncertain outcomes with
GET /v2/transactions/{id}

