This document describes how to install and configure the Magento 2 integration for Affirm. The extension only works with USD base dollar currency, and for shipping/billing country addresses within the US. There are three major functionalities offered with the Affirm extension:
- Affirm as payment method
- Affirm promotional messaging
- Order management
Install the Magento 2 extension
Install using Composer
1. In the Magento root directory, enter the following commands using command line:
composer config repositories.magento composer https://packagist.org/ composer require affirm/magento2 composer update php bin/magento setup:upgrade php bin/magento setup:di:compile
Note: To get the authentication keys for repo.magento.com, refer these instructions - Get your authentication keys.
2. Once done, clear your Magento 2 cache to ensure the default Magento 2 Affirm configuration options are set properly
Install using Command Line
1. Download the extension from here
2. Move the extension files to "Magento2_root/app/code/Astound/Affirm/" (You may need to create the Astound/Affirm directory)
3. In Magento2 root directory, run the following command to check if "Astound_Affirm" exists in "List of disabled modules":
php bin/magento module:status
4. In the Magento2 root directory, run the following commands:
php bin/magento module:enable Astound_Affirm php bin/magento setup:upgrade
5. Once done, clear your Magento 2 cache to ensure the default Magento 2 Affirm configuration options are set properly
Note: If you are upgrading the extension, follow the same installation steps. Latest extension will be retrieved from packagist.org. Installation using Composer is the preferred method of extension installation.
- Sign in to https://sandbox.affirm.com/dashboard
- Retrieve API keys
- Hover over the profile icon area at the lower-left of the page.
- Click the API Keys link that appears.
- Copy the public, private, and financial product keys.
- Hover over the profile icon area at the lower-left of the page.
Configure Affirm as a payment method
Once you've installed the Affirm extension, log in to your Magento 2 admin panel and browse to Stores > Configuration > Sales > Payment Methods > Affirm to open the Affirm configuration profile. Affirm can be enabled as a payment method by updating the following configurations:
- Enabled: By default, payment method is disabled. Once you get the configuration settings completely filled in, activate the payment method. The Action should be set to "Yes".
- Mode: By default, "Sandbox" mode is selected. In testing mode use "Sandbox option", in live mode use "Production".
- Public API Key: Your public API key, that you retrieved from the Affirm Merchant Dashboard.
- Private API Key: Your private API key, that you retrieved from the Affirm Merchant Dashboard.
- Payment Action: By default, "Authorize" action is selected. If you currently automatically capture, change it to "Authorize and Capture".
- Disable for backordered items: By default, "No" is selected. If you want to disable Affirm when a backordered item is in the cart, change the "Disable for backordered items" to "Yes".
- Minimum Order Total: Dollar amount, by default, "0.01" value is entered. Identifies minimum total price threshold for when Affirm is available as a payment option at the checkout.
- Maximum Order Total: Dollar amount, by default, "100000" value is entered. Identifies maximum total price threshold for when Affirm is available as a payment option at the checkout.
- Sort Order: Changes the order of displaying Affirm as a payment method during checkout. To change the order, enter a number in Sort Order greater than 0.
- Plain Text Appearance: By default, "No" option is selected. If you want to change the appearance of Affirm to display as text instead of a logo during checkout, change "Plain Text Appearance" to "Yes".
- Icon & Affirm Payment Method HTML: Affirm logo and sub-text displayed on the checkout page. By default, Affirm approved message is used.
- Enabled Checkout Button: By default, "No" option is selected. Determines if the button should be displayed on the shopping cart page. Affirm Button URL can be updated in the "Checkout Button Code".
- Checkout Flow Type: By default, "Redirect" option is selected. If you would like to use modal checkout flow, change it to "Modal".
If you have problems with the changes not showing up immediately
- Visit System > Cache Management
- Click Flush Magento Cache
- Log out and log back in to reset permissions
Monthly Payment Pricing (As-Low-As)
Affirm monthly payment pricing (as low as messaging) and modal on the product description pages and shopping cart page can be enabled by going to Stores > Configuration > General > Affirm Promos and updating the following configurations:
- Enable for Product PDP: By default, "No" option is selected. Determines if the "as low as" message should be displayed on the Catalog Product Pages.
- Enable for Category PLP: By default, "No" option is selected. Determines if the "as low as" message should be displayed on the Category Pages.
- Enable for Shopping Cart: By default, "No" option is selected. Determines if the "as low as" message should be displayed on the Shopping Cart Page.
- Affirm logo: By default, "Blue" option is selected. Color of the logo.
- Minimum amount for displaying the monthly payment pricing: By default, monthly payment pricing is displayed if the amount above $50. Setting 100 as the value here will display monthly payment pricing for products above $100.
- Default Affirm Promo ID: Optional Default Affirm Promo ID value (provided by the Affirm Client Success Team)
Note: For displaying "as low as" functionality, we are using the "Affirm/Block/Promotion/ProductPage/Aslowas" block and the "Affirm/view/frontend/templates/promotion/aslowasPDP.phtml" template. To include this block in a specific location on the PDP or cart, you will need to select the appropriate handle ("catalog_product_view.xml" by default for PDP in Magento) and "parent block or container", which will render the "as low as" block (using <referenceBlock name="parent_block_name"> structure or <referenceContainer name="test_content">), where "parent_block_name" - name "parent block" in layout.
If your website dynamically changes the product price based on size, color, or some other attribute, the tool allows for you to call the updateAffirmAsLowAs function. This function updates the monthly payment calculation whenever the price changes. See: Astound\Affirm\Block\Promotion\AslowasAbstract.php, Astound\Affirm\Block\Promotion\ProductPage\Aslowas.php, Astound\Affirm\Block\Pro motion\CartPage\Aslowas.php, Astound\Affirm\view\frontend\web\js\model\aslowas.js
Additional placement option for As-Low-As message on product page
Additional placement for PDP as-low-as can be selected from going to Stores > Configuration > General > Affirm Promos and updating the following configurations:
- PDP Placement options for As low as
- After Price (selected by default)
- Before Price
- End of Product Info
Affirm promotional banners across various pages on your site can be enabled by going to Stores > Configuration > General > Affirm Promos and by updating the following configurations:
- General Settings
- Affirm Promo Key: By default "W6WU7UK82RS34HDH" value is used.
- Enabled: By default, "No" option is selected. Determines if the promotional banners (images) should be displayed on specified pages.
- Home Page Settings, Catalog Category Page Settings, Catalog Product Page Settings, Checkout Cart Page Settings
- Display: By default, "No" option is selected. Determines if the promotional banner should be displayed on the specified page.
- Promo Size: Determines the size of the promotional banner. See Promotional Banners for a list of possible sizes.
- Promo Position: Determines the position of promotional banner.
Multiple Financing Programs
Multiple Financing Programs (MFPs) allows you to selectively offer a specific custom financing program to consumers based on product or cart attributes that are defined in Magento 2. MFP setup is optional and the values are provided by Affirm, For more information please visit Magento 2 Multiple Financing Programs documentation.
Whenever an authorize, void, invoice or credit memo is applied to an order in Magento, the request is sent to Affirm to update order status in Affirm Merchant Dashboard. See Daily Operations for details.
Test your Affirm configuration
Test your configuration to ensure that everything is working before you go live. Email firstname.lastname@example.org with a link to your test site so that we can verify your configuration and provide you with production keys.
- Add an item to the cart on your test site.
- Proceed to checkout.
- During checkout, enter valid U.S. addresses and mobile-phone information. Affirm cannot test your configuration if the address or phone information is fake.
- Select Affirm as the payment option.
- Proceed to Affirm's testing environment checkout.
Note: The URL https://sandbox.affirm.com indicates that you are in the testing environment.
6. When prompted for your security PIN, enter 1234.
7. Select terms.
8. Confirm your loan.
9. Wait to ensure that you have been redirected to your confirmation page.
10. Verify that the transaction appears in your platform's admin panel and on sandbox.affirm.com/dashboard.
Note: When a customer completes checkout with Affirm as the payment method, Affirm authorizes a charge for the amount of the order. The charge appears in a pending state on the customer’s Affirm account. Authorized transactions expire if they are not captured before the capture deadline. The default capture deadline is specified in your partnership agreement with Affirm. If you did not specify your authorization-period requirements because of inventory, pre-orders, or shipping time in your onboarding form, please email email@example.com for help with completing this process.
Go live with Affirm financing
After you verify that your configuration is working properly in the Affirm Sandbox environment, your Affirm Client Success Manager will activate your Affirm Live environment access. This will allow you to sign into the Live version of the Merchant Dashboard, as well as access your Live API keys.
Retrieve Live API keys
- Go to the API keys page in the Affirm Dashboard.
- The work email address that you use to sign-in to the Affirm Dashboard must be granted access by your Dashboard's administrator, or your Affirm contact.
- Need help accessing the Affirm Dashboard?
- Retrieve your live API keys.
- Enter the live API keys into your integration/platform.
- Update Mode to Production in Stores > Configuration > Sales > Payment Methods > Affirm.