Affirm payments
Affirm lets a US buyer pay for a purchase in installments. The buyer approves a plan on Affirm's site or app, you receive the full amount, and Affirm collects the installments from the buyer. On Flint, Affirm is the affirm payment option. It uses the same PaymentIntent, order, Refund, and Dispute resources as a card, and the same webhooks.
Two things make it different from a card:
- The buyer leaves your page. They approve the plan at Affirm and come back to a return page you name. The return itself tells you nothing about the outcome, so your backend reads the payment to find out.
- Affirm decides each purchase. It can decline a buyer after every Flint check passes. Always offer card next to Affirm.
How much you build depends on where the buyer pays:
| Where the buyer pays | What you build |
|---|---|
| Flint Checkout or a payment link | Nothing beyond turning Affirm on. Flint runs the redirect, the return, and retries. |
| Your page, with a PaymentIntent your server creates | The five steps below and a return page. |
| Your own checkout on a headless checkout session or an order | The same browser steps, paid through the order. See Affirm on an order. |
How an Affirm payment flows#
- Your server sends POST /v1/payment-intents with payment_return_url to Flint
- Flint returns payment_collection with Flint's return_url to Your server
- Browser sends ConfirmationToken with that return_url to Your server
- Your server sends POST /confirm with the token to Flint
- Flint returns requires_action and current_payment_action to Your server
- Browser sends Open the Flint URL to redirect the buyer to Affirm
- Affirm sends buyer decides, returns to the relay to Flint
- Flint returns 303 to your payment_return_url to Browser
- Your server sends read the PaymentIntent to Flint
- Flint returns the outcome, also sent by webhook to Your server
The steps build on the collect-and-confirm flow in Server-confirmed payments. Affirm adds the return URL, the redirect, and the return page.
Turn on Affirm#
Affirm is off by default. To turn it on, you need Affirm pricing on your Flint plan, an active Affirm capability on your payment account, and card payments turned on, which Stripe requires for Affirm. Outstanding onboarding requirements don't turn Affirm off by themselves. Read your merchant to see which of these is missing:
curl https://api.withflintpay.com/v1/merchant \
-H "Authorization: Bearer YOUR_API_KEY"
Find the entry with capability: "accept_affirm_payments" in readiness.capabilities. When its status is ready, you can turn Affirm on. Otherwise status_reason names the first blocker:
status_reason | What it means | What to do |
|---|---|---|
payment_option_not_in_plan | Your Flint plan doesn't include Affirm. | Contact Flint support to add it. |
payment_option_access_not_provisioned | Affirm pricing isn't set up for this environment. | Contact Flint support. |
payment_option_activation_pending | Flint is reviewing billing and eligibility for Affirm. | Contact Flint support to check on the review. |
payment_option_not_available | Affirm isn't available for this environment. | Contact Flint support to review eligibility. |
requirements_due | Stripe turned Affirm off until the payment account has more details. | Complete requirements in a merchant account session. |
next_actions on the entry says who acts on each blocker. Other reasons mean what Going live lists.
Once the capability is ready, add Affirm to your checkout payment options in the dashboard. With the API, read the current options first.
curl https://api.withflintpay.com/v1/settings/effective \
-H "Authorization: Bearer YOUR_API_KEY"
PATCH /v1/settings replaces the entire checkout.enabled_payment_options list. Send affirm and every option you want to keep from the effective settings. This example adds Affirm to the default list of card, Apple Pay, and Google Pay.
curl -X PATCH https://api.withflintpay.com/v1/settings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"checkout": {"enabled_payment_options": ["card", "apple_pay", "google_pay", "affirm"]}}'
Turning Affirm on before the capability is ready fails with 409 PAYMENT_OPTION_UNAVAILABLE. The error's reason names the blocker, and its next action points back to GET /v1/merchant. Clear the blocker, confirm status: "ready", then try again.
Turning Affirm on makes it available to your account. Flint still checks each payment on its own, as the next section describes.
Eligibility#
Flint checks every Affirm payment against the facts it can see and rejects it when one of these rules fails:
- The currency is USD, and the amount is within the limits for where the buyer pays.
- Your payment account, the buyer's billing address, and any shipping address are in the US.
- The payment is one-time and made with the buyer present. A ConfirmationToken that asks to save the payment method is rejected.
- One payment covers the full balance. Affirm can't share an order with a gift card, another payment, or a manual payment. The one exception is Return credit applied to an exchange's replacement order.
- The surface offers Affirm, as Where Affirm is offered lists.
Some rules depend on facts Flint never receives, so your integration enforces them by not offering Affirm:
- The purchase is a consumer sale, not business to business.
- The goods or services are available now. Affirm doesn't allow pre-orders.
- Your business is not in one of Stripe's prohibited or restricted categories for Affirm.
Amount limits#
The minimum is $50.00 everywhere. The maximum depends on where the buyer pays:
| Where the buyer pays | Minimum | Maximum |
|---|---|---|
| Standalone PaymentIntent, Flint Checkout, or invoice | $50.00 | $30,000.00 |
| Payment link | $50.00 | $25,000.00, or up to $30,000.00 when Flint support raises it |
A limit you configure yourself can narrow this range but not widen it. An amount outside the range fails when you create the payment with 409 PAYMENT_OPTION_UNAVAILABLE, reason amount_out_of_range, and param amount_money.amount. Above the maximum, the error also carries maximum_money. The message names the payment option and surface that set the limit. Flint checks the amount again at confirmation, so an amount that changed between the two calls is caught there.
Where Affirm is offered#
| Offered | Not offered |
|---|---|
| Flint Checkout, hosted or headless | Subscriptions and invoice autopay |
| Fixed-price payment links | Donation, event, and buyer-chosen-amount payment links |
| Standalone PaymentIntents | Charges to a saved payment method, or without the buyer present |
| One-time invoices, paid on the hosted invoice page or an invoice checkout session | Virtual terminal |
| Collecting a Return's balance | Any split payment |
Asking for Affirm where it isn't offered fails with 400 INVALID_REQUEST and detail code NOT_ALLOWED. The message says which rule blocked it, such as the surface or a split payment.
Accept an Affirm payment#
These steps take a standalone PaymentIntent from creation to the redirect. You need an API key with payments.payment_intents.write.
Handle the return#
Affirm sends the buyer back to Flint's relay. The relay drops every query parameter Affirm added and answers with a 303 to your payment_return_url, exactly as you gave it. Look up the payment_intent_id you stored for the reference in your path, or list GET /v1/payment-intents?external_reference_id=1042, and check the payment from your backend:
curl https://api.withflintpay.com/v1/payment-intents/pi_1kmn0aExample \
-H "Authorization: Bearer YOUR_API_KEY"
If status is still requires_action, Flint may not have heard from Stripe yet. Confirm again with the payment already attached. Flint checks the payment with Stripe and returns its current state:
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: affirm-return-1042" \
-d '{}'
{
"data": {
"payment_intent_id": "pi_1kmn0aExample",
"status": "succeeded",
"selected_payment_option": "affirm",
"payment_source": {"type": "affirm"},
"support_reference": "N7XBTQJ4KMEXAMPLE",
"current_payment_action": null
}
}
Then act on status:
status | What happened | What to do |
|---|---|---|
succeeded | Affirm approved the plan and the payment is complete. | Show the confirmation. Fulfill once, from the webhook or this result. |
requires_capture | Affirm approved a manual-capture hold. | Capture in full before authorization_expires_at. |
requires_action | The buyer hasn't finished at Affirm, or closed the tab. | Show that the payment is waiting. To continue, run the returned current_payment_action again. |
requires_payment_method | Affirm declined, or the buyer left or ran out of time. | Read last_payment_error.code and offer another try. |
A confirm with an omitted payment_source after the status has moved past requires_action returns 409 ACTION_NOT_ALLOWED. Read the PaymentIntent first, as above, and confirm only while it's requires_action.
Don't create a second PaymentIntent or ConfirmationToken because the buyer came back. They may still be inside Affirm's flow, and a lost redirect is recovered by reading the existing payment. Server-confirmed payments gives the full recovery order.
Fulfill from webhooks#
Affirm adds no event types. It sends the usual PaymentIntent events:
Fulfill from payment_intent.succeeded, or from order.paid for an order, after you check dispute_status, never from the buyer's return. Webhooks covers signatures and retries.
Failures and retries#
A failed Affirm attempt leaves the PaymentIntent in requires_payment_method, with one of these codes in last_payment_error.code:
| Code | What happened | Flint Checkout's retry |
|---|---|---|
payment_method_declined | Affirm declined the buyer for this purchase. | Checkout hides Affirm and keeps every other eligible method, with card first when available. |
payment_method_temporarily_unavailable | Affirm couldn't take the payment right now. | Checkout hides Affirm and keeps every other eligible method, with card first when available. |
payment_not_completed | The buyer left Affirm without approving a plan. | Card first, Affirm still offered. |
payment_action_expired | The buyer didn't finish at Affirm in time. | Card first, Affirm still offered. |
payment_method_unavailable | Affirm isn't available for this payment. | Card first, Affirm still offered. |
The failed attempt is over. To retry, create a new ConfirmationToken and confirm the same PaymentIntent again. On your own page you choose what to offer, because Flint doesn't change payment_options on a PaymentIntent after a failure. Following Flint Checkout's pattern is a good default.
Affirm on an order#
When the payment belongs to an order, such as a headless checkout session you build on or an order your server pays, the browser steps are the same and the payment runs through the order:
- Return URL. On a headless checkout session, send
payment_return_urlwhen you create the session. A session that offers Affirm without it fails with400 INVALID_REQUESTand detail codeREQUIRED. The same URL rules apply. An order your server pays takespayment_return_urlonPOST /v1/payment-intentsinstead. - Collection. Read
payment_collectionfrom the order. Itsstripe.return_urlis Flint's relay, and the ConfirmationToken must carry that exact URL. - Payment. Pay with
POST /v1/orders/{order_id}/pay. The attempt returnsrequires_actionwith a pending action that sends the buyer to Affirm. Open its Flint URL as in step 5, or explicitly opt in to the Stripe.js path. - Return. On your return page, read the order and its payment attempt. If the attempt is still
requires_action, pay again with"action": "resume"and theorder_payment_attempt_id. Finish 3D Secure shows the resume request, which works the same way for Affirm. - Fulfillment. Fulfill from
order.paid, after you check the order'sdispute_statusagainst the access rules.
A headless session must also leave Affirm enough time. When fewer than 15 minutes remain in the session's payment window, the payment fails with 409 PAYMENT_OPTION_UNAVAILABLE and reason action_window_too_short before the buyer is sent anywhere. Start a new payment attempt or offer card. A standalone PaymentIntent has no such window.
This works for order checkouts, invoice checkout sessions, and a Return's balance collected through a session with "surface": "headless". Build your own checkout walks through the session flow.
Manual capture#
Affirm's authorization window is seven days from the authorized charge's creation time. Creating the PaymentIntent earlier doesn't start that window, and returning from Affirm or refreshing the payment doesn't restart it. Read authorization_expires_at for the deadline and capture before it.
Affirm supports "capture_method": "manual" with one capture for the full hold. Capture with no amount_money, or with the full capturable_money:
curl -X POST https://api.withflintpay.com/v1/payment-intents/pi_1kmn0aExample/capture \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: affirm-capture-1042"
Any other amount returns 400 INVALID_REQUEST with detail code NOT_ALLOWED and param amount_money. You can't raise, lower, or reauthorize an Affirm hold. Capture before authorization_expires_at. Manual capture covers holds, cancellation, and expiry.
Refunds#
Refund an Affirm payment with the Refunds API, as you would a card. Both full and partial refunds work:
curl -X POST https://api.withflintpay.com/v1/refunds \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: affirm-refund-1042-1" \
-d '{
"payment_intent_id": "pi_1kmn0aExample",
"refund_type": "amount",
"amount_money": {"amount": 2500, "currency": "USD"}
}'
Affirm applies the refund to the buyer's loan. It cancels scheduled installments and returns what the buyer already paid, minus any interest they paid. As with every refund, the original processing fee isn't returned.
Affirm sets three limits:
- 120 days. Submit refunds within 120 days of the stored capture time. The PaymentIntent's
refund_expires_atis the last accepted time; after it,POST /v1/refundsreturns409 ACTION_NOT_ALLOWEDwith reasonrefund_window_expired. Later payment-attempt updates do not move this deadline. If the capture time is missing,refund_expires_atisnulland Flint lets the provider decide whether the refund is still allowed. Canceled payments have no refund window. Reimburse the buyer another way if the window has ended. - Asynchronous. A refund can take up to two days. Wait for
refund.succeededorrefund.failed, and don't try to cancel it: an Affirm refund can't be canceled once submitted. - One failure ends refunds. If a refund on an Affirm payment fails, the money stays in your balance and the buyer hasn't been paid. Reimburse them outside Flint. Any later refund on that payment returns
409 ACTION_NOT_ALLOWEDwith reasonprevious_refund_failed. Reconcile the failed Refund.
A refund that fails during the request still returns 201 and can already carry status: "failed". If the response is pending, follow it with GET /v1/refunds/{refund_id} or refund.* events. A later failure arrives as refund.failed. Check status on every create response.
Disputes#
An Affirm dispute is the same Dispute resource as a card chargeback, with payment_option set to affirm. Buyers sign in to Affirm to approve every payment, and Affirm covers losses from buyer fraud. On Affirm's behalf, Stripe may ask you to pause a shipment before a loss happens. Do so promptly. Handling disputes covers evidence and deadlines.
Read an Affirm payment#
After the buyer chooses Affirm, three fields on the PaymentIntent identify it:
{
"payment_intent_id": "pi_1kmn0aExample",
"status": "succeeded",
"selected_payment_option": "affirm",
"payment_source": {"type": "affirm"},
"support_reference": "N7XBTQJ4KMEXAMPLE",
"risk": null
}
support_referencebecomes Affirm's transaction reference. Give it to a buyer who contacts Affirm support; it's the value Affirm asks for. Until Affirm issues one, it holds the PaymentIntent ID, so treat it as an opaque string.payment_source.typeisaffirm, with no card or bank details.riskisnull. Flint doesn't risk-assess Affirm payments; Affirm's approval and your own controls apply.
Show Affirm plans before checkout#
Stripe's Payment Method Messaging Element shows the plans a buyer may qualify for on product, cart, and payment pages. Create it on the same connected-account Stripe instance as the Payment Element, with the amount you'll charge:
stripe
.elements()
.create("paymentMethodMessaging", {
amount: order.totalAmount, // minor units, such as 9900 for $99.00
currency: "USD",
countryCode: "US",
paymentMethodTypes: ["affirm"],
})
.mount("#affirm-message");
The element shows plans that may be available, not an approval. Don't write your own installment amount, APR, or approval claim next to it; Affirm's marketing compliance guides govern that copy. Stripe uses cookies and IP addresses to record which Elements a buyer saw. Disclose that, and get any consent your page needs.
Test in a sandbox#
With a test API key, make the same calls. payment_return_url can be an http://localhost URL. When the buyer chooses Affirm and submits, Stripe shows a test page in place of Affirm where you approve or fail the payment:
- Approve to see
payment_intent.succeeded, orpayment_intent.requires_capturewith manual capture. - Fail to see
payment_intent.payment_failedand exercise your retry path. - Close the test page without choosing, then return, to exercise the
requires_actionbranch of your return page.
There are no Affirm test amounts. Any amount within the limits works.
Errors#
API calls#
Related guides#
Server-confirmed paymentsBuild your own checkoutDeclines and payment attempts- Manual capture: holds, capture, and expiry.
- Refunds: the refund lifecycle and failed refunds.
- Handling disputes: evidence and deadlines.