Clearpay Dynamic Messaging Widget
Availability
Clearpay Dynamic Messaging Widget is currently only available in the UK and in Afterpay Regions.
In order to use the dynamic messaging widget and all of its features you will require a “Public Key”. Public keys are not made available to all merchants. Should you have any questions please speak to your Clearpay account manager.
The Clearpay Dynamic Messaging widget allows you to display the standard Clearpay messaging together with Clearpay promo messaging during the shopping experience. The messaging can be shown on product pages, the cart, and the checkout pages.
Integrating dynamic messaging for the first time
- Add the following code snippet in the
<head>section of your product, cart, and checkout web pages:
- Initialise the widget by adding the following code into the
<body>of any page you wish to display Clearpay messaging. We recommend that on product pages the messaging is immediately below the price, on cart pages the messaging is below the subtotal, and on checkout pages, the messaging is within the Clearpay payment option.
- Add the following code into your web pages to configure the look and feel of the widget:
- Configure the widget to suit your implementation. Locale, currency, context, and render style should be adjusted as necessary. For more information, see configuring the dynamic widget.
Replacing an existing Clearpay messaging widget
To replace an existing Clearpay messaging widget with the dynamic widget, follow these steps:
- Add the following code to the
<head>element of your web pages:
- In your web page HTML, find and copy the
afterpay placementelement. It should look something like this:
- Open the dynamic widget migration helper and enter your public key, region, context, and paste the code snippet copied in the last step into the Current
<afterpay-placement>tag: section. - Copy the code in the New placement javascript field.
- Add the following code snippet to the
<head>section of your web page, and paste in the code copied in the previous step:
- Initialise the widget by adding the following code into the
<body>of any page you wish to display Clearpay messaging. We recommend that on product pages the messaging is immediately below the price, on cart pages the messaging is below the subtotal, and on checkout pages, the messaging is within the Clearpay payment option.
- Search for and delete the following code snippet:
- Search for and delete the
<afterpay-placement>tag and all code inside it. It will probably look similar to the following code snippet:
Configuring the dynamic messaging widget
There are a number of configuration options that can be adjusted .
Style configuration options
Font Faces
The fontFaces style allows you to define one or many custom font faces that you will reference in your fontFamily definition for the widget.
The following defines the attributes of each font face option.
Here is a full example of a font face definition.
Font Sources
A single font face can have a number of different sources. There are 2 kinds of font sources - a URL to a remote font, or a local font on a customer’s computer.Remote Font
Local Font
Amount selector
The amountSelectors attribute is available as an alternative to the amount attribute, which allows you to select the content of an HTML element to use as the amount. This element will also be watched for any changes and the widget will be updated automatically. Here is an example of using this attribute:
Amount mutation selector
The mutation attribute, allows you to watch for changes in content on an element that is not the amount element, to trigger an update of the amount present in your selected amount element. This is useful if product amount changes on your site trigger a reload of a parent element to the amount, meaning mutations on the amount itself will not be fired. Here is an example of this.
Target selector
The targetSelector attribute functions as an alternative to the target attribute and allows you to place the widget adjacent to an existing element using a CSS selector (a target HTML element to place the widget inside is not required). Here is an example of using this option:
Valid values for the placementPosition option are the same as the valid position values defined here.
All configuration attributes of the static Clearpay messaging widget are applicable to the dynamic messaging widget, and can be found here.
When using these attributes in the JavaScript snippet, they should be converted from snake case to camel case. For example payment-amount-is-bold would become paymentAmountIsBold, show-upper-limit would become showUpperLimit.
Testing Promotion Messaging
When implementing the messaging widget, you may wish to manually enable a promotion to see how this appears on your site. When using the Sandbox version of afterpay.js you can enable promotion messaging using one of the following “test” public keys in your configuration.
This public key only works when using the Sandbox version of afterpay.js - it will not work with the production version.
Example: