Server-confirmed payments
Use this flow to charge an amount on your own page with a standalone PaymentIntent: a balance top-up, a deposit, or a payment for something you track outside Flint. The browser collects the buyer's card, wallet, or bank account with Stripe Elements and turns it into a ConfirmationToken. Your server sends that token to Flint, and Flint confirms the payment.
The browser never confirms the PaymentIntent. The create response has no client secret, so the first confirmation always comes from your server, through your risk rules and Flint's idempotency. If the buyer has to act, the confirm response carries a Stripe client secret for that step. It can also confirm the payment, so pass it only to handleNextAction and take the outcome from your server. Cards, Apple Pay, Google Pay, ACH debit, and Affirm all use this flow.
If you're selling items, use an order instead. An order carries line items, tax, and totals, and you pay it through the order as Embedded payments describes. A checkout session gives you a Flint-hosted page. Orders first helps you choose.
How it works#
- Your server sends POST /v1/payment-intents to Flint
- Flint returns payment_collection to Your server
- Browser sends mount Elements, create a ConfirmationToken to Stripe
- Browser sends the token's ctoken_ ID to Your server
- Your server sends POST /confirm with the token to Flint
- Flint returns status, and current_payment_action if the buyer must act to Your server
- Browser sends handleNextAction, for 3D Secure to Stripe
- Your server sends POST /confirm with credential_type attached to Flint
- Flint returns the outcome, also sent by webhook to Your server
The calls this guide uses:
Your API key needs payments.payment_intents.write. To save the card as well, it also needs payments.payment_methods.write. Apple Pay and Google Pay buttons appear only on hostnames you've registered.
Take a payment#
Act on the result#
A confirmation that Flint runs returns 200, whether the payment succeeded, needs the buyer, or was declined. Branch on status, not the HTTP status:
status | What happened | What to do |
|---|---|---|
succeeded | The payment was collected. | Fulfill, or wait for payment_intent.succeeded if you fulfill from webhooks. |
requires_capture | A manual capture hold is in place. | Capture or cancel it before authorization_expires_at. |
processing | An ACH debit was submitted, and the bank hasn't answered. | Wait for payment_intent.succeeded or payment_intent.payment_failed. |
requires_action | The buyer must act, usually for 3D Secure, or to approve an Affirm plan. | Run the buyer action. |
requires_payment_method | The payment was declined or blocked, and last_payment_error says why. | Ask for another payment method. |
Your server can return status and current_payment_action to the browser. Keep your API key and the rest of the payment on the server.
Choose a credential#
The first confirmation names exactly one credential in credential_type:
credential_type | Field | Use it for |
|---|---|---|
stripe_confirmation_token | stripe.confirmation_token | A ConfirmationToken the browser created from payment_collection.stripe. This is the normal case. |
token | payment_source_token | A processor payment method ID, such as the pm_... that stripe.createPaymentMethod returns. |
payment_method | payment_method_id | A saved payment method that belongs to the PaymentIntent's customer. |
attached | None | Continuing after a buyer action. See Continue with the attached credential. |
Send only the field that belongs to your credential_type. A field from another type returns 400 INVALID_REQUEST with detail code NOT_ALLOWED, and an empty string returns 400 INVALID_REQUEST. Create and update never take a credential; only confirm does. To help risk evaluation, you can also send a Flint-Buyer-Device header: a random 32-character lowercase hex ID that you keep for the buyer's device.
Handle 3D Secure and other buyer actions#
When the bank asks the buyer to authenticate, the confirm response has status: "requires_action" and a current_payment_action:
{
"data": {
"payment_intent_id": "pi_1kmn0aExample",
"status": "requires_action",
"supported_actions": ["confirm", "cancel"],
"current_payment_action": {
"pending_action_id": "pendact_1kmn0aExample",
"subject": {
"payment_intent": {"payment_intent_id": "pi_1kmn0aExample"}
},
"action_type": "payment_authentication",
"client_action": {
"stripe": {
"account_id": "acct_Example",
"publishable_key": "pk_test_Example",
"payment_intent": {
"stripe_js_call": "handle_next_action",
"client_secret": "pi_Example_secret_Example"
}
}
}
}
},
"request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4F"
}
Every confirm response includes current_payment_action, and it's null when the buyer has nothing to do. Only confirm responses carry it: reads, lists, and webhooks leave it out. Act on the typed action, never on status alone, and never on payment_collection. The action carries a Stripe PaymentIntent client secret for this step. It can also confirm the payment at Stripe with a different card, so pass it only to handleNextAction, never to confirmPayment or confirmCardPayment, and read the outcome from your backend.
In the browser, run the Stripe.js call that stripe_js_call names, with a Stripe instance for the action's own publishable_key and account_id. Then ask your server to continue, even if Stripe.js reported an error, because Flint reads the real outcome from the processor:
// result is {status, current_payment_action} as your server relays it.
async function handleResult(result, continuations = 0) {
if (["succeeded", "requires_capture", "processing"].includes(result.status)) {
return showConfirmation();
}
if (result.status === "requires_payment_method") {
return showMessage("Your payment was declined. Try another card or payment method.");
}
if (result.status !== "requires_action" || continuations >= 3) {
return showMessage("We couldn't finish your payment. Try again in a moment.");
}
if (!result.current_payment_action) {
// Flint couldn't produce the action yet. Continue to fetch it.
return continuePayment(continuations + 1);
}
const action = result.current_payment_action.client_action.stripe;
if (action.payment_intent?.stripe_js_call !== "handle_next_action") {
throw new Error("Unsupported payment action");
}
const actionStripe = Stripe(action.publishable_key, {stripeAccount: action.account_id});
const {error} = await actionStripe.handleNextAction({
clientSecret: action.payment_intent.client_secret,
});
if (error) showMessage(error.message);
await continuePayment(continuations + 1);
}
async function continuePayment(continuations) {
const response = await fetch("/api/topups/1001/continue", {method: "POST"});
await handleResult(await response.json(), continuations);
}
For Affirm, handleNextAction sends the buyer to Affirm, and they come back through a return page instead. Affirm payments covers that page.
Continue with the attached credential#
After the browser action, your server calls the same confirm route with credential_type: "attached". Don't send a new credential: the continuation uses the payment attempt, credential, and risk decision of the first confirmation.
curl -X POST https://api.withflintpay.com/v1/payment-intents/pi_1kmn0aExample/confirm \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: continue-pi_1kmn0aExample-pendact_1kmn0aExample" \
-d '{"credential_type": "attached"}'
Flint reads the payment's state from the processor first, and confirms again only if the processor still needs a confirmation. Otherwise it confirms nothing and returns the current PaymentIntent:
- The buyer authenticated: the result is
succeeded,requires_capture, orprocessing. - The buyer hasn't finished: the result is still
requires_action, withcurrent_payment_actionagain. This is also how you get the action back after a lost response. - Authentication failed: the result is
requires_payment_methodwithlast_payment_error.codeauthentication_required. Treat it as a decline.
If status is requires_action but current_payment_action is null, Flint couldn't produce the action yet. The confirmation already happened, so don't send a new credential. Confirm again with credential_type: "attached", and contact support with the request_id if the action stays null.
Continuations are safe to repeat. Two continuations at once, even with different idempotency keys, lead to one confirmation at the processor.
attached works only for a PaymentIntent that a confirmation has already started:
- On a PaymentIntent that was never confirmed, it returns
400 INVALID_REQUESTwith detail codeREQUIREDonstripe.confirmation_token. Send the buyer's credential instead. - Once
statusissucceeded,canceled,expired,processing, orrequires_capture,supported_actionsno longer listsconfirm, and confirm returns409 ACTION_NOT_ALLOWEDwithcurrent_status. The exception is a confirmation Flint started and hasn't finished recording:attachedfinishes it and returns its result.
Handle a decline#
A declined or blocked payment isn't an API error. Confirm returns 200 with the PaymentIntent back at requires_payment_method, and last_payment_error says why:
{
"data": {
"payment_intent_id": "pi_1kmn0aExample",
"status": "requires_payment_method",
"supported_actions": ["confirm", "cancel"],
"selected_payment_option": "card",
"last_payment_error": {
"code": "insufficient_funds",
"message": "The payment method has insufficient funds. Ask the customer to use a different payment method.",
"failed_at": "2026-10-28T18:04:12Z",
"remediation": {
"retry": "none",
"next_steps": "Try again with a different payment method."
}
},
"current_payment_action": null
},
"request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4G"
}
Show the buyer a message based on code, not message, which is written for you. Then let them try again with the same Elements instance: create a new ConfirmationToken and confirm with it, using a new idempotency key. Replaying the declined request's key returns the same decline and charges nothing.
Declines and payment attempts lists every code, which ones to show the buyer, and when last_payment_error is set and cleared.
Recovery and idempotency#
If your server loses a response, recover the existing payment. Don't create another PaymentIntent or ask for a new token.
- Retry the lost request with the same
Idempotency-Keyand body. A request Flint finished replays its result withIdempotency-Replayed: true. - If you no longer have the key, read the PaymentIntent with
GET /v1/payment-intents/{payment_intent_id}. The read doesn't includecurrent_payment_action. - If
statusisrequires_action, confirm withcredential_type: "attached"to get the action. Run it in the browser if the buyer hasn't, then confirm withattachedagain to continue. - If
statusisrequires_confirmation, a confirmation was interrupted. Confirm withattachedto finish it. - Stop when
statusissucceeded,requires_capture,processing,canceled, orexpired. Atrequires_payment_method, readlast_payment_error: if it's set, the payment was declined.
Sending the same ConfirmationToken again is also safe. A token this PaymentIntent already used returns the current PaymentIntent instead of an error, and Flint doesn't confirm it twice. A token another PaymentIntent used, or one that expired, returns 409 ACTION_NOT_ALLOWED.
A 5xx or a timeout means you don't know the outcome. Retry with the same key. Flint records the real outcome once the processor reports it, and never writes last_payment_error for an outcome it couldn't learn. Idempotency covers keys, replays, and conflicts for every route.
Save the card for later charges#
Send save_payment_method: true with the first confirm to keep the card the buyer pays with. Flint saves it for the PaymentIntent's customer as a payment method with usage: "off_session", so you can charge it later without the buyer: for a subscription, an automatic invoice, or as the customer's default card. The buyer enters the card and completes any authentication once, for both the payment and the save.
Saving works for standalone PaymentIntents, the only ones /confirm accepts. To save a card without taking a payment, see Save a card and charge it later.
Show the buyer what they agree to#
A card with usage: "off_session" can be charged while the buyer is away, so save it only when the buyer agreed to that on your page before they paid. Put the wording next to the pay button, and say:
- that you will keep the card,
- what you will charge it for, and
- when, or how often, you will charge it.
For example: "Save this card. Cedar & Stone Coffee will charge it for each monthly coffee delivery until you cancel." When saving is optional, ask with an unchecked checkbox, and send save_payment_method: true only when the buyer checked it.
With setupFutureUsage: "off_session", the Payment Element also shows a line saying the buyer allows future charges. Keep it, since a card saved this way does receive them. It doesn't say what you will charge or when, so show your own wording as well.
Before you confirm#
- The PaymentIntent has a customer. Flint saves the card for the PaymentIntent's
customer_id. Set it when you create the PaymentIntent, or withPATCH /v1/payment-intents/{payment_intent_id}while the status isrequires_payment_method. - Your credential can save cards. The API key or partner token needs
payments.payment_methods.writeas well aspayments.payment_intents.write. - The credential is new. Send a card, Apple Pay, or Google Pay credential collected for this confirm: a
stripe.confirmation_tokencreated withsetupFutureUsage: "off_session", or apayment_source_token. A savedpayment_method_idis already kept, so it can't be sent withsave_payment_method: true. - Card payments are enabled for the environment. Until they are, the save fails with
409 MERCHANT_NOT_READY, with reasoncapability_not_requestedoronboarding_required.
Create the PaymentIntent with the customer:
curl -X POST https://api.withflintpay.com/v1/payment-intents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: subscription-start-1002" \
-d '{
"amount_money": {"amount": 4200, "currency": "USD"},
"payment_options": ["card", "apple_pay", "google_pay"],
"customer_id": "cus_1kmn0aExample"
}'
Create the token with setupFutureUsage#
Stripe saves the card from the ConfirmationToken, so the token carries the buyer's choice. Set setupFutureUsage: "off_session" on Elements before you call stripe.createConfirmationToken, and clear it when the buyer unchecks the option:
const saveCard = document.querySelector("#save-card");
saveCard.addEventListener("change", () => {
elements.update({setupFutureUsage: saveCard.checked ? "off_session" : null});
});
Wait for the Elements update-end event after a change before you create the token, then send the token and the buyer's choice to your server. When the purchase always saves the card, pass setupFutureUsage: "off_session" when you create Elements instead.
The token must match the request:
save_payment_method: truewith a token created withoutsetupFutureUsage, or with"on_session", returns400 INVALID_REQUESTwith detail codeNOT_ALLOWEDonstripe.confirmation_token. Create a new token afterelements.updatefinishes.- A token created with
setupFutureUsage, sent withoutsave_payment_method: true, returns the same error. Send the buyer's choice, or create the token withoutsetupFutureUsage. - Only a card, Apple Pay, or Google Pay can be saved. A bank account or Affirm with
save_payment_method: truereturns400 INVALID_REQUESTwith detail codeNOT_ALLOWED. When the PaymentIntent also offers ACH debit or Affirm, clearsetupFutureUsagebefore creating a token for one, and leavesave_payment_methodout.
Confirm with save_payment_method#
curl -X POST https://api.withflintpay.com/v1/payment-intents/pi_1kmn0aExample/confirm \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: confirm-pi_1kmn0aExample-ctoken_Example-save" \
-d '{
"credential_type": "stripe_confirmation_token",
"stripe": {"confirmation_token": "ctoken_Example"},
"save_payment_method": true
}'
Leaving save_payment_method out and sending false do the same thing: nothing is saved.
If the bank asks the buyer to authenticate, run the action as for any payment. That one authentication covers both the payment and the saved card. Then continue with {"credential_type": "attached"} and no save_payment_method. The payment attempt keeps the first confirmation's choice: sending true returns 400 INVALID_REQUEST with detail code REQUIRED on save_payment_method, and false doesn't cancel the save.
Wait for payment_method.activated#
Flint saves the card after the payment is approved: when the PaymentIntent is succeeded, or requires_capture for manual capture. That happens after the confirm response, so the response doesn't include the saved card.
- Handle the
payment_method.activatedwebhook. Its object is the saved card, with itspayment_method_id,customer_id,status: "active", andusage: "off_session". You can charge it from then on. - To link the card to this payment, read the PaymentIntent.
payment_source.card.payment_method_idnames the saved card. Flint sets it after saving the card and sendspayment_intent.updatedwhen it does, sopayment_method.activatedcan arrive first. If the field isn't there yet, wait for thatpayment_intent.updated.
curl https://api.withflintpay.com/v1/payment-intents/pi_1kmn0aExample \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": {
"payment_intent_id": "pi_1kmn0aExample",
"customer_id": "cus_1kmn0aExample",
"status": "succeeded",
"payment_source": {
"type": "card",
"card": {
"brand": "visa",
"last4": "4242",
"payment_method_id": "pm_1kmn0aExample"
}
}
},
"request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4H"
}
- A declined payment saves nothing. The PaymentIntent returns to
requires_payment_method, and the next confirmation with a new credential uses that request'ssave_payment_method. Send it again if the buyer still wants the card saved. - Canceling an uncaptured payment, or refunding it after approval, doesn't remove the saved card. Remove it with
DELETE /v1/payment-methods/{payment_method_id}when you don't want to keep it. - If the customer is deleted before the save finishes, Flint saves nothing and sends no event.
Errors#
An error response is a refusal, not a payment outcome. Read param for the field to change and details[0].reason where a row names one, and fix what the error describes before you send a corrected request with a new idempotency key. OPERATION_IN_PROGRESS is the exception: resend the same request.
Order-linked PaymentIntents#
/confirm is for standalone PaymentIntents only. A PaymentIntent created through an order never lists confirm in supported_actions, and /confirm refuses it with 409 ACTION_NOT_ALLOWED and reason order_owned. remediation.next_actions names the order's pay route. Pay it with POST /v1/orders/{order_id}/pay, and continue a buyer action there with action: "resume" and the order_payment_attempt_id, as Embedded payments describes.
Capture, cancel, and refunds work the same for both kinds. See Manual capture and Refunds.
Webhooks#
Confirm responses are enough to drive the browser, but outcomes that arrive later, such as an ACH debit settling, reach you only by webhook. Subscribe to these on the endpoint that tracks payments:
Disputes and refunds send their own dispute.* and refund.* events. Deliveries can be duplicated, delayed, or out of order: verify signatures, deduplicate by event ID, and read the PaymentIntent when order matters. See Webhooks.
Test the flow#
In the sandbox, the browser flow works with any test card. Use for a payment that succeeds, and for one that asks for 3D Secure, each with any future expiry date and any CVC.
To script the flow without a browser, confirm with one of Stripe's fixed test aliases. Create the PaymentIntent as in step 1, then send the alias as a token credential:
curl -X POST https://api.withflintpay.com/v1/payment-intents/pi_1kmn0aExample/confirm \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: confirm-pi_1kmn0aExample-test" \
-d '{"credential_type": "token", "payment_source_token": "pm_card_visa"}'
| Alias | Outcome |
|---|---|
pm_card_visa | The PaymentIntent is succeeded. |
pm_card_chargeDeclined | The PaymentIntent is back at requires_payment_method with last_payment_error.code of card_declined. |
pm_card_chargeDeclinedInsufficientFunds | The same, with insufficient_funds. |
pm_card_authenticationRequired | The PaymentIntent is requires_action, with a 3D Secure step for the browser. |
The same alias works on any number of payments in a sandbox. Testing lists more aliases, including ones for disputes, reviews, and fraud warnings. To rehearse an order instead, pay it with a test token.
Test a decline, a 3D Secure step that succeeds, one that fails, and a lost response: send the same confirm twice with the same key, and the second response carries Idempotency-Replayed: true.
