Clearpay Buttongetting-started-clearpay-button

Error Handling

This topic describes the error handling function available for the Clearpay Button.

Property

The property is ClearpayButton.onError.

This property allows a custom function to be called that handles both client and server-side errors. When an error occurs, the Clearpay window closes and passes the message to the onError callback.

The onError hook returns event information that contains the following:

AttributeDescription
httpStatusCodeThe type of error. See HTTP response status codes
errorCodeA common error identifier.
errorIdThe unique id used to locate the error event.
messageThe reason for the error.
1clearpayButton.onError = function(event) {
2 const { errorCode, errorId, message, httpStatusCode } = event.data;
3 // handle errors
4 // send error logs to backend
5 console.table({ errorCode, errorId, message, httpStatusCode })
6};

Clearpay Button Error Codes

An error at this point in the checkout flow means the customer has clicked the Clearpay Button. Unfortunately something then occurs and an order token is not created for this transaction. The Clearpay window closes, and sends details to the onError callback. The error codes are in the table below:

errorCodehttpStatusCodeDescription
invalid_object422One or more required fields were missing or invalid.
checkout_amount_too_low412The create checkout amount is below the merchant’s minimum threshold.
checkout_amount_too_high412The create checkout amount is above the merchant’s maximum threshold.
auth_token_malformed412The auth_token was invalid.
too_many_requests429The customer has been rate limited.
Unauthorized401The ppaConfirmToke has expired.

Return to the Clearpay Button guide menu