Documentation Index
Fetch the complete documentation index at: https://docs.cheqpay.mx/llms.txt
Use this file to discover all available pages before exploring further.
Error Format
Handle errors gracefully to provide the best customer experience. All errors include clear codes and messages. Errors follow a consistent structure:HTTP Status Codes
| Status Code | Meaning | Common Causes |
|---|---|---|
400 | Bad Request | Invalid parameters, validation errors |
401 | Unauthorized | Invalid or missing API key |
404 | Not Found | Resource doesn’t exist |
409 | Conflict | Duplicate resource, conflicting state |
422 | Unprocessable Entity | Payment declined, business logic error |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server error (rare) |
503 | Service Unavailable | Temporary service disruption |
Error Codes
Client Errors (400-499)
| Code | Status | Meaning | Action |
|---|---|---|---|
VALIDATION_ERROR | 400 | Invalid request parameters | Check and fix parameters |
UNAUTHORIZED | 401 | Invalid API key | Verify credentials |
NOT_FOUND | 404 | Resource not found | Check resource ID |
DUPLICATE | 409 | Resource already exists | Use existing resource |
DECLINED | 422 | Payment declined by bank | Try different card |
INSUFFICIENT_FUNDS | 422 | Customer has low balance | Contact customer |
EXPIRED_CARD | 422 | Card has expired | Request new card details |
INVALID_CARD | 422 | Invalid card number | Re-enter card information |
AUTHENTICATION_REQUIRED | 422 | 3DS authentication needed | Show 3DS challenge |
AUTHENTICATION_FAILED | 422 | 3DS verification failed | Allow customer to retry |
Server Errors (500-599)
| Code | Status | Meaning | Action |
|---|---|---|---|
INTERNAL_ERROR | 500 | System error | Retry request with backoff |
SERVICE_UNAVAILABLE | 503 | Temporary issue | Retry with exponential backoff |
Handle Declined Payments
Show customer-friendly messages when payments are declined:Declined Payment Response
Decline Reasons
| Decline Reason | Customer-Friendly Message |
|---|---|
insufficient_funds | ”Payment couldn’t be processed. Please try a different card.” |
invalid_card | ”Unable to process this card. Please check your card details.” |
expired_card | ”This card has expired. Please use a different card.” |
card_declined | ”Payment couldn’t be completed. Please try another payment method.” |
processing_error | ”We’re having trouble processing this payment. Please try again.” |
Best Practices
Use Generic Messages
Use Generic Messages
Don’t expose specific decline reasons to customers. Use friendly, generic messages that don’t embarrass them.✅ Good: “Payment couldn’t be processed. Please try a different card.”
❌ Bad: “Insufficient funds in your account.”
Suggest Alternatives
Suggest Alternatives
When a payment is declined, suggest trying:
- Another payment method
- A different card
- SPEI bank transfer (for large amounts)
Log Full Details
Log Full Details
Log the complete error response for your records, but show simplified messages to customers.
Allow Retries
Allow Retries
Let customers retry payments. Some declines are temporary (network issues, temporary holds).
Example: Handle Declined Payment
Retry Failed Requests
For temporary errors, implement retry logic with exponential backoff:Safe Retries with Idempotency
Thanks to idempotency, you can safely retry requests without creating duplicate charges:Validation Errors
Handle validation errors before submitting:Client-Side Validation
Validate data before sending to API:Handle Authentication Errors
Invalid API Key
- API key is correct
- Using the right environment (sandbox vs production)
- Authorization header format:
Bearer YOUR_API_KEY
Example
Handle 3DS Errors
Authentication Required
Authentication Failed
- Show friendly message: “We couldn’t verify your identity. Please try again.”
- Allow customer to retry
- Offer alternative payment method
3D Secure Guide
Learn how to implement 3DS authentication
Rate Limiting
If you exceed rate limits:Handle Rate Limits
Contact support@cheqpay.com if you consistently hit rate limits. We can increase your limits.
Network Errors
Handle network connectivity issues:Error Logging
Log errors for debugging and monitoring:Error Monitoring
Set up alerts for critical errors:Best Practices Summary
Use Customer-Friendly Messages
Use Customer-Friendly Messages
Show simple, non-technical error messages to customers. Log detailed errors for debugging.
Implement Retry Logic
Implement Retry Logic
Retry temporary failures with exponential backoff. Use idempotency to prevent duplicates.
Validate Client-Side
Validate Client-Side
Validate data before sending to API to provide instant feedback and reduce errors.
Log Everything
Log Everything
Log all errors with context for debugging. Never log sensitive data like card numbers.
Monitor Error Rates
Monitor Error Rates
Track error rates and set up alerts for unusual patterns or critical errors.
Provide Fallbacks
Provide Fallbacks
Offer alternative payment methods when primary method fails.
Next Steps
Testing Guide
Test error scenarios in sandbox
Best Practices
Follow recommended patterns
API Reference
View complete error reference
Contact Support
Get help with errors