Idempotency
Network calls fail. When you retry POST /gateway/sessions/, you must not create
a second payment for the same order. Paymee makes session creation idempotent
through the merchant_reference field.
How it works
Section titled “How it works”merchant_reference is your unique identifier for a payment (an order id, a cart
id, an invoice number — whatever is stable on your side).
- The first request with a given
merchant_referencecreates the session and returns201 Created. - A subsequent request with the same
merchant_referencereturns the existing session with200 OK— no duplicate is created.
# First call → 201 Created, new sessioncurl https://api.paymee.online/api/v1/gateway/sessions/ \ -H "Authorization: Bearer sk_live_…" -H "Content-Type: application/json" \ -d '{ "amount": "10.500", "merchant_reference": "order-0001", "first_name": "Aymen", "last_name": "Ben Salah", "email": "aymen@example.com" }'
# Same merchant_reference → 200 OK, the same session is returnedGuidelines
Section titled “Guidelines”- Generate
merchant_referenceonce per order, before the first attempt, and reuse it on every retry of that order. - Use a new
merchant_referenceonly when you genuinely want a new payment (e.g. the buyer is paying again after a failure that closed the session). - Keep it unique per merchant account.
Conflicts
Section titled “Conflicts”If a request conflicts with the current state of an existing session, you receive
409 Conflict as an RFC 9457 problem document, which may
include an existing_session_id.

