Guides
Safe retries
Retry a payment with the same reference, and a payment link with an Idempotency-Key.
Networks drop. If a request times out you cannot tell whether it reached us, so you retry. Payments and payment links retry in different ways.
Payments
POST /payments/initialize does not use an Idempotency-Key. Your reference is the key. The same reference and the same amountKobo returns the original payment. A different amount is 409 REFERENCE_IN_USE.
Payment links
Send an Idempotency-Key header on POST /payment-links. A retry with the same key returns the original link instead of creating another one.
With an idempotency key
curl -X POST https://middleware.test.nextcba.com/api/v1/pg/v1/payment-links \
-H "Authorization: Bearer $CSWITCH_SECRET_KEY" \
-H "Idempotency-Key: 6f1c2e4a-9b7d-4c1e-8a2f-1d3e5b7c9a0b" \
-H "Content-Type: application/json" \
-d '{"title": "Silk wrap dress", "amountKobo": 6500000}'CarefulUse a new Idempotency-Key for each new link. Reusing a key is for retrying that same create, not for a different title or amount.