Skip to content

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.

Your server sends the first confirmation through your risk rules and Flint's idempotency. The create response has no client secret. When the buyer must act, current_payment_action tells you how to complete the step. Flint's API returns a Stripe client secret only when the request sends client_action_type: "stripe", while url is the default; with url, your page never receives one, and Stripe's authentication page receives what it needs to run the challenge. Take the payment outcome from your server. Cards, Apple Pay, Google Pay, ACH debit, and Affirm all use this flow.

If you're selling items, create an order instead. An order carries line items, tax, and totals, and you pay it from your page as Embedded payments describes: pay the order in one call, or confirm its payment intent as Confirm an order payment shows. A checkout session gives you a Flint-hosted page. The overview and Orders first help you choose.

How it works#

A server-confirmed paymentResponse
BrowserYour serverFlintStripePOST /v1/payment-intentspayment_collectionmount Elements, create a ConfirmationTokenthe token's ctoken_ IDPOST /confirm with the tokenstatus, and current_payment_action if the buyer must actOpen the Flint authentication URLPOST /confirm without payment_sourcethe outcome, also sent by webhook
  1. Your server sends POST /v1/payment-intents to Flint
  2. Flint returns payment_collection to Your server
  3. Browser sends mount Elements, create a ConfirmationToken to Stripe
  4. Browser sends the token's ctoken_ ID to Your server
  5. Your server sends POST /confirm with the token to Flint
  6. Flint returns status, and current_payment_action if the buyer must act to Your server
  7. Browser sends Open the Flint authentication URL to Stripe
  8. Your server sends POST /confirm without payment_source to Flint
  9. 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#

  1. Create the PaymentIntent#

    Your server names the amount and the payment options the buyer may use. Idempotency-Key is required: reuse it when you retry the same create, so a timeout doesn't make a second PaymentIntent.

    <!-- docs-test {"scenario":"main","status":201} -->

    cURL
    curl -X POST https://api.withflintpay.com/v1/payment-intents \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: topup-1001" \
      -d '{
        "amount_money": {"amount": 4200, "currency": "USD"},
        "payment_options": ["card", "apple_pay", "google_pay"],
        "external_reference_id": "topup_1001"
      }'
    
    Response
    {
      "data": {
        "payment_intent_id": "pi_1kmn0aExample",
        "status": "requires_payment_method",
        "supported_actions": ["confirm", "cancel"],
        "amount_money": {"amount": 4200, "currency": "USD"},
        "capture_method": "automatic",
        "payment_options": ["card", "apple_pay", "google_pay"],
        "payment_flow": "api",
        "external_reference_id": "topup_1001",
        "last_payment_error": null,
        "version": 1,
        "payment_collection": {
          "stripe": {
            "account_id": "acct_Example",
            "publishable_key": "pk_test_Example",
            "elements": {
              "next_step": "create_confirmation_token",
              "submit_to": "confirm_payment_intent",
              "mode": "payment",
              "amount_money": {"amount": 4200, "currency": "USD"},
              "payment_options": ["card", "apple_pay", "google_pay"],
              "payment_method_creation": "manual"
            }
          }
        }
      },
      "request_id": "req_01KWM6XKAEP3K57S07NV6W8BG3"
    }
    

    Store payment_intent_id with your own record, and pass payment_collection.stripe to the browser unchanged. payment_options lists the Flint payment options to offer. Stripe Elements takes processor method types instead, and wallets ride on card, so map the options as the snippet below does.

    Other create options:

  2. Mount the Payment Element#

    Initialize Stripe.js with payment_collection.stripe.publishable_key. Pass account_id as stripeAccount when it is set. Create deferred Elements using the collection guidance, including on_behalf_of as onBehalfOf when present. Pass payment_method_options through whole when it's present: for ACH debit, Stripe requires the options the browser collected with to match the ones Flint confirms with.

    HTML
    <script src="https://js.stripe.com/v3/"></script>
    
    <form id="payment-form">
      <div id="payment-element"></div>
      <button type="submit">Pay $42.00</button>
      <div id="payment-message" role="alert"></div>
    </form>
    
    JavaScript
    // Your server relays the create response's payment_collection.stripe.
    const collection = paymentCollection.stripe;
    const guidance = collection.elements;
    
    const stripe = Stripe(collection.publishable_key, {
      ...(collection.account_id ? {stripeAccount: collection.account_id} : {}),
    });
    
    // Stripe Elements takes processor method types. Apple Pay and Google Pay ride on card.
    const STRIPE_METHOD_TYPES = {card: "card", apple_pay: "card", google_pay: "card", affirm: "affirm", ach_debit: "us_bank_account"};
    const paymentMethodTypes = [...new Set(guidance.payment_options.flatMap((option) => STRIPE_METHOD_TYPES[option] ?? []))];
    
    const elements = stripe.elements({
      mode: guidance.mode,
      amount: guidance.amount_money.amount,
      currency: guidance.amount_money.currency.toLowerCase(),
      paymentMethodCreation: guidance.payment_method_creation,
      paymentMethodTypes,
      ...(collection.on_behalf_of ? {onBehalfOf: collection.on_behalf_of} : {}),
      ...(guidance.payment_method_options
        ? {paymentMethodOptions: guidance.payment_method_options}
        : {}),
    });
    
    const wallets = guidance.payment_options;
    elements
      .create("payment", {
        wallets: {
          applePay: wallets.includes("apple_pay") ? "auto" : "never",
          googlePay: wallets.includes("google_pay") ? "auto" : "never",
        },
      })
      .mount("#payment-element");
    

    The wallets option hides a wallet the PaymentIntent doesn't allow. Flint refuses a token for a payment option that isn't in payment_options.

    If the buyer reloads the page or comes back later, read the PaymentIntent with GET /v1/payment-intents/{payment_intent_id}. While its status is requires_payment_method or requires_confirmation, the read includes a current payment_collection.

  3. Create the ConfirmationToken#

    When the buyer submits, call elements.submit() to validate the form, then create the token and send its ID to your server.

    JavaScript
    document.querySelector("#payment-form").addEventListener("submit", async (event) => {
      event.preventDefault();
    
      const {error: submitError} = await elements.submit();
      if (submitError) return showMessage(submitError.message);
    
      const {error, confirmationToken} = await stripe.createConfirmationToken({
        elements,
        params: {
          payment_method_data: {
            billing_details: {name: buyer.name, email: buyer.email},
          },
        },
      });
      if (error) return showMessage(error.message);
    
      const response = await fetch("/api/topups/1001/confirm", {
        method: "POST",
        headers: {"Content-Type": "application/json"},
        body: JSON.stringify({confirmation_token: confirmationToken.id}),
      });
      await handleResult(await response.json());
    });
    

    Send accurate billing details. ACH debit requires both the name and the email. A Stripe.js error at this point means Stripe rejected the form, and nothing reached Flint.

    The token is a payment credential. Send it only to your server, over HTTPS, and keep it out of logs, analytics, and browser storage.

  4. Confirm from your server#

    Send the token with credential_type: "stripe_confirmation_token":

    <!-- docs-test {"scenario":"main","status":200,"card":"pm_card_visa"} -->

    cURL
    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" \
      -d '{"payment_source": {"credential_type": "stripe_confirmation_token", "stripe": {"confirmation_token": "ctoken_Example"}}}'
    
    Response
    {
      "data": {
        "payment_intent_id": "pi_1kmn0aExample",
        "status": "succeeded",
        "supported_actions": [],
        "amount_money": {"amount": 4200, "currency": "USD"},
        "captured_money": {"amount": 4200, "currency": "USD"},
        "captured_at": "2026-10-28T18:04:12Z",
        "selected_payment_option": "card",
        "payment_source": {
          "type": "card",
          "card": {"brand": "visa", "last4": "4242"}
        },
        "last_payment_error": null,
        "current_payment_action": null,
        "version": 3
      },
      "request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4D"
    }
    

    An idempotency key built from the PaymentIntent and token IDs, as here, stays the same when you retry the same confirmation and changes when the buyer tries again with a new token. Idempotency-Key is optional on confirm.

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:

