Skip to main content

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

ItemValue
Base URLhttps://app.papi.mg/engine/api
Path/v1/payments
MethodPOST
Request bodyJSON
Response bodyJSON

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​

HeaderRequiredValueDescription
Token✓<YOUR_API_KEY>API key of your shop.
Content-Type✓application/jsonThe body is JSON.

The LinkToken header used by the payment page is not accepted as an authentication method.


Body parameters​

FieldTypeRequiredConstraints / validationDescription
paymentMethodstring✓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.
amountinteger✓Whole number. Minimum 300.Amount to pay, in currency, without the payer fee.
currencystring✗Only MGA is accepted. Default: MGA.Currency of amount.
referencestring✓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.
descriptionstring✓Maximum 255 characters.Short description of the payment.
notificationUrlstring✗Must start with http:// or https://.Your endpoint that receives the payment notification. Strongly recommended.
clientNamestring✓Maximum 255 characters.Name of the payer (your customer), as for payment links. It appears on the receipt and in the notification.
payerEmailstring✗Valid email address.Email address of the payer.
phoneNumberstring✓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.
temporaryCodestringFor ORANGE_MONEY onlyOrange 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.
testReasonstring✗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.

FieldTypeDescription
papiPaymentReferencestringPapi'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.
referencestringYour reference, as sent. It is the merchantPaymentReference of the notification.
paymentMethodstringPayment method: MVOLA, AIRTEL_MONEY or ORANGE_MONEY.
paymentStatusstringPENDING, SUCCESS or FAILED. The same values as paymentStatus in the notification. See Payment statuses.
amountnumberAmount of the payment, without the payer fee.
payerFeenumberPapi fee charged to the payer on top of amount.
totalAmountnumberAmount debited from the payer's account: amount + payerFee.
currencystringCurrency of the amounts (MGA).
descriptionstringDescription of the payment.
clientNamestringName of the payer, as sent.
payerEmailstringEmail address of the payer, or null.
phoneNumberstringMobile money phone number of the payer, in international format.
notificationUrlstringNotification URL, or null.
notificationTokenstringToken generated by Papi for this payment (a UUID). Store it: the notification carries the same value, as an additional check after the signature.
errorobjectnull, except when paymentStatus is FAILED. See Failed payment.
createdAtintegerCreation time of the payment, in epoch milliseconds (UTC).
updatedAtintegerTime of the last status change of the payment, in epoch milliseconds (UTC).

Behaviour per payment method​

paymentMethodpaymentStatus after initiationWhat happens next
MVOLAPENDINGThe 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_MONEYPENDINGSame as MVOLA.
ORANGE_MONEYSUCCESS or FAILEDThe 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."
}
}
}
FieldTypeDescription
error.codestringCode of the failure (for example PAPI-6001).
error.sourcestringOrigin 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.messagestringHuman-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 exist200 with a new payment.
…is PENDING or SUCCESS, with the same amount, currency, paymentMethod and phoneNumber200 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 phoneNumber409 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:


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 statusError codeMeaning
400CORE_INPUT_400A 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.
400PAYMENT_METHOD_NOT_ENABLEDThe payment method exists but is not enabled on your shop.
401CORE_PERM_0001The Token header is missing, or the API key is invalid (message: API key invalide).
409PAYMENT_CONFLICTThe payment that counts for this reference is PENDING or SUCCESS with a different amount, currency, paymentMethod or phoneNumber. See Idempotency.
409PROVIDER_SUSPENDEDProduction application only: the payment method is temporarily suspended by Papi.
409CREDIT_EXHAUSTEDYour 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 400 without changing the request: the same body is refused again.
  • Do not retry a 409 PAYMENT_CONFLICT with the same body. Follow the options in Conflict response.

Waiting for the final status​

  • Rely on the notification sent to your notificationUrl. Verify its X-Papi-Signature header first: see Securing notifications (callbacks). Then check merchantPaymentReference and notificationToken.
  • As a fallback, call GET /v1/payments/{reference} every few seconds, and stop when paymentStatus is no longer PENDING.

Amounts and phone numbers​

  • You send amounts as whole numbers in MGA: MGA has no fraction. Papi returns every amount and fee as a number (5000.0), never rounded, like the payment-link API. Only MGA is 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).