Statuses
succeeded, failed and canceled are final. Refunds and disputes later change the amounts (amount_refunded, amount_disputed), not the status.
status is an open enum: handle a value you do not know as “not final yet”.
Create on the server
amount and currency are required. amount is an integer in the currency minor unit. Useful optional fields:
The full schema is in Create a payment.
The client secret
The create response carriesclient_secret, shaped pay_<id>_secret_<random>:
- It is returned only to the server that created the payment, and on an idempotent replay of that create. Every other read returns
client_secret: null. - Pass it to the page that collects the payment, for example in your server-rendered HTML or an authenticated JSON response. It lets a browser holding your publishable key confirm and read this one payment, nothing else.
- Never put it in a URL, never log it, never store it beyond the checkout.
Confirm in the browser
The browser client confirms the payment and performs every next action until the payment is final or the shopper leaves for a redirect:next_action
When a payment isrequires_action, next_action describes the step. It is null otherwise.
The browser reports each finished 3DS step to
POST /v1/payments/{id}/authentication. The API reads the result from the provider or processor itself; nothing the browser sends is taken as the result.
next_action.type is an open enum. The browser client raises UnsupportedNextActionError for a type it does not know.
After a redirect
When the shopper returns to yourreturn_url, call handleReturn with the same clientSecret. It reports the return to the API and waits for the answer:
Capture, cancel, retry
Refunds are their own resource:
POST /v1/refunds.