Paper Checkout
Search…
PaperSDKError
1
export type PaperSDKError {
2
code: PaperSDKErrorCode;
3
error: Error;
4
}
5
​
6
export enum PaperSDKErrorCode {
7
InvalidProps = 'The props you passed in to this component are not valid.',
8
InvalidCard = 'The card information is invalid. Please double check that the Card, CVC, and Zip code are all correct.',
9
EmailNotVerified = 'The email was unable to be verified.',
10
NotEnoughSupply = 'There is not enough supply to claim.',
11
AddressNotAllowed = 'This address is not on the allowlist.',
12
NoActiveClaimPhase = 'There is no active claim phase at the moment.',
13
}
14
​
Copied!
The PaperSDKError object has a code enum field which provides a user-facing error message. You can choose to directly show the user this message or check for these error codes and provide your own logic (e.g. localized strings, redirect the user to another page). The object also contains an error field that passes along the full Javascript error that was encountered for debugging purposes.
Example of redirecting the buyer to another page when the sale has ended:
1
<PayWithCard
2
...
3
onError={(error: PaperSDKError) => {
4
switch (error) {
5
case NotEnoughSupply:
6
case NoActiveClaimPhase:
7
window.location.href = '/sale-ended';
8
break;
9
default:
10
setMessage(`Something went wrong! ${error}`);
11
}
12
}}
13
/>
Copied!
​
Copy link