H2H Response Structure
Host-to-Host API responses provide essential information for tracking and completing payment processes. This guide covers response formats, status handling, and implementation patterns.Response Overview
The API returns a payment response containing essential information for tracking and completing the payment process.Response Structure
The payment response includes:- Payment Request Identifier: A unique identifier for the created payment request that can be used to pull payment request status
- Redirect URL: A URL to complete the payment if necessary (for payment methods requiring customer interaction)
Response Fields
Field | Description | Type |
---|---|---|
paymentRequestId | Created payment request identifier | string/integer |
redirectUrl | URL to complete payment (if required) | string |
status | Initial payment status | string |
Response Usage
1. Status Tracking
Use the payment request identifier to check payment status via status endpoints:2. Payment Completion
Redirect customers to the provided URL for payment methods requiring user interaction:3. Transaction Management
Store the identifier for future reference and reconciliation:Implementation Examples
Basic H2H Payment Processing
Multiple Provider Handling
Error Handling
Common Error Codes
- INVALID_API_KEY: API key is missing or invalid
- INSUFFICIENT_FUNDS: Customer’s account has insufficient funds
- CARD_DECLINED: Payment method was declined by issuer
- INVALID_CARD: Card number or details are invalid
- EXPIRED_CARD: Payment method has expired
- NETWORK_ERROR: Communication error with payment provider
Retry Logic
Status Management
Payment Status Types
- pending: Payment is being processed
- completed: Payment was successful
- failed: Payment failed
- cancelled: Payment was cancelled
- expired: Payment request expired
Status Polling
Response Validation
Validate Response Structure
Response Processing
Best Practices
Response Handling
- Immediate Validation: Validate response structure immediately
- Status Tracking: Always track payment status changes
- Error Logging: Log all errors for debugging and monitoring
- Timeout Handling: Implement appropriate timeout values
Performance
- Connection Pooling: Use HTTP connection pooling for better performance
- Async Processing: Handle responses asynchronously when possible
- Caching: Cache non-sensitive response data appropriately
- Monitoring: Monitor response times and success rates
Security
- Response Validation: Always validate response data
- Sensitive Data: Never log sensitive payment information
- Error Messages: Sanitize error messages before displaying to users
- Audit Trail: Maintain audit trail of all payment responses
Next Steps
Request Structure
Learn about H2H API request format and parameters
Notifications
Set up webhook notifications for real-time status updates
Payment Methods
Explore available payment methods and implementations