Skip to main content
A Payment is one attempt to collect an amount from a shopper. Your server creates it, the shopper’s browser confirms it, and the API routes it to a processor according to the store’s payment policy. If the processor or the issuer declines, the API can move it to a backup processor before it concludes.

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 carries client_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:
See the browser client guide for card fields, wallets and redirect returns.
A resolved confirmPayment does not mean success. It returns the payment as it is: it can still be processing or requires_action after a polling limit, or failed. Fulfil orders from your server, after reading the payment with your secret key.

next_action

When a payment is requires_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 your return_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.