Clearpay JS - Redirect Method

by afterpay

HTML

<script src="https://portal.sandbox.clearpay.co.uk/afterpay.js" async></script>

JavaScript

window.addEventListener("load", function(){
	AfterPay.initialize({countryCode: "GB"});
	AfterPay.redirect({token: "A_TOKEN"});
})


// If you see the Clearpay logo with an error message, it's working!
// A_TOKEN is an invalid token, so the error page is expected behaviour; it indicates that the Clearpay JS has loaded correctly.