Error classes
All of them extend
FunnefoxSDKError, which adds code and details to
Error. Each error’s name matches its class name.
A missing organization ID throws a plain
Error: “orgId is required. Pass it
to createCheckout() or call configure() first.” The SDK also exports
ConfigurationError, which no method currently throws.Handle errors
Catch errors fromcreateCheckout() and the other methods to show
appropriate feedback.
- JavaScript
- TypeScript
In JavaScript, check the error class with
instanceof:Error properties
Every SDK error hasname, message, code, and details. Some classes
add more:
APIError:statusCode,errorCode,errorType,requestId,response,declineCode, anddeclineCodeSource.NetworkError:originalError, the underlying error.PrimerError:primerError, the original Primer error.CheckoutError:phase, the checkout phase that failed.ValidationError:fieldandvalue, the invalid input.
APIError, code is the error code from FunnelFox Payments when one is
present, such as double_purchase when the customer already owns the
product. Otherwise, code is one of the ERROR_CODES constants:
API_ERROR, NETWORK_ERROR, PRIMER_ERROR, CHECKOUT_ERROR,
VALIDATION_ERROR, or SDK_ERROR.
Decline codes
When a payment provider declines a payment, FunnelFox Payments reports a decline code. Use it to tell an insufficient-funds decline apart from other failures, for example to offer a different payment method.declineCode: The decline code in uppercase, for example"INSUFFICIENT_FUNDS". Empty when the provider reports none.declineCodeSource: The provider that reported it:"primer","stripe", or"adyen".
onPaymentFail and purchase-failure pass a plain Error with
declineCode and declineCodeSource (the PaymentFailure type), not an
APIError. Read the fields directly instead of checking the class.Initialization errors
WhencreateCheckout() can’t initialize, the SDK replaces the container’s
content with this message:
The payment form didn’t load correctly. Please refresh the page to try again. If the problem persists, please contact support.The message also shows the request ID when one is available. Style it with the
.ff-sdk-error-container class. Share the request ID with support to
speed up troubleshooting.
Tax errors
When a tax recalculation fails, the SDK callsonTaxError with an APIError
or a NetworkError. Learn more about
taxes in the Web SDK.