JavaScript Library

Loading the Library

The Afterpay.js script loads various Clearpay Messaging and Assets for merchants to utilize throughout their store. To load the Afterpay.js library add the following async script tag to the <head> section of your site.

<script src="https://js.afterpay.com/afterpay-1.x.js"
    async
></script>

Clearpay Simulator

To display the Instalment Messaging add the <afterpay-placement> tag to the product and cart HTML files. The messaging should be placed immediately below the price element on both product and cart pages.

To render Clearpay messaging with the correct language and calculated installment amount, provide the locale, currency, and amount attributes to the custom element.

<afterpay-placement 
    data-locale="fr_FR"
    data-currency="EUR" 
    data-amount="44.00"
 ></afterpay-placement>
<afterpay-placement 
    data-locale="es_ES"
    data-currency="EUR" 
    data-amount="44.00"              
        async
 ></afterpay-placement>
<afterpay-placement 
    data-locale="it_IT"
    data-currency="EUR" 
    data-amount="44.00"
        async
 ></afterpay-placement>
AttributeTypeDefault
data-localeString required
data-currencyString required
data-amountString required
data-show-upper-limitString"true"
data-show-lower-limitString"true"
data-badge-themeString"black-on-mint"

Setting a price range to show Clearpay (optional)

data-min and data-max define the minimum and maximum for the messaging. When a product or cart total is outside of this range, the messaging will read like so:

11741174

Often merchants want to restrict customers from using Clearpay on items that fall outside a specific price range. To configure the minimum an maximum threshold, add the following attribute to the Afterpay.js Script tag:
E.g)

<script
    src="https://js.sandbox.afterpay.com/afterpay-1.x.js"
    data-min="4.00"
    data-max="800.00"
></script>
AttributeTypeDefault
data-minString"4.00"
data-maxString"800.00"

Please note: The min and max values only affect the amounts used in the simulator.