Skip to content
FanakDocs
WebsiteDashboard

Integrate

Idempotency

Retry a create safely, without charging the customer twice.

merchant_reference is your idempotency key: the same reference returns the same intent.

Request Answer
First create with a reference 201, new intent
Later create, same reference 200, the existing intent, any status (even succeeded, canceled)
Two identical creates at once One intent
  • Unique per application. One per payment, such as your order number.
  • A repeat ignores its other fields: amount, description and expiry stay as created.
  • A repeat must still be valid (422 otherwise). expires_at limits apply only on creation.
Terminal window
# Run it twice: the first call answers 201, the second 200 with the same uuid.
curl -i https://pay.fanak.ly/api/v1/payment-intents \
-H "X-API-Key: $FANAK_API_KEY" \
-H "Authorization: Bearer $FANAK_ACCESS_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"merchant_reference": "order-1042", "amount": 5000, "currency": "LYD", "description": "Order #1042"}'
  • Derive it from your order, so retries reuse it.
  • A second payment for one order needs a new one: order-1042-2.
  • At most 255 characters.