---
updatedAt: 2025-11-13T14:11:07.000Z
agentTools:
  siteIndex: https://docs.affirm.com/llms.txt
  projectIndex: https://docs.affirm.com/platforms/llms.txt
---

# Upgrade your Magento 1 Integration

Learn about upgrading your Magento integration to get the most out of Affirm. Learn how to upgrade your Magento integration.

> 📘 Magento 1 sunset
>
> Effective June 30 2020, Adobe sunsetted support for Magento 1. This means Adobe will no longer release security patches for Magento 1. If you have questions, see [End of Software Support FAQ](https://info2.magento.com/rs/585-GGD-959/images/Implications_of_Unsupported_Software_FAQ_OS_Version_Sept_2019.pdf?mkt_tok=eyJpIjoiT1dGaU9EWTBZakF4TVRWaSIsInQiOiI2UW5ZRkltdGFvbzc2TVdDcEtMXC96TW5rUExBblFBVUR0SWFFamplYXdFR0QyT1lpbUsyREcyc3AxOFRFN2c1KysrQ1ppaXoxK281VVdaTUx3XC9yRmo4SnE5OEExQzlvdE1uNDRaSWVqdVlHTTM2cjJ0WGdUNnlNNFdVUjJjUmdaIn0%3D).
>
> For additional details, see[Magento 1](https://docs.affirm.com/platforms/docs/magento).

## Overview

Affirm now offers the following features using the new data-page-type attribute in the Affirm promotional messaging:

* New promotional messaging components that respond dynamically to your unique financing programs such as longer terms (18, 24 and 36-month repayment terms) and 0% APR promotions, with customizable messaging to personalize the consumer journey
* Our Prequalification flow within promotional messaging components to unlock purchasing power upfunnel while minimizing additional development work for your teams
* Our updated `Affirm.js` library, which includes Enhanced Analytics that provide consumer insights and enable A/B testing to keep your site optimized

This guide is for merchants using Magento who want to take advantage of the above features without upgrading their Magento extension (version 3.5.6 and up).

***

## 1. Connect to Affirm's Sandbox

Perform this upgrade in your development environment connected to our sandbox. To connect your development environment to our sandbox, do the following:

1\.  Get your sandbox public and private API keys at <https://sandbox.affirm.com/dashboard/#/apikeys>\
2\.  Sign in to your Magento admin portal\
3\.  Go to **System > Configuration > Sales > Payment Methods > Affirm**\
4\.  Keep **Mode** set to **Sandbox**\
5\.  Enter the **Public API Key** and **Secret Key (private key)** you retrieved from the Affirm sandbox merchant dashboard.

## 2. Add Affirm.js

Add the Affirm.js embed code to the head of your global page template by doing the following:

1. Open `MAGENTO_ROOT/app/design/frontend/base/default/layout/affirm/affirm.xml`
2. Add `Affirm.js` and the Affirm configuration initialization in the global header

```xml
<layout>
    <default>
        <reference name="head">
            <action method="addItem">
                <type>skin_js</type>
                <name>js/affirm/promos.js</name>
            </action>
            <block type="core/text" name="affirm.cdn.javascript">
                <action method="setText">
                    <text helper="affirm/getAffirmJs" />
                </action>
            </block>
        </reference>
    </default>
```

3\.  Open `MAGENTO_ROOT/app/code/community/Affirm/Affirm/Helper/Data.php`\
4\.  Add the following function

```php
/**
 * Get affirm js url
 *
 * @return string
 */
public function getAffirmJsUrl()
{
    $apiUrl = $this->getApiUrl();
    $parsedUrl = Mage::getModel('core/url')->parseUrl($apiUrl);
    $domain = $parsedUrl->getHost();
    $domain = str_ireplace('www.', '', $domain);
    $domain = str_ireplace('api.', '', $domain);
    $prefix = 'cdn1.';
    if (strpos($domain, 'sandbox') === 0) {
        $prefix = 'cdn1-';
    }
    return 'https://' . $prefix . '' . $domain . '/js/v2/affirm.js';
}
/**
 * Get affirm js text
 *
 * @return string
 */
public function getAffirmJs()
{
    $affirmJs = '<script type="text/javascript">
    if (!AFFIRM_AFFIRM.promos.getIsInitialized()) {
        AFFIRM_AFFIRM.promos.initialize("'.  $this->getApiKey() .'","'. $this->getAffirmJsUrl() .'");
    }
    if (!AFFIRM_AFFIRM.promos.getIsScriptLoaded()) {
        AFFIRM_AFFIRM.promos.loadScript();
    }
    </script>';
    return $affirmJs;
}
```

See the following GitHub links:

* [affirm.xml](https://github.com/Affirm/Magento_Affirm/blob/master/extension/app/design/frontend/base/default/layout/affirm/affirm.xml)
* [Data.php](https://github.com/Affirm/Magento_Affirm/blob/master/extension/app/code/community/Affirm/Affirm/Helper/Data.php)

## 3. Update Affirm Promotional Messaging

The Affirm promotional messaging HTML `data-page-type` attribute allows you to customize messaging in the future without development work. By default, promotional messaging on product pages have prequalification enabled, but you can work with your Client Success Manager to change this and [configure additional customizations](https://docs.affirm.com/payments/docs/customize-your-promotional-messaging).

Adding the `data-page-type` attribute depends on which version of extension you're using and if you've added any custom work to it. The best way to add the attribute is to search for and locate the Magento template files that use `affirm-as-low-as` and `affirm-product-modal` to display promotional messaging. Add the `data-page-type `attribute corresponding to the template file where that promotional messaging component is placed:

|                               |                                                                                                                                                                    |
| :---------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **data-page-type="category"** | `MAGENTO_ROOT/app/code/community/Affirm/Affirm/Block/Product/List.php`                                                                                             |
| **data-page-type="cart"**     | `MAGENTO_ROOT/app/design/frontend/base/default/template/affirm/promo/aslowas/checkout.phtml`                                                                       |
| **data-page-type="product"**  | `MAGENTO_ROOT/app/design/frontend/base/default/template/affirm/promo/aslowas/product.phtml`                                                                        |
| **data-page-type="banner"**   | [Magento\_Affirm - line 27](https://github.com/Affirm/Magento_Affirm/blob/master/extension/app/design/frontend/base/default/template/affirm/promo/promo.phtml#L27) |

Monthly payment messaging (affirm-as-low-as) usually display price-specific information (requires data-amount) and are typically used with the following data-page-types:

* category
* product
* cart
* payment

If you don't pass data-page-type, the component will use a default setting.

## 4. 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](https://docs.affirm.com/payments/docs/confirmation-page-analytics) to your payment confirmation page. We only require `orderId`, `total`, `productId`, and `quantity` for A/B testing.

1\.  Open `MAGENTO_ROOT/app/design/frontend/base/default/layout/affirm/affirm.xml`\
2\.  Add the following snippet at the bottom

```xml
<checkout_onepage_success> <!-- To add pixel for enhanced analytics -->
    <reference name="head" before="-">
        <block type="affirm/promo_pixel_confirm" name="affirm_pixel_javascript" template="affirm/promo/pixel/confirm.phtml"/>
    </reference>
</checkout_onepage_success>
<checkout_multishipping_success translate="label"> <!-- To add pixel for enhanced analytics -->
    <reference name="head" before="-">
        <block type="affirm/promo_pixel_confirm" name="affirm_pixel_javascript" template="affirm/promo/pixel/confirm.phtml"/>
    </reference>
</checkout_multishipping_success>
```

3\.  Add [https://github.com/Affirm/Magento\_Af.../confirm.phtml](https://github.com/Affirm/Magento_Affirm/blob/master/extension/app/design/frontend/base/default/template/affirm/promo/pixel/confirm.phtml) to your code

See the following GitHub links:

* [affirm.xml](https://github.com/Affirm/Magento_Affirm/blob/master/extension/app/design/frontend/base/default/layout/affirm/affirm.xml)
* [Commit notes](https://github.com/Affirm/Magento_Affirm/commit/548a92a1904f057c50ce2bf72ae5d44a2d516145)

## 5. Test and Set live

Test your upgrade development in our sandbox and make sure all of your Affirm promotional messaging components display as expected. Also be sure to keep a copy of your Magento store and database so you can revert to the previous version in case there are any issues. After testing, connect to our live site:

1\.  Sign in to your live merchant dashboard at <https://affirm.com/dashboard>\
2\.  Retrieve your public and private keys\
3\.  In the Magento admin panel, go to **System > Configuration > Sales > Payment Methods > Affirm**\
4\.  Set **Mode** to **Production**\
5\.  Enter the **Public API Key** and **Secret Key (private key)** you just retrieved from the Affirm merchant dashboard

After you've connected to our live environment, you're ready to deploy to your production environment.

# Sibling pages

* [How to Process Affirm Transactions in Magento 1](https://docs.affirm.com/platforms/docs/how-to-process-affirm-transactions-in-magento.md)
* [Upgrade the Magento 1 Extension](https://docs.affirm.com/platforms/docs/upgrade-the-magento-extension.md)
* [Upgrade the Telesales Add-On Module for Magento 1](https://docs.affirm.com/platforms/docs/upgrade-the-telesales-add-on-module-for-magento.md)
* [Magento 1 Telesales Integration](https://docs.affirm.com/platforms/docs/magento-telesales-integration.md)
* [Magento 1 Multiple Financing Programs](https://docs.affirm.com/platforms/docs/magento-multiple-financing-programs.md)
* [How does the Chrome SameSite Cookie Policy Impact Magento 1 Integrations?](https://docs.affirm.com/platforms/docs/how-does-the-chrome-samesite-cookie-policy-impact-my-magento-1-integration.md)