---
updatedAt: 2026-02-02T21:52:50.000Z
agentTools:
  siteIndex: https://docs.affirm.com/llms.txt
  projectIndex: https://docs.affirm.com/payments/llms.txt
---

# Set Up Split Capture

Easily integrate Affirm Split Capture to offer flexible payment options, customize the experience to match your brand, and ensure a smooth, secure checkout for your customers.

<HTMLBlock>{`
<style>
  .dropdown-menu {
    font-family: Arial, sans-serif;
    max-width: 250px;
    margin-left: auto; /* Align to the right */
  	margin-right: 0; /* Ensure it's flush to the right */
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    background: #4A4AF4;
    overflow: hidden; /* Ensure the container grows with content */
  }

  .dropdown-item {
    margin-bottom: 10px;
  }

  .dropdown-toggle {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
  }

  .dropdown-toggle:hover {
    background: #f0f0f0;
  }

  .dropdown-content {
    display: none;
    margin-top: 5px;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
  }

  .dropdown-item.open .dropdown-content {
    display: block;
  }

  .flag-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }

  .product-item {
    margin-bottom: 5px;
    color: black;
  }

  .product-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }
  
  .country-title {
    font-family: Arial, sans-serif;
    font-size:20px;
    text-align: center;
    font-weight: bold;
    color: #ffffff;
  } 

</style>
  <div class="dropdown-menu">
    <p class="country-title" alt="Countries where this product is available">Country Availability</p>

    <div class="dropdown-item">
      <button class="dropdown-toggle" onclick="toggleDropdown(event)" alt="Drop down menu displaying the available countries for this product">
        <b>Country List</b> ⬇️
      </button>
      <div class="dropdown-content">
        <div class="product-item">
          <img src="https://files.readme.io/a4c8b3d6596d943e2b93c82cb1d432a2edaf6998667835c2e97ef4a31d460c7e-us-circle-01.png" alt="USA" class="flag-icon">
          USA
        </div>
        <div class="product-item">
          <img src="https://files.readme.io/3ca294a1b4b8b8506c3ff32876abc6e3e33d0e65a509dab81398915094bdbc5c-61TcZ33ZrJL._AC_UY1000_.jpg" alt="Canada" class="flag-icon">
          Canada
        </div>
      </div>
    </div>

  </div>
`}</HTMLBlock>

## Prerequisites

* Set up your [Affirm account](https://www.affirm.com/dashboard/signin) to access to your merchant account credentials.

## Steps

### 1. Add Affirm.js

Add the Affirm.js script to the `<head>` on your site. The script loads directly from the Affirm domain.

> 🚧 Sandbox API Keys
>
> Use only your sandbox API keys and domain during testing and development. This ensures that you don't accidentally modify live transactions.

```javascript
<script>
var _affirm_config = {
		public_api_key: "YOUR_PUBLIC_API_KEY", /* replace with public api key */
		script: "https://cdn1-sandbox.affirm.com/js/v2/affirm.js",
		locale: "en_US",
		country_code: "USA",
	};

(function(m,g,n,d,a,e,h,c){var b=m[n]||{},k=document.createElement(e),p=document.getElementsByTagName(e)[0],l=function(a,b,c){return function(){a[b]._.push([c,arguments])}};b[d]=l(b,d,"set");var f=b[d];b[a]={};b[a]._=[];f._=[];b._=[];b[a][h]=l(b,a,h);b[c]=function(){b._.push([h,arguments])};a=0;for(c="set add save post open empty reset on off trigger ready setProduct".split(" ");a<c.length;a++)f[c[a]]=l(b,d,c[a]);a=0;for(c=["get","token","url","items"];a<c.length;a++)f[c[a]]=function(){};k.async=
  !0;k.src=g[e];p.parentNode.insertBefore(k,p);delete g[e];f(g);m[n]=b})(window,_affirm_config,"affirm","checkout","ui","script","ready","jsReady");
</script>
```

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.

### 2. Initiate checkout

Create a checkout object and launch the checkout process with the Checkout function. Rendering the Affirm checkout enables your customers to use Affirm to pay for purchases on your site.

```javascript
affirm.checkout({
 
      "merchant": {
        "user_confirmation_url":    "https://merchantsite.com/confirm",
        "user_cancel_url":          "https://merchantsite.com/cancel",
        "user_confirmation_url_action": "POST",
        "name": "Your Customer-Facing Merchant Name"
      },
      "shipping":{
        "name":{
          "first":"Joe",
          "last":"Doe"
        },
        "address":{
          "line1":"633 Folsom St",
          "line2":"Floor 7",
          "city":"San Francisco",
          "state":"CA",
          "zipcode":"94107",
          "country":"USA"
        },
        "phone_number": "4153334567",
        "email": "joedoe@123fakestreet.com"
      },
      "billing":{
        "name":{
          "first":"Joe",
          "last":"Doe"
        },
        "address":{
          "line1":"633 Folsom St",
          "line2":"Floor 7",
          "city":"San Francisco",
          "state":"CA",
          "zipcode":"94107",
          "country":"USA"
        },
        "phone_number": "4153334567",
        "email": "joedoe@123fakestreet.com"
      },
      "items": [{
        "display_name":         "Awesome Pants",
        "sku":                  "ABC-123",
        "unit_price":           1999,
        "qty":                  3,
        "item_image_url":       "http://merchantsite.com/images/awesome-pants.jpg",
        "item_url":             "http://merchantsite.com/products/awesome-pants.html"
        "categories": [
            ["Home", "Bedroom"],
            ["Home", "Furniture", "Bed"]
        ],
      }],
      "shipping_amount":        1000,
      "tax_amount":             500,
      "total":                  5997
  });

affirm.checkout.open()
```

> 📘 Create a Checkout Object
>
> You can find more information on how to [create a checkout object](https://docs.affirm.com/payments/docs/create-a-checkout-object) via our Affirm Javascript library.

### 3. Add the checkout button

Add the pre-styled checkout button. For details, see <Anchor label="Checkout Button" target="_blank" href="https://docs.affirm.com/developers/docs/pre-styled-checkout-button">Checkout Button</Anchor> .

### 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, we send this request via `POST`. You can configure the checkout object so that we send this request via `GET`.

To choose how we send the `checkout_token`, you can set the `user_confirmation_url_action` parameter in the checkout object to:

* `POST` to send the `checkout_token` in the body of the HTTP request (default setting).
* `GET` to send the `checkout_token` in the query string of the HTTP request.

### 5. Create a transaction

When a customer successfully completes a checkout, it’s recorded as a new purchase attempt. This must be handled on your server-side to be fulfilled by our [Transaction API](https://docs.affirm.com/payments/reference/transaction-api-endpoints).

## What’s Next?

* [API Reference](https://docs.affirm.com/developers/reference/introduction)
* [Promotional Messaging and Prequalification](https://docs.affirm.com/developers/docs/about-promotional-messaging-and-prequalification)
* [Managing Split Capture Transactions](docs.affirm.com/developers/docs/split-capture-transactions)

# Sub pages

* [API Reference for Split Capture](https://docs.affirm.com/payments/docs/split-capture-api-reference.md)

# Sibling pages

* [About Direct API](https://docs.affirm.com/payments/docs/direct-api-overview.md)
* [Set Up Direct API](https://docs.affirm.com/payments/docs/transactions-web.md)
* [Inline Integration Overview](https://docs.affirm.com/payments/docs/inline-integration.md)
* [About Split Capture](https://docs.affirm.com/payments/docs/split-capture.md)