Idempotency ensures that retrying the same request multiple times has the same effect as making it once. This is crucial for preventing duplicate payments, refunds, and other operations in unreliable network conditions.Documentation Index
Fetch the complete documentation index at: https://docs.toffeepay.com/llms.txt
Use this file to discover all available pages before exploring further.
Idempotency-Key Header
ToffeePay supports idempotency for mutation operations (POST requests) using theIdempotency-Key header:
How It Works
- First Request: ToffeePay processes the request and stores the result with the idempotency key
- Duplicate Requests: If the same idempotency key is used again within 24 hours, ToffeePay returns the cached result instead of processing again
- Different Parameters: If the same key is used with different request parameters, ToffeePay returns an error
Supported Operations
Idempotency is supported for these operations:- Create Session - Prevents duplicate payment sessions
- Create Refund - Prevents duplicate refunds
Best Practices
Generate Unique Keys
Use UUIDs or other collision-resistant identifiers:Key Per Operation
Use a different idempotency key for each distinct operation:Error Handling
Idempotency Conflicts
If you use the same idempotency key with different parameters:Key Expiration
Idempotency keys expire after 24 hours. After expiration, the same key can be reused.Webhook Idempotency
For webhook processing, use thewebhook-id header to deduplicate events. See the Webhooks page for details.