Standard Response Structure
All successful requests return a consistent response format:Field | Type | Description |
---|---|---|
id | string | Unique transaction identifier (UUID) |
operation_type | string | "payment" or "withdrawal" |
status | string | Current transaction status |
amount | decimal | Transaction amount |
currency | string | Currency code (e.g., "MXN" , "USD" ) |
client_reference | string | Your reference identifier |
created_at | string | ISO 8601 timestamp of creation |
status_code | integer | HTTP status code |
Transaction Status Values
Thestatus
field can have the following values:
Status | Label | Description | Next Steps |
---|---|---|---|
pending | Pending | Transaction awaiting completion | Check status or wait for webhook |
on_hold | On hold | Transaction temporarily held | Wait for review completion |
processing | Processing | Transaction being processed | Monitor for completion |
sent_to_provider | Sent to provider | Sent to payment provider | Monitor for completion |
success | Success | Transaction successfully completed | Transaction complete |
paid_full | Paid in full | Payment completed in full | Transaction complete |
in_transit | In transit | Payment in transit to destination | Monitor for completion |
canceled | Canceled | Transaction was cancelled | No further action required |
declined | Declined | Payment declined by provider or issuer | Try different payment method |
rejected | Rejected | Transaction was rejected | Try different payment method |
failed | Failed | Transaction processing failed | Check error details and retry |
Unknown | Unknown | Status cannot be determined | Contact support for clarification |
expired | Expired | Transaction or authorization expired | Create new transaction if needed |
authorized | Authorized | Payment authorized (cards only) | Transaction complete |
Payment Response Examples
Here are some examples of payment responses.Card Payment Response
Card Payment Response
SPEI Payment Response
SPEI Payment Response
SPEI Withdrawal Response
SPEI Withdrawal Response
Debit Card Withdrawal Response
Debit Card Withdrawal Response
Next Action Handling
Some transactions require additional steps (3D Secure, redirects, iframe interactions). Thenext_action
object will contain specific instructions for handling these scenarios.
Here are some examples of responses that require additional action.
Redirect to URL (3DS Authentication)
Redirect to URL (3DS Authentication)
For card payments requiring 3D Secure authentication:Implementation Steps:
- Redirect customer to the provided
url
- Customer completes 3DS authentication
- Customer is redirected back to your
return_url
- Check transaction status using the
verify_transaction_status_url
Iframe Resources (MercadoPago)
Iframe Resources (MercadoPago)
For providers requiring iframe-based authentication:
Payment Instructions Response
For cash payment methods (OXXO, SafetyPay), the response includes detailed payment instructions:Payment Instructions Fields
The following table lists the fields that are included in thepayment_instructions
object.
Field | Type | Description |
---|---|---|
reference_code | string | Payment reference for cash payment |
barcode | string | Barcode representation |
store_name | string | Store chain name (e.g., “OXXO”) |
expiration_date | string | Payment expiration timestamp |
instructions | array | Step-by-step payment instructions |
voucher_pdf | string | URL to downloadable payment voucher |
HTTP Status Codes
The following tables lists the HTTP status codes that are returned by the API.Success Codes
Code | Description | When Used |
---|---|---|
200 | OK | Status check successful |
201 | Created | Transaction created successfully |
202 | Accepted | Transaction accepted, requires additional action |
Client Error Codes
Code | Description | Action Required |
---|---|---|
400 | Bad Request | Fix request format |
401 | Unauthorized | Check authentication |
402 | Payment Required | Payment declined |
404 | Not Found | Check transaction ID |
422 | Validation Error | Fix request data |
429 | Rate Limited | Retry with backoff |
Server Error Codes
Code | Description | Action Required |
---|---|---|
500 | Internal Server Error | Retry request |
502 | Bad Gateway | Retry request |
503 | Service Unavailable | Retry later |
Response Headers
All responses include standard headers for debugging and rate limiting:Header | Description |
---|---|
X-Request-ID | Unique request identifier for debugging |
X-RateLimit-Limit | Request limit per window |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Unix timestamp when limit resets |
Error Response Format
When requests fail, errors follow a consistent format:Field | Type | Description |
---|---|---|
error.code | string | Specific error code |
error.message | string | Human-readable error message |
error.type | string | Error category |
error.details | object | Additional error context |
request_id | string | Request identifier for support |
Implementation Examples
Here are some examples of how to handle responses in different programming languages.Best Practices
Make sure to follow these best practices to handle responses properly.Response Processing
Response Processing
- Always check status code - Don’t assume success based on HTTP 200
- Handle next actions - Process 3DS and iframe requirements properly
- Store transaction IDs - Keep references for status checking
- Process payment instructions - Display cash payment details to customers
Error Handling
Error Handling
- Use error codes - Don’t rely on error messages for logic
- Log request IDs - Include in support requests
- Implement retries - For server errors (5xx status codes)
- Validate responses - Check for required fields before processing
Status Management
Status Management
- Monitor pending transactions - Use webhooks or periodic status checks
- Handle status changes - Update UI based on current status
- Set timeouts - Don’t wait indefinitely for completion
- Notify customers - Keep users informed of transaction progress
Next Steps
- Learn about Status Checking for monitoring transactions
- Set up Webhooks for real-time status updates
- Review Error Handling for comprehensive error management
- Check Payment Methods for method-specific responses