Skip to main content

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 CheckoutPayment API
Who builds the payment screensPapi (the Papi payment form)You
How you start a paymentCreate a payment link, then redirect the customer to itInitiate a payment from your backend
Payment methodsMVola, Airtel Money, Orange Money, cardsMVola, Airtel Money, Orange Money (no cards)
GuideIntegrate Papi to your web applicationThis 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 LinkToken header used by the payment page is not accepted.
Call the API from your server only

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.

paymentStatusMeaning
PENDINGThe payment is started and waits for the payer or the provider.
SUCCESSThe payment went through. This status is final.
FAILEDThe 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 methodWhat you collect from the payerWhat the payer doesAfter initiation
MVola (MVOLA)phoneNumberReceives 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)phoneNumberReceives a validation prompt on their Airtel Money phone and confirms it with their PIN code.Same as MVola.
Orange Money (ORANGE_MONEY)phoneNumber and temporaryCodeBefore 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 referencePapi answers
NoneA new payment.
PENDING or SUCCESS, with the same amount, currency, paymentMethod and phoneNumberThe same payment again. The payer is not debited a second time.
PENDING or SUCCESS, with a different amount, currency, paymentMethod or phoneNumber409 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​

1
Offer the payment methods

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.

2
Show the fees (optional)

Call GET /v1/payments/fees with the chosen paymentMethod and the amount. Show payerFee and totalAmount to the payer.

3
Collect the payer's phone number

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.

4
Initiate the payment

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.

5
Wait for the final status

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.

6
Retry safely after a network error

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 methodTest phone number (success)
Orange Money0321230001
MVola0341230001
Airtel Money331230001

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/).