Initiate a payment
Starts a mobile money payment from your own checkout. Papi sends the request to the provider and returns the payment, with its paymentStatus. Papi notifies your notificationUrl when the payment ends.
For the concepts and the whole flow, see the Payment API guide.
Endpoint
POST https://app.papi.mg/engine/api/v1/payments
| Item | Value |
|---|---|
| Base URL | https://app.papi.mg/engine/api |
| Path | /v1/payments |
| Method | POST |
| Request body | JSON |
| Response body | JSON |
The same path is available in the sandbox environment.
Authentication
Every request must carry your shop API key in the Token header. You find the API key in the dashboard: Avatar icon → Boutiques → select shop → Developer tab. It is the same key as for the payment link API.
The payment is created in the shop that the API key belongs to. Idempotency (see Idempotency) is also evaluated inside that shop.
Request headers
| Header | Required | Value | Description |
|---|---|---|---|
Token | ✓ | <YOUR_API_KEY> | API key of your shop. |
Content-Type | ✓ | application/json | The body is JSON. |
The LinkToken header used by the payment page is not accepted as an authentication method.
Body parameters
| Field | Type | Required | Constraints / validation | Description |
|---|---|---|---|---|
paymentMethod | string | ✓ | One of MVOLA, AIRTEL_MONEY, ORANGE_MONEY. Card methods (for example BRED) are refused. | Payment method chosen by the payer, among the payment methods enabled on your shop. |
amount | integer | ✓ | Whole number. Minimum 300. | Amount to pay, in currency, without the payer fee. |
currency | string | ✗ | Only MGA is accepted. Default: MGA. | Currency of amount. |
reference | string | ✓ | Maximum 255 characters. | Your identifier for this payment (for example, your order ID). It is the idempotency key: see Idempotency. It is returned as merchantPaymentReference in notifications. |
description | string | ✓ | Maximum 255 characters. | Short description of the payment. |
notificationUrl | string | ✗ | Must start with http:// or https://. | Your endpoint that receives the payment notification. Strongly recommended. |
clientName | string | ✓ | Maximum 255 characters. | Name of the payer (your customer), as for payment links. It appears on the receipt and in the notification. |
payerEmail | string | ✗ | Valid email address. | Email address of the payer. |
phoneNumber | string | ✓ | Valid phone number, national (0341234567) or international format. | Mobile money phone number of the payer. Papi sends the payment request to this number, and the money is taken from this account. |
temporaryCode | string | For ORANGE_MONEY only | Orange Money refuses the payment without it: the answer is then 200 with paymentStatus FAILED. | Temporary code that the payer gets by dialing #144*3*3# on their Orange Money phone. |
testReason | string | ✗ | Same values as for payment links. | Reason for the test. |
Request example
curl -X POST "https://app.papi.mg/engine/api/v1/payments" \
-H "Content-Type: application/json" \
-H "Token: <YOUR_API_KEY>" \
-d '{
"paymentMethod": "MVOLA",
"amount": 5000,
"currency": "MGA",
"reference": "ORDER-1042",
"description": "Commande 1042",
"notificationUrl": "https://shop.example/papi/notify",
"clientName": "Ranaivo",
"payerEmail": "ranaivo@example.mg",
"phoneNumber": "0341234567"
}'
Request body for Orange Money (temporaryCode is the only extra field):
{
"paymentMethod": "ORANGE_MONEY",
"amount": 5000,
"reference": "ORDER-1043",
"description": "Commande 1043",
"notificationUrl": "https://shop.example/papi/notify",
"clientName": "Ranaivo",
"phoneNumber": "0321234567",
"temporaryCode": "1234"
}
Success response
Status: 200 OK
Papi answers 200 with the payment for every outcome of the initiation, including when the provider refuses the payment. In that case, paymentStatus is FAILED and the error object gives the reason (see Failed payment). Always read paymentStatus: a 200 does not mean that the payment succeeded.
{
"data": {
"papiPaymentReference": "b6d1…-uuid",
"reference": "ORDER-1042",
"paymentMethod": "MVOLA",
"paymentStatus": "PENDING",
"amount": 5000.0,
"payerFee": 0.0,
"totalAmount": 5000.0,
"currency": "MGA",
"description": "Commande 1042",
"clientName": "Ranaivo",
"payerEmail": "ranaivo@example.mg",
"phoneNumber": "+261 34 12 345 67",
"notificationUrl": "https://shop.example/papi/notify",
"notificationToken": "uuid",
"error": null,
"createdAt": 1790238788404,
"updatedAt": 1790238788404
}
}
Payment object
The same object is returned by Get a payment.
| Field | Type | Description |
|---|---|---|
papiPaymentReference | string | Papi's reference for this payment attempt. It is the paymentReference of the notification. It is not a lookup key: you read the payment with your reference. |
reference | string | Your reference, as sent. It is the merchantPaymentReference of the notification. |
paymentMethod | string | Payment method: MVOLA, AIRTEL_MONEY or ORANGE_MONEY. |
paymentStatus | string | PENDING, SUCCESS or FAILED. The same values as paymentStatus in the notification. See Payment statuses. |
amount | number | Amount of the payment, without the payer fee. |
payerFee | number | Papi fee charged to the payer on top of amount. |
totalAmount | number | Amount debited from the payer's account: amount + payerFee. |
currency | string | Currency of the amounts (MGA). |
description | string | Description of the payment. |
clientName | string | Name of the payer, as sent. |
payerEmail | string | Email address of the payer, or null. |
phoneNumber | string | Mobile money phone number of the payer, in international format. |
notificationUrl | string | Notification URL, or null. |
notificationToken | string | Token generated by Papi for this payment (a UUID). Store it: the notification carries the same value, as an additional check after the signature. |
error | object | null, except when paymentStatus is FAILED. See Failed payment. |
createdAt | integer | Creation time of the payment, in epoch milliseconds (UTC). |
updatedAt | integer | Time of the last status change of the payment, in epoch milliseconds (UTC). |
Behaviour per payment method
paymentMethod | paymentStatus after initiation | What happens next |
|---|---|---|
MVOLA | PENDING | The payer confirms the prompt on their phone with their PIN code. The final status arrives by notification (and is visible with Get a payment) when the payer confirms, or when the prompt expires or fails. |
AIRTEL_MONEY | PENDING | Same as MVOLA. |
ORANGE_MONEY | SUCCESS or FAILED | The temporary code is validated synchronously: the status is final in this response. The notification is still sent. |
Failed payment
When the provider or Papi refuses the payment, the answer is still 200 OK, with paymentStatus set to FAILED and an error object. Excerpt (other fields omitted):
{
"data": {
"papiPaymentReference": "b6d1…-uuid",
"reference": "ORDER-1042",
"paymentStatus": "FAILED",
"error": {
"code": "PAPI-6001",
"source": "PROVIDER_ERROR",
"message": "Le fournisseur de paiement n'a pas répondu à temps. Si votre compte a été débité, le montant vous sera restitué. Veuillez réessayer plus tard ou utiliser un autre moyen de paiement."
}
}
}
| Field | Type | Description |
|---|---|---|
error.code | string | Code of the failure (for example PAPI-6001). |
error.source | string | Origin of the failure: PAYER_ERROR, PROVIDER_ERROR, PAPI_ERROR, or UNKNOWN_ERROR when the provider reported the failure without a cause (code PAPI-8000). |
error.message | string | Human-readable reason, in French. |
A failed payment is final. To let the payer try again, initiate a new payment with the same reference: see Idempotency.
Idempotency
Initiating a payment is idempotent on reference, inside your shop, with one rule: a reference can succeed only once. Papi compares your request with the payment that counts for the same reference: the SUCCESS one if there is one, whatever its age, otherwise the latest attempt.
Behaviour
You send a POST with a reference whose payment that counts… | Papi answers |
|---|---|
| …does not exist | 200 with a new payment. |
…is PENDING or SUCCESS, with the same amount, currency, paymentMethod and phoneNumber | 200 with the same payment. No new payment is created, and the payer is not debited a second time. |
…is PENDING or SUCCESS, with a different amount, currency, paymentMethod or phoneNumber | 409 with the code PAYMENT_CONFLICT. No payment is created. |
…is FAILED (no SUCCESS under the reference) | 200 with a new payment attempt. |
Recommendations
- Use one reference per order.
- If the order changes (for example, a different amount), use a new reference.
- After a network error, send the same request again, with the same body. You receive the payment created by the first request, or a new payment if the first request never reached Papi.
Conflict response
Status: 409 Conflict
{
"error": {
"code": "PAYMENT_CONFLICT",
"message": "Un paiement en cours existe déjà pour la référence ORDER-1042 avec un montant, une devise, un moyen de paiement ou un numéro de téléphone (phoneNumber) différents. Utilisez une autre référence."
}
}
To resolve a conflict, choose one of these options:
- read the existing payment with
GET /v1/payments/{reference}and wait for its final status; - send the request with another
reference.
Errors
All errors in the table below use this body format:
{
"error": {
"code": "<ERROR_CODE>",
"message": "<Human-readable message, in French>"
}
}
A refusal by the provider is not an error of this table: it is returned as 200 with paymentStatus FAILED (see Failed payment).
| HTTP status | Error code | Meaning |
|---|---|---|
400 | CORE_INPUT_400 | A body field failed validation: missing field, amount lower than 300, invalid phone number or email address, or a currency other than MGA, or paymentMethod is not one of MVOLA, AIRTEL_MONEY, ORANGE_MONEY. |
400 | PAYMENT_METHOD_NOT_ENABLED | The payment method exists but is not enabled on your shop. |
401 | CORE_PERM_0001 | The Token header is missing, or the API key is invalid (message: API key invalide). |
409 | PAYMENT_CONFLICT | The payment that counts for this reference is PENDING or SUCCESS with a different amount, currency, paymentMethod or phoneNumber. See Idempotency. |
409 | PROVIDER_SUSPENDED | Production application only: the payment method is temporarily suspended by Papi. |
409 | CREDIT_EXHAUSTED | Your Papi credit is exhausted (direct collection). |
Test mode
- If your shop is a sandbox application, every payment it creates is a test payment.
- If your shop is in production, every payment is a real payment.
In the sandbox, use the test phone numbers of the sandbox environment.
Practical notes
Retrying a request
- If the request times out or the connection drops, send the same request again, with the same body. See Idempotency.
- You can also read the payment that counts for your reference with
GET /v1/payments/{reference}. - Do not retry a
400without changing the request: the same body is refused again. - Do not retry a
409 PAYMENT_CONFLICTwith the same body. Follow the options in Conflict response.
Waiting for the final status
- Rely on the notification sent to your
notificationUrl. Verify itsX-Papi-Signatureheader first: see Securing notifications (callbacks). Then checkmerchantPaymentReferenceandnotificationToken. - As a fallback, call
GET /v1/payments/{reference}every few seconds, and stop whenpaymentStatusis no longerPENDING.
Amounts and phone numbers
- You send amounts as whole numbers in
MGA:MGAhas no fraction. Papi returns every amount and fee as a number (5000.0), never rounded, like the payment-link API. OnlyMGAis supported today. - Phone numbers are accepted in national (
0341234567) or international format. They are returned in international format (for example+261 34 12 345 67).