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 return200 regardless of internal processing status:
Debugging Tips
Check the browser console
Check the browser console
The SDK logs initialization steps and errors to the browser console. Open DevTools and filter for “CubePay” or “cubepay” messages.
Verify environment variables
Verify environment variables
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.Use development mode
Use development mode
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.Inspect network requests
Inspect network requests
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.