Skip to main content

HTTP Error Responses

All API errors return a JSON response with an error message.

Status Codes


SDK Errors

These errors are thrown by the client-side SDK service during payment execution.

CubePayClosedError

Thrown when the user closes the payment modal without completing the transaction. This is not a failure — it indicates the user chose to cancel.

Initialization Errors

Session Creation Errors


Webhook Error Handling

Your webhook endpoint should always return 200 regardless of internal processing status:
Returning a non-2xx status causes the payment service to retry webhook delivery. Always return 200 to prevent duplicate processing.

Debugging Tips

The SDK logs initialization steps and errors to the browser console. Open DevTools and filter for “CubePay” or “cubepay” messages.
Missing or incorrect environment variables are the most common cause of SDK failures. Double-check that NEXT_PUBLIC_CUBEPAY_MERCHANT_ID is set on the client and CUBEPAY_API_KEY is set on the server.
When CUBEPAY_API_KEY is absent and NODE_ENV is not production, the SDK returns mock data. This is useful for isolating whether an issue is in your code or the API integration.
Use the browser Network tab to inspect requests to /api/payment-sessions. Check that the request body is valid JSON and the response contains paymentSessionId and paymentSessionToken.