Idempotency in Payment Processing
Understanding the usage of idempotent string
Idempotency in payment processing ensures that duplicate requests for the same transaction do not result in multiple charges, authorizations, or refunds. By using an idempotent string, merchants can prevent unintended duplicate transactions, improving user experience and reducing operational overhead.
How Idempotency Works
An idempotent string is a unique identifier included in the payment request to restrict duplicate actions. If a request with the same idempotent string is sent within 24 hours, the system returns the original response without initiating a new charge, authorization, or refund. This ensures consistency and prevents duplicate processing.
Example Implementation
Include the idempotent string in the reference object of the payment request (Authorize or Charges or Refunds). The idempotent string should be consistent for the same order to avoid duplicate charges.
"reference": {
"transaction": "txn_0001",
"order": "ord_001",
"idempotent": "txn_0001"
}
If the same request is sent again with the same idempotent string within 24 hours, the original response is returned, and no new charge/refund/authorize is created.
Key Features
- Validity: The idempotent string is valid for 24 hours.
- Consistency: Use the same idempotent string for retries or duplicate requests for the same order.
- Response Handling: If the original response is missing or the transaction URL is still valid, the same idempotent string retrieves the original response or redirects the customer to the same 3DS page.
Benefits
- Prevents Duplicate Charges: Ensures customers are not charged multiple times for the same order.
- Improves Success Rates: Reduces abandoned transactions caused by multiple payment attempts.
- Seamless User Experience: Allows customers to return to the same 3DS page if the transaction URL is still valid.
Merchant Use Cases
- E-commerce Checkout: A customer clicks the "Pay" button multiple times due to a slow response. Using the same idempotent string (e.g., the order number) ensures only one charge is processed, even if multiple requests are sent.
- 3DS Authentication:A customer is redirected to a 3DS authentication page but abandons the process. If they attempt to pay again within 30 mins (or within the expiry period of the respective transaction), the same idempotent string redirects them to the original 3DS page instead of initiating a new charge.
- Mobile App Payments: A mobile app user experiences network issues and retries the payment. The idempotent string ensures the retry does not create a new charge but returns the status of the original request.
- Subscription Renewals: During automated subscription renewals, transient network issues may trigger retry attempts. An idempotent string prevents duplicate charges for the same renewal cycle.
- Booking Platforms: A customer books a service (e.g., travel or event tickets) and retries due to a timeout. The idempotent string ensures only one booking is processed, avoiding duplicate reservations.
Implementation Guidelines
- Generate Unique Idempotent Strings: Use the order number or a unique transaction identifier as the idempotent string to maintain consistency.
- Handle Retries: If a customer retries a payment or is on the 3DS screen, send the same idempotent string to retrieve the original response or redirect to the valid 3DS page.
- Monitor Timeouts: Ensure the idempotent string is reused within the 24-hour validity period to avoid creating new transactions.
- Test Scenarios: Simulate duplicate clicks, network failures, or abandoned 3DS flows to verify idempotency behavior.
For detailed API documentation, visit: Tap Payments - Create a Charge
Updated 2 days ago