7. Build your own payment screens with the Payment API
The Payment API lets you take mobile money payments from your own checkout screens. Your application shows the payment methods, collects the payer's phone number and starts the payment. Papi sends the request to the provider and tells you the result.
This page explains the concepts and the integration flow. The endpoints are described in the API reference:
Hosted Checkout and Payment API
Papi offers two integration modes:
| Hosted Checkout | Payment API | |
|---|---|---|
| Who builds the payment screens | Papi (the Papi payment form) | You |
| How you start a payment | Create a payment link, then redirect the customer to it | Initiate a payment from your backend |
| Payment methods | MVola, Airtel Money, Orange Money, cards | MVola, Airtel Money, Orange Money (no cards) |
| Guide | Integrate Papi to your web application | This page |
Both modes run on the same payment engine. The pricing, the calls to the providers, the provider callbacks and the notifications sent to your notificationUrl are the same.
Availability
The Payment API is available to every shop, in the sandbox and in production, without any activation. Your API key is all you need.
Cards are not available
Card payments are excluded from the Payment API on purpose. Card data is captured only on the Papi payment form (hosted fields), so that card numbers never pass through your servers.
If you send "paymentMethod": "BRED" (or any other value outside MVOLA, AIRTEL_MONEY, ORANGE_MONEY), Papi answers 400 with the code CORE_INPUT_400 and the list of accepted methods. To accept cards, use the Hosted Checkout for those payments.
Authentication
Every request must carry your shop API key in the Token header. It is the same key as for the payment link API. You find it in the dashboard: Avatar icon → Boutiques → select shop → Developer tab.
- A missing or invalid API key is answered with
401. - The
LinkTokenheader used by the payment page is not accepted.
The API key identifies your application. Never put it in a web page, a mobile app or any other code that runs on the customer's device. Your checkout screens call your backend, and your backend calls Papi.
Payment statuses
A payment has one of three statuses. They are the same values as paymentStatus in the notification.
paymentStatus | Meaning |
|---|---|
PENDING | The payment is started and waits for the payer or the provider. |
SUCCESS | The payment went through. This status is final. |
FAILED | The payment did not go through. The error object gives the reason. This status is final. |
A PENDING payment is never closed by Papi on its own. If the provider's answer never reaches Papi, Papi asks the provider for the status of the payment about an hour after the initiation, and settles the payment from that answer only. As long as the provider reports the payment as pending, it stays PENDING.
Behaviour per payment method
| Payment method | What you collect from the payer | What the payer does | After initiation |
|---|---|---|---|
MVola (MVOLA) | phoneNumber | Receives a validation prompt on their MVola phone and confirms it with their PIN code. | paymentStatus is PENDING until the payer confirms the prompt on their phone. |
Airtel Money (AIRTEL_MONEY) | phoneNumber | Receives a validation prompt on their Airtel Money phone and confirms it with their PIN code. | Same as MVola. |
Orange Money (ORANGE_MONEY) | phoneNumber and temporaryCode | Before the initiation, dials #144*3*3# on their Orange Money phone to get a temporary code, and types this code in your checkout. | paymentStatus is SUCCESS or FAILED immediately. |
MVola and Airtel Money
Papi pushes a confirmation prompt to the payer's phone. The final status arrives when the payer confirms, or when the prompt expires or fails. You receive it by notification, and you can also read it with Get a payment.
Orange Money
Before the payment is initiated, the payer dials #144*3*3# on their Orange Money phone. Orange Money gives them a temporary code. Your checkout asks the payer to type this code, and you send it in temporaryCode.
Papi validates the temporary code synchronously. The response to the initiation already contains the final status (SUCCESS or FAILED). The notification is still sent.
Idempotency
Your reference (for example, your order ID) is the idempotency key, inside your shop. The rule is simple: one reference can succeed only once. A PENDING attempt holds the reference until it ends, however long that takes, and only a FAILED attempt lets you start a new one. When you initiate a payment, Papi looks at the payment that counts for the same reference: the SUCCESS one if there is one, whatever its age, otherwise the latest attempt:
Payment that counts for this reference | Papi answers |
|---|---|
| None | A new payment. |
PENDING or SUCCESS, with the same amount, currency, paymentMethod and phoneNumber | The same payment again. The payer is not debited a second time. |
PENDING or SUCCESS, with a different amount, currency, paymentMethod or phoneNumber | 409 with the code PAYMENT_CONFLICT. No payment is created. |
FAILED (and no SUCCESS under the reference) | A new payment attempt. |
Rules for your integration:
- Use one reference per order.
- If the order changes (for example, a different amount), use a new reference.
- After a failed payment, you can initiate a new attempt with the same reference.
Details: Idempotency in the API reference.
Notifications
The Payment API uses the existing notification mechanism, without any change. When the payment ends, Papi sends a POST request to your notificationUrl. The body is the same as for payment links (paymentStatus, paymentMethod, amount, fee, merchantPaymentReference, paymentReference, notificationToken, message, and so on). See the example notification body in the integration guide.
Every notification is signed with the X-Papi-Signature header. Verify the signature before you trust the notification: see Securing notifications (callbacks). Then check that merchantPaymentReference and notificationToken match the values of your payment.
Rely on the notification to update your order. As a fallback, read the payment with GET /v1/payments/{reference}: see Get a payment.
Suggested integration flow
Show the payer the payment methods that you enable on your application: MVOLA, AIRTEL_MONEY, ORANGE_MONEY. The table in Behaviour per payment method gives the fields to collect and what the payer does for each method.
Call GET /v1/payments/fees with the chosen paymentMethod and the amount. Show payerFee and totalAmount to the payer.
Ask the payer for their mobile money phone number (phoneNumber). For Orange Money, the payer first dials #144*3*3# on their phone, then types the temporary code in your checkout.
Call POST /v1/payments from your backend. Store the returned papiPaymentReference and notificationToken next to your reference. For MVola and Airtel Money, tell the payer to confirm the payment on their phone.
Wait for the signed notification on your notificationUrl. As a fallback, call GET /v1/payments/{reference} every few seconds, and stop when paymentStatus is no longer PENDING.
If you did not receive the answer to the initiation, send the same request again, with the same body. You receive the same payment. You can also read the payment that counts for your reference with GET /v1/payments/{reference}.
Test mode
- A sandbox application always creates test payments.
- A production application always creates real payments.
In the sandbox, use the test phone numbers of the sandbox environment. The first number of each list gives a successful payment:
| Payment method | Test phone number (success) |
|---|---|
| Orange Money | 0321230001 |
| MVola | 0341230001 |
| Airtel Money | 331230001 |
The sandbox page lists the other numbers (insufficient balance, invalid phone number, blocked account).
Versioning
The API version is part of the path: /v1/.
- In a version, fields are only added. Your code must accept fields that it does not know.
- A change that is not backward compatible is published under a new path (
/v2/).