H2H Notifications
Host-to-Host API provides real-time payment status notifications through webhooks, enabling automatic updates when payment statuses change. This guide covers webhook setup, handling, and security best practices.Webhook Overview
Notification System
- Real-time Updates: Automatic payment status notifications via webhooks
- HTTP POST: Notifications sent as HTTP POST requests
- Content Type:
application/x-www-form-urlencoded
- Requirement: Notifications only sent if notify URL is configured
Configuration
- Dashboard Setup: Set notify URL in dashboard profile page
- Per-Request Override: Override notify URL in individual payment requests
- Multiple Endpoints: Configure different URLs for different notification types
Notification Fields
Field | Description |
---|---|
id | Payment request identifier |
transactionId | Payment request transaction identifier |
transactionStatusId | Transaction status: 1 – approved, 2 – declined |
paymentRequestStatusId | Payment status: 1 – paid, 2 – unpaid |
merchantId | Merchant identifier (from control panel) |
unit | Payment currency |
grossAmount | Payment gross amount including fees |
fee | Payment fee amount |
netAmount | Net amount deposited to merchant wallet |
referenceId | Custom reference details |
notes | Payment notes |
clientId | Payment sender customer identifier |
clientName | Payment sender customer name |
clientEmail | Payment sender customer email |
clientPhone | Payment sender customer phone |
clientMemberId | Payment sender customer member identifier |
message | Payment failure reason message |
code | Payment failure reason code |
Example Notification
Webhook Handler Implementation
Basic Webhook Handler
Advanced Webhook Handler
Notification Verification
Signature Verification
Verify notification authenticity using HMAC SHA512 signature:Verification Process
- Header Check: Check
X-Signature
header in notification request - Algorithm: HMAC SHA512 hash in Base64 format
- Key: Use your API key from the control panel
Status Processing
Payment Status Mapping
Business Logic Processing
Error Handling
Duplicate Prevention
Retry Logic
Security Best Practices
Webhook Security
- Signature Verification: Always verify webhook signatures
- HTTPS Only: Use HTTPS endpoints for webhook URLs
- IP Whitelisting: Restrict webhook sources to known IPs
- Rate Limiting: Implement rate limiting on webhook endpoints
Data Protection
- Sensitive Data: Never log sensitive payment information
- PCI Compliance: Follow PCI DSS guidelines for payment data
- Access Control: Restrict access to webhook processing systems
- Audit Logging: Maintain audit logs of all webhook processing
Error Handling
- Graceful Failures: Handle errors gracefully without exposing system details
- Monitoring: Monitor webhook processing success rates
- Alerting: Set up alerts for webhook processing failures
- Backup Processing: Implement backup processing for failed webhooks
Testing and Validation
Webhook Testing
Best Practices
Implementation
- Idempotency: Handle duplicate notifications gracefully
- Fast Response: Respond quickly to webhook requests (< 30 seconds)
- Async Processing: Process notifications asynchronously when possible
- Status Codes: Return appropriate HTTP status codes
Monitoring
- Success Rates: Monitor webhook processing success rates
- Response Times: Track webhook processing response times
- Error Patterns: Analyze error patterns and common failures
- Alert Thresholds: Set up appropriate alerting thresholds
Reliability
- Retry Mechanisms: Implement retry logic for failed processing
- Dead Letter Queue: Use dead letter queues for failed notifications
- Backup Processing: Implement backup processing mechanisms
- Health Checks: Regular health checks on webhook endpoints
Next Steps
Request Structure
Learn about H2H API request format and parameters
Response Structure
Understand H2H API response handling
Payment Methods
Explore available payment methods and implementations