---
updatedAt: 2025-11-26T19:58:06.000Z
agentTools:
  siteIndex: https://docs.affirm.com/llms.txt
  projectIndex: https://docs.affirm.com/platforms/llms.txt
---

# Configuring Affirm

Learn how to configure and add Affirm as a payment option on Shopify.

> 🚧 Affirm promotional messaging
>
> Make sure you've set up [Affirm promotional messaging](https://docs.affirm.com/platforms/docs/using-the-promotional-messaging-app) before moving forward.

## Install Affirm

1. Sign in to your Shopify account and go to **Settings > Payments**.

<Image align="center" alt={2422} border={false} width="smart" src="https://files.readme.io/9e30773-Shopify_settings_payments.png" title="Shopify_settings_payments.png" />

2. In the **Alternative Payments** section, click the **Choose alternative payment** button.

<Image align="center" alt={776} border={false} width="smart" src="https://files.readme.io/7b3f6f0-Shopify_payment_providers.png" title="Shopify_payment_providers.png" />

3. On the **Alternative payment providers** page, select **Affirm**.

<Image align="center" alt={2038} border={false} width="smart" src="https://files.readme.io/99f19c8-alt_payment_providers.png" title="alt_payment_providers.png" />

4. Check the **Use test mode** checkbox for testing in our sandbox.
5. Enter the `public_api_key` and `private_api_key` you retrieved from your <Anchor label="Affirm merchant dashboard" title="https://affirm.com/dashboard/#/apikeys" href="https://affirm.com/dashboard/#/apikeys">Affirm merchant dashboard</Anchor>
6. Click **Activate**. Affirm is now a payment option in Shopify.

<Image align="center" alt={1256} border={false} width="smart" src="https://files.readme.io/e187109-Affirm_payment_method.png" title="Affirm_payment_method.png" />

3. Add the Confirmation Page function

***

When a customer completes their purchase, you can send their order and product information to Affirm for A/B testing, which will help you optimize your site. Send this information by adding the Confirmation Page function to your payment confirmation page. We only require orderId, total, productId, and quantity for A/B testing.

[Click here for all the Confirmation Page function parameters](https://docs.affirm.com/platforms/docs/confirmation-page-analytics).

To add the confirmation page function, go to  **Settings > Checkout > Order Processing > Additional scripts** and add the code below.  Replace `public_api_key` with your public API key found in the merchant dashboard.

```javascript
<script>
_affirm_config = {
   public_api_key:  "YOUR_PUBLIC_KEY",
   script:          "https://cdn1.affirm.com/js/v2/affirm.js"
};
(function(l,g,m,e,a,f,b){var d,c=l[m]||{},h=document.createElement(f),n=document.getElementsByTagName(f)[0],k=function(a,b,c){return function(){a[b]._.push([c,arguments])}};c[e]=k(c,e,"set");d=c[e];c[a]={};c[a]._=[];d._=[];c[a][b]=k(c,a,b);a=0;for(b="set add save post open empty reset on off trigger ready setProduct".split(" ");a<b.length;a++)d[b[a]]=k(c,e,b[a]);a=0;for(b=["get","token","url","items"];a<b.length;a++)d[b[a]]=function(){};h.async=!0;h.src=g[f];n.parentNode.insertBefore(h,n);delete g[f];d(g);l[m]=c})(window,_affirm_config,"affirm","checkout","ui","script","ready");
 
affirm.ui.ready(function(){
affirm.analytics.trackOrderConfirmed({
    "orderId": "{{ order.id }}",
    "total": "{{ order.total_price }}"
}, [{
   {% for item in order.line_items %}
   "productId": "{{ item.sku }}",
   "quantity": "{{ item.quantity }}",
   {% endfor %}
}]);
});
</script>
```

### Required function parameters

#### Order object

<Table align={["left"]}>
  <thead>
    <tr>
      <th>
        Attributes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        * **paymentMethod** `string`
          The payment method chosen by the customer (e.g., Visa). Maximum 150 characters.
      </td>
    </tr>

    <tr>
      <td>
        * **orderId** `string`  
          Your internal unique identifier representing the order. Maximum 500 characters.
      </td>
    </tr>

    <tr>
      <td>
        * **total** `string`  
          The total amount of the transaction, including tax and shipping, stated in USD cents (e.g., $100 = 10000).
      </td>
    </tr>
  </tbody>
</Table>

#### Product object

<Table align={["left"]}>
  <thead>
    <tr>
      <th>
        Attributes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        * **productId** `string`
          Your internal unique identifier representing the product, such as the SKU or an internal database identifier. Maximum 500 characters.
      </td>
    </tr>

    <tr>
      <td>
        * **quantity** `string`  
          The quantity of the purchased product.
      </td>
    </tr>
  </tbody>
</Table>