statusWhat happenedWhat to do
succeededThe payment was collected.Fulfill, or wait for payment_intent.succeeded if you fulfill from webhooks.
requires_captureA manual capture hold is in place.Capture or cancel it before authorization_expires_at.
processingThe payment was submitted, and Flint is waiting for or confirming its outcome.Wait for payment_intent.succeeded or payment_intent.payment_failed, or read the payment again. Don't start another payment.
requires_actionThe buyer must act, usually for 3D Secure, or to approve an Affirm plan.Run the buyer action.
requires_payment_methodThe 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.

If the processor doesn't answer after Flint sends the confirmation, Flint records the payment as processing and returns 200. Flint resolves the outcome without another confirmation from you, so wait for the payment's events or read it again, and never confirm with a new credential meanwhile. A same-key retry replays that stored 200 response, even after the payment concludes; read the payment or use its events for the current state. If Flint can't save the uncertain outcome, the response is 503 SERVICE_UNAVAILABLE with reason outcome_unknown.

Choose a credential#

The first confirmation sends exactly one payment_source object. Its credential_type selects the credential:

credential_typeFieldUse it for
stripe_confirmation_tokenpayment_source.stripe.confirmation_tokenA ConfirmationToken the browser created from payment_collection.stripe. This is the normal case.
stripe_payment_methodstripe.payment_methodA processor payment method ID, such as the pm_... that stripe.createPaymentMethod returns.
payment_methodpayment_method_idA saved payment method that belongs to the PaymentIntent's customer.
readerreader_id, optional tipPresenting a card on an active reader. Requires payments.readers.write.

