Using Affirm.js as a dynamically loaded javascript library

Using Affirm.js on SFCC

SFCC has required AppExchange partners to remove any dynamically loaded Javascript files from content delivery networks (CDNs). As such, Affirm.js, which is a browser-side Javascript library served via CDN is replaced by a static copy. To prevent Affirm.js from going out of date and ensure that Affirm.js receives critical updates, we recommend our merchants use the CDN route to embed the script into the storefront pages by following the instructions below:

  1. Go to cartridges/int_affirm/cartridge/templates/resources/affirm.properties (or other locale resources file such as affirm_fr_CA where applicable) and fill in the following empty fields with the URLs for corresponding environments:

    Before:
    affirm.production.js=
    …
    affirm.sandbox.js=
    
    After: 
    affirm.production.js=https://cdn1.affirm.com/js/v2/affirm.js
    …
    affirm.sandbox.js=https://sandbox.affirm.com/js/v2/affirm.js
    
  2. Once this change has been made and properly uploaded to your SFCC server instance, go to: Business Manager > Merchant Tools > Custom Preferences > AFFIRM_PAYMENT > Affirm Static JS and set the value to “No”. This configuration will allow the storefront to use the Affirm.js library as a remote resource which gets imported via CDN and ensures that your storefront has an up to date version of the library.

Please reach out to Developer Support if you have any further questions regarding this step.