Retry a payment request using idempotency
If you do not receive a response to a POST /payment-request call (for example, because of a timeout), resend the request with the original body and Idempotency-Key. The API recognises the request as a duplicate and returns the original response, rather than making a second payment.
Use your own metadata parameters (such as ExternalReference1) to track retries across your internal systems.
If you modify any fields in the request body, you must use a new
Idempotency-Keyso that the payment is treated as a new request. Reusing anIdempotency-Keywith a different payload results in a400 Bad Requesterror.
To avoid accidental double payments, ensure your system applies logic to detect and suppress unintended retries, especially in cases of intermittent failures.
Retry attempt using the same body and Idempotency-Key
cURL Example
curl -X POST https://api.vitessepsp.com/payment-request \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: b1f2f3a4-65db-46f7-b890-2d42e91f8c77" \
-d '{
"SendAccountId": "a14ff4d1-d91a-4b19-b94e-c302b7b43f3d",
"SendCurrency": "GBP",
"SendValue": 100.00,
"StoredRecipient": {
"StoredRecipientId": "5ac2e92a-1c2b-4d53-9e6b-67bb0e02fc9f"
},
"PaymentMethod": "BankAccount",
"PaymentDescription": "Retry test",
"RecipientReference": "RETRY-01"
}'JavaScript (fetch) example with retry logic
const paymentBody = {
SendAccountId: "a14ff4d1-d91a-4b19-b94e-c302b7b43f3d",
SendCurrency: "GBP",
SendValue: 100.00,
StoredRecipient: {
StoredRecipientId: "5ac2e92a-1c2b-4d53-9e6b-67bb0e02fc9f"
},
PaymentMethod: "BankAccount",
PaymentDescription: "Retry test",
RecipientReference: "RETRY-01"
};
const headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
"Idempotency-Key": "b1f2f3a4-65db-46f7-b890-2d42e91f8c77"
};
async function sendPayment() {
try {
const response = await fetch("https://api.vitessepsp.com/payment-request", {
method: "POST",
headers,
body: JSON.stringify(paymentBody)
});
const result = await response.json();
console.log("Payment response:", result);
} catch (error) {
console.error("Request failed, retrying...");
// Retry using same body and same Idempotency-Key
await sendPayment(); // In production, implement exponential backoff
}
}
sendPayment();What to do next?
After you receive a successful response, you can:
- Continue processing using the returned payment ID
- Retrieve the latest payment status with
GET /payment-request/{id} - Rely on webhook events to receive status updates
Updated 17 days ago