Add the Clearpay Button
This topic shows you how to add the Clearpay Button to your page, and also how to change the appearance of the button.
Add the Clearpay Button
Follow the instructions below:
- Import the Clearpay.js script as a script tag:
Note
All regions load the same clearpay-button.js script url script tag above. The region attribute in the clearpay-button element is the differentiation - see below.
- Add the Clearpay Button element. To do this, insert the following HTML to initialize the
afterpay-buttonelement:
You will need your merchant public key, provided by Clearpay. Your public key is used solely to identify your account with Clearpay. The public key can safely be published in places like your JavaScript code, or in an Android or iPhone app. .
- Add the region setting. You must add a region setting to HTML
afterpay-buttonelement above. The code is:
UK = region="UK"
Set the Order Attributes
Assuming you have added the Clearpay Button by following the instructions above, your next task is to make sure the order attributes are available. Before a customer can checkout with Clearpay, Clearpay needs the following information:
-
Merchant Reference- This is your (the merchant’s) unique order id/reference that this payment corresponds to. We use it reconcile orders in the Clearpay merchant portal -
Amount- The total amount of the order to be charged to the customer. This includes any shipping and tax, minus any discounts. This is the maximum amount that you can charge to the virtual Visa card -
Currency- The currency in ISO 4217 format. The value provided must correspond to the currency of the Merchant account that makes the request -
Consumer details- The customer’s phone number, name, and email address -
Shipping details- The shipping name and shipping address -
Items- Information about the line items in the order
An example of the above attributes is in the JavaScript below:
The Buy Now flag (CTA Button)
This attribute shows the customer a Buy Now button at the end of the Clearpay checkout flow. When it is not set, the button displays Confirm.
Increase your conversion rates
Providing customer details allows new customers to speed through checkout with prepopulated name and address fields.
Object Types
Money Object
Item Object
This contains information about a line item in the order. The value given to the afterpayButton.items is a string. To pass line item details, provide an array of item objects using JSON.stringify. For example,
afterpayButton.items= JSON.stringify(itemsArray);
Consumer Object
Contact Object
Change the Appearance of the Clearpay Button (Optional)
To change the appearance of the button, see the Changing the Appearance topic.