Skip to Content
FlowPayDocs

Create a payment

POST
/v1/payments

Creates a payment intent and returns the link to give the payer (checkout_url). The Idempotency-Key header is required: replaying the same request returns the same payment.

Payment through the page (without network): the optional country and networks restrict the networks offered to the payer; both combine (intersection). A network that is unavailable right now is left out; if none remains, the response is 422 no_network_available and nothing is created. networks in the response gives the final list.

Direct payment: as soon as network is present (with msisdn), the payment is direct: the attempt opens in the same call, the response carries next_action, networks only holds that network and checkout_url is null. country and networks are then ignored. What the payment method requires is checked before anything is created: a code network without otp answers 422 otp_required, a redirect network without return_url answers 422 return_url_required, and nothing is created. Other attempt refusals (invalid_msisdn, network_not_allowed…) leave the payment pending; replay with the same Idempotency-Key once fixed.

Authorization

ApiKeyBearer
headerAuthorizationBearer <sk_test_… | sk_live_…>

The application's API key. sk_test_…: sandbox, no money moves. sk_live_…: real.

Header Parameters

Idempotency-Key*string

Identifies the request: replaying it (unstable network) does not create a second payment. 1 to 255 characters, a unique identifier per creation (UUID recommended).

Length1 <= length <= 255

Request Body

application/json
  1. body
merchant_reference*string

Your order reference. Unique per application.

Length1 <= length <= 128
amount*|

Amount in major units, strictly positive: a number (15.5) or a string ("15.50"). No scientific notation. No more decimals than the currency allows (XOF: none).

currency*string
Match^[A-Z]{3}$
description?string
Lengthlength <= 500
return_url?string

The payer's return link. http(s) only: a javascript: link would run on the page.

Match^https?://\S+$
Lengthlength <= 2048
country?string

Payment through the page only: offers only this country's networks (two-letter ISO code). Ignored for a direct payment.

Match^[A-Z]{2}$
networks?array<string>

Payment through the page only: offers only these networks. Empty or absent: no restriction. Combines with country. Ignored for a direct payment.

network?string

Makes the payment direct, without a payment page: with msisdn, the attempt opens in the same call. The response then carries next_action (NONE or REDIRECT) and redirect_url.

msisdn?string

The payer's number. Requires network.

Lengthlength <= 32
otp?string

The operator's code, required by a USSD_PULL network (422 otp_required otherwise, with no call to the aggregator). Never stored, logged, or part of the idempotency fingerprint.

metadata?

Free-form JSON object, returned as is in webhooks.

Response Body

Payment created, or replayed if the idempotency key was already used for the same request.

application/json
  1. response
id*string
Formatuuid
state*PaymentState
Value in"CREATED""AWAITING_CUSTOMER""PROCESSING""SUCCEEDED""FAILED""EXPIRED""CANCELED"
mode*string
Value in"LIVE""TEST"
merchant_reference*string
amount*string

Amount in major units, at the currency's exponent.

amount_minor*integer

The same amount in minor units.

Formatint64
currency*string
description?string|null
metadata*
networks*array<string>

Networks the payer can choose, in alphabetical order: those left after country and networks. Only one for a direct payment, the one the merchant chose.

network?|

The network of the latest attempt, the one the payer paid or tried to pay with; null until they have tried.

checkout_url*|

The payment page link, to give the payer. null for a direct payment, which skips the page: for a redirect network (Wave), the operator's link is redirect_url.

expires_at*string
Formatdate-time
succeeded_at?|
Formatdate-time
created_at*string
Formatdate-time
attempts?array<>|

Present when reading a payment and in the response of a direct payment (the opened attempt); null when creating a payment with a payment page, in the list and on cancellation.

next_action?string

Only present in a direct payment's response (network and msisdn at creation). REDIRECT: send the payer to redirect_url. NONE: nothing to do, the payer confirms on their phone; follow the payment with GET /v1/payments/{id} or the webhook.

Value in"NONE""REDIRECT"
redirect_url?|

Only present in the response of a direct payment. The operator's page, for REDIRECT.

curl -X POST 'https://api.flowpay.example/api/v1/payments' \  -H 'Idempotency-Key: cle-2026-0001' \  -H 'Content-Type: application/json' \  -d '{  "merchant_reference": "CMD-2026-0001",  "amount": 5000,  "currency": "XOF"}'
Example Response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "state": "CREATED",  "mode": "LIVE",  "merchant_reference": "string",  "amount": "5000",  "amount_minor": 5000,  "currency": "XOF",  "description": "string",  "metadata": {},  "networks": [    "BF_ORANGE"  ],  "network": "BF_ORANGE",  "checkout_url": "string",  "expires_at": "2019-08-24T14:15:22Z",  "succeeded_at": "2019-08-24T14:15:22Z",  "created_at": "2019-08-24T14:15:22Z",  "attempts": [    {      "attempt_no": 1,      "state": "CREATED",      "provider_key": "LIGDICASH",      "route_reason": "LOWEST_COST",      "route_cost_minor": 0,      "failure_class": "CUSTOMER_DECLINED",      "created_at": "2019-08-24T14:15:22Z",      "settled_at": "2019-08-24T14:15:22Z"    }  ],  "next_action": "NONE",  "redirect_url": "string"}