Direct payment
Charge a phone number from your own interface, without the FlowPay payment page.
By default, creating a payment returns a checkout_url: you send the customer to the FlowPay payment page, which collects their network and number. If your own interface already collects them, open the attempt in the create call: that is a direct payment.
When to use it
| You want to… | Use |
|---|---|
| Send the customer to a ready-made payment page | A payment with checkout_url (Payments) |
| Keep the flow inside your app or site | A direct payment |
A direct payment is made from your server, with your secret key: your interface sends the network and the number to your server, which calls FlowPay. Never put the API key in a mobile app or a web page.
The call
It is the usual POST /v1/payments, with three more fields. As soon as network is present, the payment is direct.
| Field | Description |
|---|---|
network | The network the customer picked, for example BF_ORANGE. |
msisdn | The customer's number, with or without country code. Requires network. |
otp | The operator's code, for "code" networks only (see below). 4 to 8 digits. |
curl -X POST "$FLOWPAY_URL/v1/payments" \
-H "Authorization: Bearer sk_test_..." \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"merchant_reference": "CMD-2026-0004",
"amount": 5000,
"currency": "XOF",
"network": "BF_ORANGE",
"msisdn": "+22670000001",
"otp": "123456"
}'country and networks, which restrict the payment page's networks, are useless here: the network is already chosen, so they are ignored.
The open networks, with their key, are listed by GET /v1/referential/networks, without authentication. A network whose is_active is false appears in the list but cannot receive a payment.
The response
The response is the usual payment (see Payments): networks only holds the chosen network and checkout_url is null, since the customer skips the payment page. It also carries:
| Field | Description |
|---|---|
next_action | What is left to do: NONE or REDIRECT. |
redirect_url | Where to send the customer for REDIRECT, otherwise null. |
attempts | One entry: the attempt that just opened. |
{
"id": "6f1c2d3e-0000-4000-8000-000000000001",
"state": "PROCESSING",
"merchant_reference": "CMD-2026-0004",
"amount": "5000",
"currency": "XOF",
"next_action": "NONE",
"redirect_url": null,
"attempts": [{ "attempt_no": 1, "provider_key": "LIGDICASH" }]
}Shortened example: the full response carries every payment field.
next_action | What you do |
|---|---|
NONE | Nothing. The customer approves on their phone (or the code was already supplied). Wait for the outcome. |
REDIRECT | Send the customer to redirect_url. They pay at their operator, then come back to your return_url, required for these networks. |
Follow the outcome
Opening the attempt is not the outcome: the payment is only settled once it reaches SUCCEEDED.
- Webhook (recommended): you receive
payment.succeededorpayment.failed. See Webhooks. - Read:
GET /v1/payments/{id}. Poll a few seconds apart: the limit is 60 requests per minute (see Authentication).
Code networks
On some networks, the customer first generates a code with their operator (for example by dialing a USSD code), and you pass it in otp.
- Without
otp, the request is refused with422 otp_required, with no call to the operator. - The code is never stored, logged, returned, or counted for idempotency. Do not log it on your side either.
- It is only used for the first attempt.
When the attempt is refused
What the network requires is checked before anything is created: without otp on a code network (422 otp_required) or without return_url on a redirect network (422 return_url_required), nothing is created. Fix it and send the request again.
For other refusals, the payment is created before the attempt: it already exists and stays waiting for the customer. Fix the cause and replay with the same Idempotency-Key: you get the same payment, and the attempt is reopened.
| Status | error | Cause |
|---|---|---|
| 422 | invalid_msisdn | Number invalid for this network. |
| 422 | msisdn_not_allowed | This payment cannot be settled from this number. |
| 422 | network_not_allowed | Network not offered for this payment. |
| 422 | otp_required | The network requires a code. Nothing is created. |
| 422 | return_url_required | The network redirects the customer: return_url is required. Nothing is created. |
| 422 | invalid_otp | Invalid code: 4 to 8 digits. |
| 422 | no_route_available | No provider available for this network. |
The full list is in Errors. A payment gets at most three attempts, automatic failover to another provider included.
Test it
With an sk_test_… key no money moves: a number ending in 0000 is refused by the sandbox, any other is accepted and then settled after a few seconds. See Quickstart.