Redirect Method
The Redirect Method is the standard method used by most merchants. This method redirects the consumer away from the merchant’s website to Clearpay to complete their payment. At the end of the process, the consumer will be redirected back to the merchant’s website.
- If the Consumer clicks “confirm”, they will be redirected to the
redirectConfirmUrl
, with theorderToken
and astatus
of “SUCCESS” appended as HTTP query parameters. - If the Consumer cancels, they will be redirected to the
redirectCancelUrl
, with theorderToken
and astatus
of “CANCELLED” appended as HTTP query parameters.
Note
The Merchant defines the redirectConfirmUrl
and redirectCancelUrl
for each order in their Create Checkout call.
To implement the Redirect Method, the following two JavaScript functions must be called, in order:
AfterPay.initialize
- This prepares the Clearpay JavaScript to initiate the Clearpay screenflow in the appropriate geographical region. This function accepts one required argument: an object with a requiredcountryCode
property. This property must contain the two-character ISO 3166-1 country code of the Merchant account.AfterPay.redirect
- This redirects the consumer’s browser from the merchant’s website to Clearpay. This function accepts one required argument: an object with a requiredtoken
property. This property must contain the checkout token returned by Create Checkout.
Tip
Try using your Sandbox Merchant credentials to obtain a token from Create Checkout, then use the token to test the Clearpay screenflow on JSFiddle:
https://jsfiddle.net/afterpay/we9xfqgm/
Note that since JSFiddle loads the Clearpay screenflow inside a frameset, the login and redirect features will not be operational.