Error Response Format
All errors follow a consistent structure:HTTP Status Codes
| Status | Description |
|---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
404 | Not Found - Resource doesn’t exist |
409 | Conflict - Duplicate or conflicting resource |
422 | Unprocessable Entity - Payment declined or business logic error |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Server error (rare) |
503 | Service Unavailable - Temporary disruption |
Client Errors (400-499)
Validation Errors
VALIDATION_ERROR
Status: 400Meaning: Invalid request parameters
- Missing required fields
- Invalid data types
- Out of range values
- Invalid format (email, phone, etc.)
- Review request parameters
- Check data types and formats
- Ensure all required fields are included
Authentication Errors
UNAUTHORIZED
Status: 401Meaning: Invalid or missing API key
- Missing Authorization header
- Invalid API key
- Wrong environment (sandbox key in production)
- Incorrect header format
- Verify API key is correct
- Check Authorization header:
Bearer YOUR_API_KEY - Ensure using correct environment credentials
Resource Errors
NOT_FOUND
Status: 404Meaning: Resource not found
- Invalid resource ID
- Resource doesn’t exist
- Wrong ID format
- Verify the resource ID
- Check if resource was deleted
- Use the correct ID (Cheqpay ID or external ID)
DUPLICATE
Status: 409Meaning: Resource already exists
- Duplicate
externalId - Resource already created
- Use the existing resource
- Create resource with different ID
- Check if idempotency is working as expected
Payment Errors
DECLINED
Status: 422Meaning: Payment declined by issuing bank
| Reason | Description | Customer Message |
|---|---|---|
insufficient_funds | Low balance | ”Payment couldn’t be processed. Please try a different card.” |
invalid_card | Invalid card number | ”Unable to process this card. Please check your details.” |
expired_card | Card expired | ”This card has expired. Please use a different card.” |
card_declined | Generic decline | ”Payment couldn’t be completed. Please try another method.” |
processing_error | Temporary error | ”We’re having trouble processing. Please try again.” |
- Show customer-friendly error message
- Suggest trying different payment method
- Allow customer to retry
- Consider offering SPEI as alternative
INSUFFICIENT_FUNDS
Status: 422Meaning: Customer has insufficient funds
- Suggest trying different card
- Offer alternative payment methods
- Suggest lower amount if applicable
EXPIRED_CARD
Status: 422Meaning: Card has expired
- Request updated card information
- Suggest using different card
- Offer to update saved card
INVALID_CARD
Status: 422Meaning: Invalid card number
- Ask customer to re-enter card details
- Validate card number client-side
- Check for typos
INVALID_CVC
Status: 422Meaning: Invalid or incorrect CVC
- Ask customer to re-enter CVC
- Show CVC location on card
- Verify correct CVC length (3-4 digits)
3D Secure Errors
AUTHENTICATION_REQUIRED
Status: 422Meaning: 3D Secure authentication is required
- Display 3DS authentication challenge
- Follow 3DS implementation guide
3D Secure Guide
Learn how to handle 3DS authentication
AUTHENTICATION_FAILED
Status: 422Meaning: Customer failed 3D Secure verification
- Show friendly message: “We couldn’t verify your identity”
- Allow customer to retry
- Offer alternative payment method
AUTHENTICATION_TIMEOUT
Status: 422Meaning: 3DS authentication session expired
- Start new payment request
- Inform customer of timeout
- Provide retry option
Rate Limiting
RATE_LIMIT_EXCEEDED
Status: 429Meaning: Too many requests
- Wait for
retryAfterseconds - Implement exponential backoff
- Reduce request frequency
- Contact support for higher limits
Refund Errors
NOT_REFUNDABLE
Status: 422Meaning: Payment cannot be refunded
- Payment not completed
- Payment already fully refunded
- Payment too old
- Check payment status
- Verify refund eligibility
- Contact support for special cases
INVALID_REFUND_AMOUNT
Status: 422Meaning: Refund amount exceeds available balance
- Check remaining refundable amount
- Issue partial refund for available amount
- Verify refund history
Server Errors (500-599)
INTERNAL_ERROR
Status: 500Meaning: Internal server error
- Retry request with exponential backoff
- Contact support if persistent
- Check API status page
SERVICE_UNAVAILABLE
Status: 503Meaning: Temporary service disruption
- Wait and retry after specified time
- Implement exponential backoff
- Check status page for incidents
Error Handling Best Practices
1. Show User-Friendly Messages
2. Implement Retry Logic
3. Log Errors Appropriately
4. Handle Specific Error Types
Complete Error Reference
| Code | Status | Category | Action |
|---|---|---|---|
VALIDATION_ERROR | 400 | Client | Fix parameters |
UNAUTHORIZED | 401 | Auth | Check API key |
NOT_FOUND | 404 | Resource | Verify ID |
DUPLICATE | 409 | Resource | Use existing |
DECLINED | 422 | Payment | Try different card |
INSUFFICIENT_FUNDS | 422 | Payment | Try different card |
EXPIRED_CARD | 422 | Payment | Update card |
INVALID_CARD | 422 | Payment | Re-enter card |
INVALID_CVC | 422 | Payment | Re-enter CVC |
AUTHENTICATION_REQUIRED | 422 | 3DS | Show challenge |
AUTHENTICATION_FAILED | 422 | 3DS | Allow retry |
AUTHENTICATION_TIMEOUT | 422 | 3DS | Start new payment |
RATE_LIMIT_EXCEEDED | 429 | Rate Limit | Wait and retry |
NOT_REFUNDABLE | 422 | Refund | Check status |
INVALID_AMOUNT | 422 | Refund | Check amount |
INTERNAL_ERROR | 500 | Server | Retry with backoff |
SERVICE_UNAVAILABLE | 503 | Server | Retry after delay |