JavaScript Library (Legacy)

How can I easily add Afterpay Messaging to my site?

📘

NOTE: Upgrade to our new JavaScript Library

Merchants integrating after August 1, 2020 should visit our new JavaScript Library for the latest version.

Afterpay has a javascript widget that allows you to easily display installment amounts throughout the checkout flow.

The Javascript can be added in a few lines of code and customized to match the look and feel of your website.


Loading the Afterpay Widget

This below code should be placed just before the closing </head> tag

<script type="text/javascript" src="https://static-us.afterpay.com/javascript/present-afterpay.js"></script>

Required Fields

The Afterpay Messaging Widget is constructed by passing a configuration object into the presentAfterpay class.
The following object properties are required to construct presentAfterpay

Property

Type

Description

priceSelector

string

The HTML element the Afterpay Messaging should be positioned below.

locale

string

The language of the Afterpay Messaging / Afterpay Modal content - based on region

To initialize the the Widget, call the method .init()


What’s Next
Did this page help you?