How our Direct API Integration Works

See how Affirm works online, step by step.

Overview

Affirm offers customers seamless pay over time options. To build an Affirm integration that best works for your business, see how things work behind the scenes of an Affirm transaction.

Affirm's basic process flow begins when the customer selects Affirm at checkout. The steps below represent what the customer experiences on the front-end, and how Affirm's integration handles the checkout on the back-end. Testing


Transaction flow

Affirm transaction flow

Affirm transaction flow


1. Customer initiates a checkout

The Affirm checkout process begins when the customer selects Affirm as their payment method and submits a checkout.

The Affirm checkout process begins when the customer selects Affirm as their payment method and submits a checkout.


2. Create, configure, and send the Checkout object

Once the checkout object has been configured with the consumer and cart info, trigger the checkout.open() function to initiate the Affirm application flow in either a redirect or iframe modal.

The checkout object is the data payload that gets POSTed to the Affirm API to initialize checkout and contains all the information about the customer's order.

ParameterDescription
merchant
required
API Key, Success & Failure Callback
billing
optional
Name, Address, Phone, and Email
shipping
required
Name, Address, Phone, and Email
items
required
Item Objects; Price, Qty, SKU, and URL
metadata
optional
Additional details pertaining to the transaction
total
required
Include values for Shipping, Tax, and Total

3. Collect customer information

After the customer goes through the Affirm flow to select and confirm their loan terms, we redirect the customer to your confirmation page defined in the user_confirmation_url property of the checkout object.

Next, we send an HTTP request with the checkout_token to your page so you can parse the response and store it.


4. Authorize the transaction and complete the order

Send an authorization request

Send an Authorize Transaction request by passing the checkout_token.

Verify the authorized amount

Affirm requires a verification on the merchant side that checks if the authorized amount matches the order total. This is a security measure to make sure that the transaction amount matches the order information prior to order confirmation. The authorized amount will be returned in the transaction object sent in the authorization response.

Complete the order

  • Store the id from the transaction object, which is used for all future transaction actions, retrieved from the Authorize Transactions API response.
  • Redirect the customer to the order confirmation page or display a confirmation message.
  • This completes the order so you can fulfill it.