To continue with an attached source, omit payment_source. In requires_confirmation, Flint confirms what is attached. In requires_action, it refreshes and returns the current state and action. With no source attached, omission returns 400 INVALID_REQUEST, detail REQUIRED at payment_source.

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. Send the buyer's IP address as buyer_ip_address too; without buyer_ip_address, the payment has no IP address for risk rules and block lists.

Handle 3D Secure and other buyer actions#

For a standalone payment intent, confirm returns a Flint URL by default when the buyer must act. Open current_payment_action.client_action.url as a redirect, popup, or iframe. Flint's API returns a URL for this action, without a Stripe client secret. Stripe's authentication page receives what it needs to run the challenge. The step expires 12 hours after the confirm call that returned the action; use current_payment_action.expires_at as its deadline.

You can also send payment_return_url on confirm to choose where the buyer returns. Flint adds only payment_intent_id to that destination. The return URL must use HTTPS, or a native app scheme other than http, javascript, data, file, blob, or about, and cannot contain credentials, a query, or a fragment. Test mode accepts HTTP loopback URLs too. Without a destination, the completion page posts {type: "flint.payment_action.completed", payment_intent_id: "pi_..."} to its parent and opener. Before trusting this message, check that event.origin equals the origin of the returned Flint payment-action URL (the payment-return host). Read the payment intent to learn whether it succeeded; a completed browser step alone does not establish payment success.

JSON
{
  "payment_return_url": "https://merchant.example/payments/complete",
  "payment_source": {
    "credential_type": "stripe_payment_method",
    "stripe": {
      "payment_method": "pm_1AbcExample"
    }
  }
}

Omitting client_action_type selects url for a new confirmation. You can select it explicitly for Stripe.js with client_action_type: "stripe". A continuation keeps the original action type; requesting a different one returns 409 ACTION_NOT_ALLOWED, reason field_locked, with param: client_action_type and current_status: requires_action.

If the payment method needs a step that cannot open as a URL, confirm returns 409 ACTION_NOT_ALLOWED, reason provider_action_unsupported, and publishes no URL action. Continue with client_action_type: "stripe" to get the Stripe.js handoff. This refusal does not lock the action type.

A URL action looks like this:

JSON
{
  "pending_action_id": "pendact_1kmn0aExample",
  "action_type": "payment_authentication",
  "subject": {"payment_intent": {"payment_intent_id": "pi_1kmn0aExample"}},
  "expires_at": "2026-11-12T00:00:00Z",
  "client_action": {"type": "url", "url": "https://payment-returns.example/payment-returns/actions/pendact_1kmn0aExample/bearer-token"}
}

Treat the URL as a bearer secret: keep it out of logs and analytics, and give it only to the buyer completing this step. Stripe's hosted 3DS2 page receives the PaymentIntent client secret in its URL, so the browser holds that secret during the challenge. Flint strips provider query parameters before sending the buyer to your return destination.

If a payment is confirmed with a payment method Flint didn't approve, Flint doesn't count the charge and returns it to the buyer. The payment intent ends canceled with cancellation_reason: payment_returned.

Opt in to Stripe.js#

When you select client_action_type: "stripe" and the bank asks the buyer to authenticate, the confirm response has status: "requires_action" and a current_payment_action:

JSON
{
  "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",
      "expires_at": "2026-11-12T00:00:00Z",
      "client_action": {
        "type": "stripe",
        "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 stripe 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.

For a split payment, the Stripe action's account_id is null. Load Stripe.js with the action's publishable_key and omit stripeAccount. The action's on_behalf_of identifies the settlement account. It isn't an argument to handleNextAction. Confirm the same PaymentIntent again without payment_source after the challenge.

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:

JavaScript
// 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 handoff = result.current_payment_action.client_action;
  if (handoff.type === "url") {
    window.location.assign(handoff.url);
    return;
  }
  const action = handoff.stripe;
  if (action.payment_intent?.stripe_js_call !== "handle_next_action") {
    throw new Error("Unsupported payment action");
  }

  const actionStripe = Stripe(action.publishable_key, action.account_id ? {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 an explicit Stripe action with 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 without payment_source. Don't send a new credential: the continuation uses the payment attempt, credential, and risk decision of the first confirmation.

<!-- docs-test {"skip":"Requires a completed browser 3DS challenge before continuation; API-only test does not complete authentication."} -->

cURL
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 '{}'

While the confirmation is unfinished, 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, or processing.
  • The buyer hasn't finished: the result is still requires_action, with current_payment_action again. This is also how you get the action back after a lost response.
  • Authentication failed: the result is requires_payment_method with last_payment_error.code authentication_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 without payment_source, and contact support with the request_id if the action stays null.

Repeating a continuation never starts another charge. Two continuations at once, even with different idempotency keys, lead to one confirmation at the processor. A fresh continuation can return the state refusal below once Flint has recorded the outcome.

If the Flint action page or a webhook already finished the standalone payment, a fresh confirm returns 409 ACTION_NOT_ALLOWED with current_status. Reason already_applied with current_status: "succeeded" means the payment is paid. Read GET /v1/payment-intents/{payment_intent_id} or use the payment webhook to recover the recorded outcome; don't treat that refusal as a decline or start another payment.

Continuation uses a source already attached to the PaymentIntent:

  • With no source attached, it returns 400 INVALID_REQUEST with detail code REQUIRED on payment_source. Send the buyer's credential instead.
  • Once status is succeeded, canceled, expired, processing, or requires_capture, supported_actions no longer lists confirm, and confirm returns 409 ACTION_NOT_ALLOWED with current_status. The exception is a confirmation Flint started and hasn't finished recording: confirming without payment_source finishes 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:

Response
{
  "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": "Ask the customer to use a different payment method.",
        "next_actions": [
          {
            "action_type": "confirm_payment_intent",
            "reason_code": "provide_a_different_payment_method",
            "required_fields": ["payment_method_id"],
            "required_scope": "payments.payment_intents.write"
          }
        ]
      }
    },
    "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.

  1. Retry the lost request with the same Idempotency-Key and body. A request Flint finished replays its result with Idempotency-Replayed: true. If that result is processing, it stays processing on every replay, so read the payment for its current state.
  2. If you no longer have the key, read the PaymentIntent with GET /v1/payment-intents/{payment_intent_id}. The read doesn't include current_payment_action.
  3. If status is requires_action, confirm without payment_source to get the action. Run it in the browser if the buyer hasn't, then confirm again without payment_source to continue.
  4. If status is requires_confirmation, a confirmation was interrupted. Confirm without payment_source to finish it.
  5. If status is processing, Flint is waiting for or confirming the outcome. Wait for payment_intent.succeeded or payment_intent.payment_failed, or read again. Don't confirm again.
  6. Stop when status is succeeded, requires_capture, canceled, or expired. At requires_payment_method, read last_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 lost response never leaves you guessing whether Flint sent the payment. After Flint sends it to the processor, the answer is the payment in its current state, possibly processing, and last_payment_error stays null until a failure is known. A 503 with reason outcome_unknown means Flint couldn't record the outcome: keep the key, read the PaymentIntent before you do anything else, and contact support with the request_id if it still doesn't settle. 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 here works for standalone PaymentIntents and order legs. An order leg saves for the order's customer_id for off-session reuse. To save the card while your backend pays an order with POST /v1/orders/{order_id}/pay, see Save a card while the customer pays. 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 with PATCH /v1/payment-intents/{payment_intent_id} while the status is requires_payment_method.
  • Your credential can save cards. The API key or partner token needs payments.payment_methods.write as well as payments.payment_intents.write.
  • The credential is new. Send a card, Apple Pay, or Google Pay credential collected for this confirm: a payment_source.stripe.confirmation_token created with setupFutureUsage: "off_session", or a payment_source.stripe.payment_method. A saved payment_method_id is already kept, so it can't be sent with save_payment_method: true.
  • Card payments are enabled for the environment. Until they are, the save fails with 409 MERCHANT_NOT_READY, with reason capability_not_requested or onboarding_required.

Create the PaymentIntent with the customer:

<!-- docs-test {"scenario":"save","status":201,"fixtures":{"customer":true},"expect":{"data.status":"requires_payment_method"}} -->

cURL
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:

JavaScript
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: true with a token created without setupFutureUsage, or with "on_session", returns 400 INVALID_REQUEST with detail code NOT_ALLOWED on payment_source.stripe.confirmation_token. Create a new token after elements.update finishes.
  • A token created with setupFutureUsage, sent without save_payment_method: true, returns the same error. Send the buyer's choice, or create the token without setupFutureUsage.
  • Only a card, Apple Pay, or Google Pay can be saved. A bank account or Affirm with save_payment_method: true returns 400 INVALID_REQUEST with detail code NOT_ALLOWED. When the PaymentIntent also offers ACH debit or Affirm, clear setupFutureUsage before creating a token for one, and leave save_payment_method out.

Confirm with save_payment_method#

<!-- docs-test {"scenario":"save","status":200,"card":"pm_card_visa","expect":{"data.status":"succeeded","data.current_payment_action":null}} -->

cURL
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 '{
  "save_payment_method": true,
  "payment_source": {
    "credential_type": "stripe_confirmation_token",
    "stripe": {
      "confirmation_token": "ctoken_Example"
    }
  }
}'

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 {} 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.

  1. Handle the payment_method.activated webhook. Its object is the saved card, with its payment_method_id, customer_id, status: "active", and usage: "off_session". You can charge it from then on.
  2. To link the card to this payment, read the PaymentIntent. payment_source.card.payment_method_id names the saved card. Flint sets it after saving the card and sends payment_intent.updated when it does, so payment_method.activated can arrive first. If the field isn't there yet, wait for that payment_intent.updated.

<!-- docs-test {"scenario":"save","status":200,"waitFor":"data.payment_source.card.payment_method_id"} -->

cURL
curl https://api.withflintpay.com/v1/payment-intents/pi_1kmn0aExample \
  -H "Authorization: Bearer YOUR_API_KEY"
Response
{
  "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's save_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.

  • HTTP 400
    param names the field to correct. payment_source with detail code REQUIRED: no credential is attached. payment_source.stripe.confirmation_token with INVALID_VALUE: the token was created for another environment or account, or an ACH debit token lacks the buyer's online mandate acceptance or a billing name and email; create a new token from the returned payment_collection. NOT_ALLOWED: the token's payment option isn't in the PaymentIntent's payment_options, more than one credential was sent, or the token's setupFutureUsage doesn't match save_payment_method. On save_payment_method with REQUIRED: it was sent with a saved payment_method_id, with no credential, or on a continuation.
  • HTTP 403
    The API key or partner token lacks payments.payment_methods.write, which save_payment_method: true needs. Nothing else happens. Add the scope, or confirm without save_payment_method.
  • HTTP 404
    The PaymentIntent doesn't exist in this environment, or, with save_payment_method, its customer doesn't exist or was deleted.
  • HTTP 409
    Reason confirmation_token_unusable with param payment_source.stripe.confirmation_token: the token expired or another PaymentIntent used it, and message says which; create a new one with Stripe.js and send it. Reason managed_by_owner: follow the owner's command in remediation.next_actions. Reason configuration_required with param save_payment_method: the standalone PaymentIntent or owning order has no customer_id. Reason in_progress with save_payment_method: the customer is being deleted, so no card can be saved for them. With current_status and no param: the PaymentIntent's status no longer accepts confirm.
  • HTTP 409
    OPERATION_IN_PROGRESSRetry the same request
    Another confirmation of this PaymentIntent is still running. Wait for Retry-After when present, then resend the same request with the same Idempotency-Key.
  • HTTP 409
    VERSION_CONFLICTRefresh, then retry
    The PaymentIntent changed while Flint was confirming it, such as its amount, or expected_version is stale. Read it again and rebuild the request. Follow the key instruction in next_steps.
  • HTTP 409
    The account can't take this payment yet. details[0].reason names the readiness step to finish.
  • HTTP 409
    The payment option, or saving cards, isn't available for this merchant or amount. Offer another option, or confirm without save_payment_method.

Order-linked PaymentIntents#

/confirm also starts a single order leg covering the balance or continues its holding attempt. Checkout credentials can confirm their own session’s legs. See Confirm an order payment for owner restrictions and card saving.

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 stripe_payment_method credential:

<!-- docs-test {"scenario":"test-card","status":200,"fixtures":{"payment":{"amount":4200}},"expect":{"data.status":"succeeded","data.current_payment_action":null}} -->

cURL
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 '{"payment_source": {"credential_type": "stripe_payment_method", "stripe": {"payment_method": "pm_card_visa"}}}'
AliasOutcome
pm_card_visaThe PaymentIntent is succeeded.
pm_card_chargeDeclinedThe PaymentIntent is back at requires_payment_method with last_payment_error.code of card_declined.
pm_card_chargeDeclinedInsufficientFundsThe same, with insufficient_funds.
pm_card_authenticationRequiredThe 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.

Declines and payment attemptsEvery decline code, buyer messages, and how last_payment_error changes.3D SecureWhen banks ask for authentication, require_3ds rules, and 3DS test cards.Manual capturePlace a hold at confirmation, then capture part or all of it.ACH debit paymentsBank debits on the same flow, with mandates and settlement.Save a card and charge it laterSave a card without a payment, and charge it off session.

Divide a payment between sellers#

A collecting merchant can create a standalone PaymentIntent with splits to send fixed shares of one payment to sellers. This divides the payment's funds. Split tender means the buyer pays with several payment methods.

Use the collecting merchant's own credentials. Each seller must install the same partner app owned by that merchant, approve receiving splits in the payment's mode, and be ready to receive payouts. First set payment_splits.seller_terms_url on the app, then send each seller through authorization. Test mode needs no platform review. Live payments require the app's active payment_splits capability and an account Flint supports for splits.

Response
{
  "amount_money": {"amount": 10000, "currency": "USD"},
  "payment_options": ["card"],
  "splits": [
    {
      "partner_app_install_id": "pinst_01KF3A8C2D4E6F8G0H2J4K6M8N",
      "amount_money": {"amount": 6000, "currency": "USD"},
      "description": "Order 1042: mugs",
      "external_reference_id": "1042-mugs"
    }
  ]
}

Send 1 to 25 entries, once per install, each with an amount above zero in the payment's currency. Optional description is 1 to 500 characters; optional external_reference_id is 1 to 255. Both are shown to the seller. The total must leave enough for Flint's largest fee across the offered payment options and at least one minor unit for the collecting merchant. A total that doesn't fit returns INVALID_REQUEST, with INVALID_VALUE at splits and maximum_money.

For a split payment, payment_collection.stripe.account_id is null and payment_collection.stripe.on_behalf_of is the collecting merchant's Stripe account ID. Initialize Stripe.js with publishable_key, omitting stripeAccount. Pass on_behalf_of as the onBehalfOf option when you create Stripe Elements, then create the confirmation token.

A token created with stripeAccount returns INVALID_VALUE at payment_source.stripe.confirmation_token. If the token's settlement account is missing or differs from the payment's, confirmation returns last_payment_error.code: "confirmation_token_account_mismatch". Create Elements with the account from the collection guidance, collect a fresh token, and submit a new confirmation request.

Saved payment methods, payment_source.stripe.payment_method, save_payment_method: true, install tokens, and platform_fee can't be used for split payments. A Flint customer_id can still link the customer to the sale.

Splits are fixed after create, except for final amounts at capture. PATCH never accepts splits. Before confirmation, cancel the PaymentIntent and create another to change the sellers. Changing amount_money or tip_money below what the stored splits need returns LIMIT_EXCEEDED with minimum_money at the changed field.

Read current split state in PaymentIntent.splits or through the payment split routes. Changes send payment_split.* events. After the payment succeeds, sellers' shares wait until the payment's funds are available and any dispute has closed. A split credits the seller's Flint balance; the seller's normal payouts send it to its own bank. A marketplace can't pay a seller's bank directly or send a split outside a payment.

Confirm an order payment#

With merchant credentials, use the same POST /v1/payment-intents/{payment_intent_id}/confirm request for a staged order leg, including a checkout-session leg or an exchange balance. A single leg must cover the order balance, with no other unpaid staged legs or selected gift cards. Flint applies the order's payment effects. If the leg is held by an open attempt, omit payment_source to continue that attempt.

Create the leg with order_id, then confirm it. Omit amount_money and the leg takes the order's outstanding balance:

<!-- docs-test {"scenario":"order-leg","status":201,"fixtures":{"order":2500},"expect":{"data.status":"requires_payment_method"}} -->

cURL
curl -X POST https://api.withflintpay.com/v1/payment-intents \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: leg-ord_1kmn0aExample-1" \
  -d '{"order_id": "ord_1kmn0aExample"}'

<!-- docs-test {"scenario":"order-leg","status":200,"card":"pm_card_visa","expect":{"data.status":"succeeded","data.current_payment_action":null}} -->

cURL
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" \
  -d '{"payment_source": {"credential_type": "stripe_confirmation_token", "stripe": {"confirmation_token": "ctoken_Example"}}}'

A decline returns 200 with the leg back at requires_payment_method, as for a standalone payment. A success also pays the order, so fulfill from order.paid.

For a deposit, create a leg with the deposit's amount_money, then call POST /v1/orders/{order_id}/pay with action: "confirm_payment_intents", that leg and its payment_source in payment_intents, expected_outstanding_money set to the order's current balance, and completion_behavior: "partial_payment". The order stays open for the remaining balance. Starting a deposit through the leg's /confirm route returns 409 ACTION_NOT_ALLOWED with reason managed_by_owner naming pay_order; refreshing an unchanged order won't make the deposit cover its balance.

For an order with tracked items, Flint reserves the stock before attempting the deposit. A successful deposit holds the stock for 24 hours after the payment finishes processing. Later deposits use and renew the same hold while it is active. Paying the balance commits the stock. Once the hold expires, the next payment must reserve stock again. If the first attempt fails or is canceled before collecting money, Flint releases any new hold from that attempt. Refunding a deposit keeps the hold while the order stays open, even when you refund the full deposit. Closing the order releases the deposit hold.

Authentication returns a url action by default. Send client_action_type: "stripe" for a Stripe.js handoff. An omitted choice on a continuation keeps the stored type; a different explicit type returns 409 ACTION_NOT_ALLOWED with reason field_locked on client_action_type. Reader payments keep their Stripe behavior.

Check supported_actions before starting. When the order needs several payments together, managed_by_owner names pay_order in remediation.next_actions. With merchant credentials, invoice confirmation names collect_invoice; subscription confirmation names create_subscription_payment_retry. These owner refusals apply to both start and continuation. A checkout credential can start and continue its own session's legs through this confirm route, including invoice checkout legs. Other sessions' intents and standalone intents return 404 RESOURCE_NOT_FOUND. Checkout credentials cannot send save_payment_method; use order pay to save a buyer card.

save_payment_method: true keeps a newly collected card for the order's customer_id for off-session use. It requires payments.payment_methods.write in addition to payments.payment_intents.write. Set the order's customer first; an order without one returns configuration_required on the order.

Was this helpful?