Create a payment
Create a payment. Requires an Idempotency-Key header.
Header: Idempotency-Key: <unique value, e.g. a UUID> (max 255 characters, remembered for 24 hours).
Same key and same body: the original response is replayed with Idempotent-Replayed: true. Bodies are compared after canonicalizing, so key order and whitespace don't matter. Same key and a different body: 422. Same key while the first request is still processing: 409. A request that fails validation isn't remembered, so its key can be reused. Test data: cardLast4 0002 is always declined (status failed, still 201). bank_transfer payments start as pending.
Note: Retrying with the same Idempotency-Key and body replays the stored response (Idempotent-Replayed: true). A card ending 0002 is always declined.
Parameters 2
| Name | Type | Description |
|---|---|---|
processingSeconds | query · integer (int32) | Hold the request open for this many seconds (max 5) so a duplicate can be sent while it is in flight. Default: 0. |
Idempotency-Keyrequired | header · string | Unique key per logical payment. Same key + same body replays the stored response; a different body returns 422. |
Request body
Optional. application/json, text/json, application/*+json, application/xml, text/xml, application/*+xml. userId, orderId (optional), amount (greater than 0, max 1,000,000), currency (3-letter code), method (card, upi, paypal or bank_transfer), description, cardLast4 (4 digits, required for card).
{
"userId": 101,
"amount": 49.99,
"currency": "usd",
"method": "card",
"cardLast4": "4242",
"description": "Order #1001"
}Responses
- 200
- OK
- 201
- Payment created, or the original response replayed.
- 400
- Idempotency-Key missing or too long, or the body is invalid.
- 409
- A request with the same key is still being processed.
- 422
- The key was already used with a different body.
Example
curl -X POST "https://api.testingapis.com/api/Payments" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: {{uuid}}" \
-d '{"userId": 101, "amount": 49.99, "currency": "usd", "method": "card", "cardLast4": "4242", "description": "Order #1001"}' \
-H "X-TestingApis-Key: YOUR_API_KEY"{
"message": "Payment created successfully",
"idempotencyKey": "cda26651-04d6-4941-8323-2fcaffd05efa",
"data": {
"id": 14,
"userId": 101,
"orderId": null,
"amount": 49.99,
"currency": "USD",
"method": "card",
"status": "succeeded",
"description": "Order #1001",
"cardLast4": "4242",
"createdAt": "2026-09-30T18:26:45Z",
… (3 more lines)Sign in to see the details
The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.