Checkout Widget - Token-less Mode
HTML
<html>
<body>
<div id="afterpay-widget-container"></div>
<script>
// Ensure this function is defined before loading afterpay.js
function createAfterpayWidget() {
window.afterpayWidget = new AfterPay.Widgets.PaymentSchedule({
/*
For token-less mode, please ensure you remove the token parameter and instead define an initial amount property
*/
// token: "",
amount: { amount: "50", currency: "GBP" },
target: '#afterpay-widget-container',
locale: 'en-GB',
onReady: function (event) {
console.log(event)
window.afterpayWidget.update({
amount: {amount: "50.00", currency: "GBP"},
});
},
onChange: function (event) {
// Fires after each update and on any other state changes.
// See "Getting the widget's state" for more details.
console.log(event)
},
onError: function (event) {
// See "Handling widget errors" for more details.
console.log(event)
},
})
}
</script>
<script src="https://portal.afterpay.com/afterpay.js" async onload="createAfterpayWidget()">
</script>
</body>
</html>