Include the Affirm JS snippet on your checkout page, initialized with your public API key; use Affirm.ui.ready() to ensure the SDK is loaded before rendering promotional messaging widgets.
On checkout, construct the checkout object in JavaScript with 'merchant' details, 'shipping' and 'billing' address objects, 'items' array with SKU/price/quantity, 'discounts', 'tax_amount', and 'total' in cents.
Call affirm.checkout(checkoutObject) and then affirm.checkout.open() to launch the Affirm loan application modal; provide a success callback that receives a 'checkout_token'.
Send the 'checkout_token' to your server; authorize the charge server-side: POST /api/v2/charges with the checkout_token, using HTTP Basic auth with your private API key. A successful response returns a charge object with 'id' and status 'authorized'.
When you ship the order, capture the charge: POST /api/v2/charges/{charge_id}/capture — only capture the amount actually shipped; Affirm supports partial captures for partial fulfillment.
Handle void (cancel before capture) and refund (after capture) via POST /api/v2/charges/{charge_id}/void and POST /api/v2/charges/{charge_id}/refund respectively.
Known gotchas
The checkout_token is single-use and typically expires within a few minutes — if the user navigates away and returns, you must restart the checkout flow and get a new token; never cache and reuse tokens.
Affirm has a minimum and maximum loan amount (which varies by market and may change); if the cart total falls outside these bounds, the Affirm option should be hidden rather than presented and rejected at checkout.
Authorization does not move money — you must explicitly capture within Affirm's authorization window (typically 30 days) or the authorization expires and you cannot collect payment without the customer re-authorizing.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp