Offering Affirm as a payment option on your site consists of creating a checkout form, securely tokenizing customer information, and using that checkout_token to initiate a charge.
We make it easy to build a smooth and stress-free buying experience:
A simple application requiring a few pieces of information for a real-time decision
More purchasing power for your customers with flexible payment options
Customization and branding options that integrate harmoniously with your site
A seamless and secure transaction experience for you and your customers
## How it works
Affirm checkout is the process of collecting your customer's details when they choose Affirm to pay for their purchase. After the customer submits their checkout, you create a checkout object and your customer is either redirected to Affirm or sees an Affirm modal. We then present the option to sign in or sign up to select and confirm their loan terms. Once they fill out the required information, they’re redirected back to your site’s confirmation page.
## 1. Set up your Affirm account
Before you start, you need an Affirm account to access our merchant account credentials. To begin your integration process, you’ll need to [sign in to your account](🔗).
## 2. Add Affirm.js

Use only your sandbox API keys and domain for testing and development. This ensures that you don't accidentally modify your live transactions.
Include the following script in the head section on every page on your site. The script should always load directly from the Affirm domain.
Adding `Affirm.js
` creates a defined instance of Affirm on your client. This grants you access to the following methods within the Affirm object to trigger multiple actions:
`
affirm.checkout({ })
` - Stores the `checkout
` object and is used for the checkout request payload.`
affirm.checkout.post()
` - Sends the `checkout
` object via `POST
` request.
## 3. Initiate checkout
Rendering the Affirm checkout is the process in which a customer uses Affirm to pay for a purchase on your site. You can create a `checkout
` object and launch Affirm checkout using the `Checkout
` function.

You can find more information on how to [create a checkout object](🔗) via our Affirm Javascript library.
## 4. Handle callbacks
After you initiate a checkout and the customer confirms their Affirm loan, we send an HTTP request with the `checkout_token
` to the URL you defined in the `checkout
` object (`user_confirmation_url
`). By default, Affirm sends this request via `POST
`. However, you can configure the checkout object to have Affirm send this request via `GET
`.
You choose how we send the `checkout_token
` by setting the user_confirmation_url_action parameter in the checkout object.
Setting it to `
POST
` sends the `checkout_token
` in the body of the HTTP request (default setting).Setting it to `
GET
` sends the `checkout_token
` in the query string of the HTTP request.
## 5. Create a transaction
When a customer successfully completes a checkout, it is recorded as a new purchase attempt. This needs to be handled on your server-side to be fulfilled via our [Transaction API](🔗).