Create a payment session
const url = 'https://api.paymee.online/api/v1/gateway/sessions/';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"amount":"10.500","currency":"TND","merchant_reference":"order-0001","first_name":"Aymen","last_name":"Ben Salah","email":"aymen@example.com","return_url":"https://your-site.tn/payment/success","cancel_url":"https://your-site.tn/payment/cancel","webhook_url":"https://your-site.tn/webhooks/paymee","metadata":{"cart_id":"8812"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.paymee.online/api/v1/gateway/sessions/ \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "amount": "10.500", "currency": "TND", "merchant_reference": "order-0001", "first_name": "Aymen", "last_name": "Ben Salah", "email": "aymen@example.com", "return_url": "https://your-site.tn/payment/success", "cancel_url": "https://your-site.tn/payment/cancel", "webhook_url": "https://your-site.tn/webhooks/paymee", "metadata": { "cart_id": "8812" } }'Create a payment session and its initial hosted checkout. The response includes a checkout_url to redirect the buyer to. Reusing the same merchant_reference returns the existing session (200) instead of creating a duplicate.
Currency. The buyer’s card is always charged, and you are always settled, in your account’s currency (TND). A request in TND is charged as sent. A request in another currency is converted at the exchange rate you configured for it (Settings → Currencies), rounded half-up to millimes; the response amount/currency are then the TND charge and original carries what you requested plus the rate applied. A request in a currency you have not configured a rate for is rejected with 422 and errors[].code = "currency_unsupported" on the currency field. The rate is frozen on the session at creation; later rate changes never alter an existing session, and an idempotent replay returns the original snapshot.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Input serializer for creating a payment session.
Optional strings accept "" as “no value” (as Stripe does), so a client that sends
every field of a form, filled or not, is not refused.
object
Amount as string with correct decimal places for currency
ISO 4217 code. Defaults to the account’s currency when omitted.
Merchant’s display-friendly order ID
Line items: [{name, quantity, unit_price, description}]
object
Language of the payment page: fr, en, or auto (the default) to follow the buyer’s browser. The buyer can still switch language on the page. The card-entry page opens in the language the buyer is reading when they pay.
auto- The buyer’s browser languagefr- Frenchen- English
Examples
Create a session
{ "amount": "10.500", "currency": "TND", "merchant_reference": "order-0001", "first_name": "Aymen", "last_name": "Ben Salah", "email": "aymen@example.com", "return_url": "https://your-site.tn/payment/success", "cancel_url": "https://your-site.tn/payment/cancel", "webhook_url": "https://your-site.tn/webhooks/paymee", "metadata": { "cart_id": "8812" }}Responses
Section titled “Responses”Response serializer for payment session detail.
object
Merchant-provided unique reference for idempotency
System-generated order number (PM-XXXXXX)
Merchant’s display-friendly order ID (separate from merchant_reference)
object
Requested amount, as a decimal string at the requested currency’s precision.
Requested ISO 4217 currency code.
Exchange rate applied (1 original.currency = rate currency), six decimals. “1.000000” when no conversion.
Line items: [{name, quantity, unit_price, description}]
CREATED- CreatedPENDING- PendingPROCESSING- ProcessingSUCCEEDED- SucceededFAILED- FailedEXPIRED- ExpiredCANCELED- Canceled
object
Language of the payment page: fr, en, or auto (the buyer’s browser).
Serializer for payment attempts (read-only).
object
INITIATED- InitiatedPROCESSING- ProcessingSUCCEEDED- SucceededFAILED- FailedABANDONED- Abandoned
The acquirer’s decline code, as webhooks carry it; None unless the attempt failed.
The acquirer’s decline reason, as webhooks carry it; None unless the attempt failed.
Every refund of this session, oldest first.
A refund.
object
Refund id (re_…).
The refunded payment session (ps_…).
The session’s merchant_reference.
Refunded amount, as a decimal string.
ISO 4217 currency of amount.
FULL- FullPARTIAL- Partial
PENDING while the refund is in progress, SUCCEEDED once the money is returned, FAILED if it was not.
Why the refund is pending or failed, when known. Informational; may change.
When the refund reached SUCCEEDED or FAILED.
Example
{ "status": "CREATED", "locale": "auto", "attempts": [ { "status": "INITIATED" } ], "refunds": [ { "refund_type": "FULL", "status": "PENDING" } ]}Response serializer for payment session detail.
object
Merchant-provided unique reference for idempotency
System-generated order number (PM-XXXXXX)
Merchant’s display-friendly order ID (separate from merchant_reference)
object
Requested amount, as a decimal string at the requested currency’s precision.
Requested ISO 4217 currency code.
Exchange rate applied (1 original.currency = rate currency), six decimals. “1.000000” when no conversion.
Line items: [{name, quantity, unit_price, description}]
CREATED- CreatedPENDING- PendingPROCESSING- ProcessingSUCCEEDED- SucceededFAILED- FailedEXPIRED- ExpiredCANCELED- Canceled
object
Language of the payment page: fr, en, or auto (the buyer’s browser).
Serializer for payment attempts (read-only).
object
INITIATED- InitiatedPROCESSING- ProcessingSUCCEEDED- SucceededFAILED- FailedABANDONED- Abandoned
The acquirer’s decline code, as webhooks carry it; None unless the attempt failed.
The acquirer’s decline reason, as webhooks carry it; None unless the attempt failed.
Every refund of this session, oldest first.
A refund.
object
Refund id (re_…).
The refunded payment session (ps_…).
The session’s merchant_reference.
Refunded amount, as a decimal string.
ISO 4217 currency of amount.
FULL- FullPARTIAL- Partial
PENDING while the refund is in progress, SUCCEEDED once the money is returned, FAILED if it was not.
Why the refund is pending or failed, when known. Informational; may change.
When the refund reached SUCCEEDED or FAILED.
Example
{ "status": "CREATED", "locale": "auto", "attempts": [ { "status": "INITIATED" } ], "refunds": [ { "refund_type": "FULL", "status": "PENDING" } ]}Malformed request: the body is not valid JSON, or a header is invalid.
RFC 9457 problem detail body (application/problem+json).
object
URI identifying the error type.
Short, human-readable summary of the error type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Examplegenerated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example"}Missing, malformed, expired, or revoked API key.
RFC 9457 problem detail body (application/problem+json).
object
URI identifying the error type.
Short, human-readable summary of the error type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Examplegenerated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example"}The request conflicts with an earlier one; the type says how.
Problem detail of a 409.
object
URI identifying the error type.
Short, human-readable summary of the error type.
HTTP status code.
Human-readable explanation specific to this occurrence.
On a conflict from session creation: the session that already uses this merchant_reference.
Examplegenerated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "existing_session_id": "example"}A field failed validation (errors lists them), or a business rule refused the request (the type says which).
Problem detail of a 422: a per-field errors array when fields failed validation;
no errors when a business rule refused the request (the type says which).
object
URI identifying the error type.
Short, human-readable summary of the error type.
HTTP status code.
Human-readable explanation specific to this occurrence.
A single field-level validation error inside a problem+json body.
object
Name of the field that failed validation.
Machine-readable error code, e.g. ‘required’.
Human-readable description of the failure.
Examplegenerated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example", "errors": [ { "field": "example", "code": "example", "message": "example" } ]}Rate limit exceeded. Wait the number of seconds in the Retry-After header.
RFC 9457 problem detail body (application/problem+json).
object
URI identifying the error type.
Short, human-readable summary of the error type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Examplegenerated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example"}Unexpected error; nothing was changed. Safe to retry with backoff.
RFC 9457 problem detail body (application/problem+json).
object
URI identifying the error type.
Short, human-readable summary of the error type.
HTTP status code.
Human-readable explanation specific to this occurrence.
Examplegenerated
{ "type": "https://example.com", "title": "example", "status": 1, "detail": "example"}
