How to handle failed and pending Mobile Money payments in Ghana
A Mobile Money payment is pending from the moment the prompt is sent until the customer approves it on their phone, and it fails if they decline, enter the wrong PIN, have too little money, or simply don't respond. Good software treats pending as normal, never assumes success, lets the customer try again, and makes sure a retry can't charge twice.
Step by step
- 1
Expect delays
Prompts can take a while to arrive, and customers take time to find their phone. Don't time out after a few seconds.
- 2
Never assume
Fulfil only on a paid status or a verified webhook.
- 3
Make retries safe
Send an Idempotency-Key header when you create a payment. Sending the same key again returns the same payment and never creates a second one.
- 4
Offer another way
If the prompt doesn't arrive, give the customer the payment page, where they can use another network or a card.
- 5
Close old payments
Set an expiry so yesterday's unpaid checkout can't be paid at an old price.
- 6
Read the failure
A failed charge carries a failure message. Show the customer something useful, not a code.
Create safely, then follow the result
// Node.js: the same Idempotency-Key always returns the same charge
const res = await fetch("https://berrapay.com/api/v1/charges", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.BERRAPAY_KEY,
"Content-Type": "application/json",
"Idempotency-Key": "order-" + order.id + "-try-" + order.attempt,
},
body: JSON.stringify({ amount: order.total, phone: order.phone, network: order.network }),
});
const charge = await res.json();
if (charge.status === "failed") tellCustomer(charge.failure); // why it wasn't approved
else if (charge.status === "pending") showWaiting(charge.pay_url); // they can also pay from this pageWhat each state means
| State | What happened | What to do |
|---|---|---|
| pending | The prompt is out and the customer hasn't answered | Show a waiting screen and listen for the result |
| succeeded or paid | The customer approved and the money is confirmed | Fulfil the order, once |
| failed | Declined, wrong PIN, not enough money or no response | Tell the customer plainly and offer to try again |
| expired | The time to pay ran out | Create a new payment if they still want to buy |
Common questions
How long should I wait before giving up?
A phone charge can be approved for 15 minutes. Keep the order open at least that long.
The customer says they were charged but I see failed.
Check the payment in berrapay first. If the money did leave their wallet and didn't arrive, report it from the payment or at berrapay.com/dispute.
How do I avoid charging twice when my request times out?
Retry with the same Idempotency-Key. You get the original payment back.
Ask an AI assistant about this
Opens the assistant in a new tab with a question about this page already typed. You can change it before sending.