Skip to main content
Handle errors from the FunnelFox Payments Web SDK using structured error classes. Each error type provides specific information to help you debug issues and show the right message to your users.

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 from createCheckout() and the other methods to show appropriate feedback.
In JavaScript, check the error class with instanceof:

Error properties

Every SDK error has name, message, code, and details. Some classes add more:
  • APIError: statusCode, errorCode, errorType, requestId, response, declineCode, and declineCodeSource.
  • NetworkError: originalError, the underlying error.
  • PrimerError: primerError, the original Primer error.
  • CheckoutError: phase, the checkout phase that failed.
  • ValidationError: field and value, the invalid input.
For 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".
Where you receive them depends on the method:
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.
For Stripe card declines during 3DS, the SDK maps Stripe’s error code to the same uppercase format.
Learn how FunnelFox Payments uses declines for retries in Decline classification.

Initialization errors

When createCheckout() 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 calls onTaxError with an APIError or a NetworkError. Learn more about taxes in the Web SDK.