How to integrate Mobile Money payments into a website in Ghana
To integrate Mobile Money into a website in Ghana with the berrapay API, your server creates a checkout for the order and sends the customer to the address it returns. They pay by MTN, Telecel or AT Mobile Money or by card, are sent back to your site, and your server receives a signed webhook saying the checkout is paid. One integration covers all three networks.
Step by step
- 1
Get a test key
Sign in, open Settings, then Connections, then berrapay API, and create a key. Use a test key (it starts with bp_test_) while you build: no real money moves. Keep keys on your server, never in a web page or app.
- 2
Create a checkout for each order
Send the amount, a description, your order number as the reference and a return address.
- 3
Send the customer to the checkout
Redirect them to the url in the response.
- 4
Confirm with a webhook
Add a webhook address. Mark the order paid when checkout.paid arrives and its signature is valid.
- 5
Go live
Swap in a live key, which starts with bp_live_, once your account is approved.
Create a checkout and redirect
// Node.js, on your server
const res = await fetch("https://berrapay.com/api/v1/checkouts", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.BERRAPAY_KEY,
"Content-Type": "application/json",
"Idempotency-Key": "order-" + order.id, // a retry never creates a second checkout
},
body: JSON.stringify({
amount: 25.5, // cedis, as a number: GHS 25.50
description: "Jollof for two",
reference: String(order.id),
customer: { name: "Ama Mensah", phone: "0241234567" },
return_url: "https://yourshop.com/thanks",
}),
});
const checkout = await res.json();
if (!res.ok) throw new Error(checkout.error.message + " " + checkout.error.fix);
response.redirect(checkout.url); // the customer pays hereAt a glance
- Base address
- https://berrapay.com/api/v1
- Networks covered
- MTN, Telecel and AT, plus cards
- Amounts
- Numbers in cedis, never pesewas
- Retries
- Safe with an Idempotency-Key header
- Test mode
- Free, no money moves
Common questions
Do I integrate each network separately?
No. One checkout takes MTN, Telecel and AT.
How do I test without real money?
Use a test key and the pretend payment page, which lets you approve or fail a payment.
What if my server misses the webhook?
berrapay retries for about a day, and you can always read the checkout's status directly.
What does it cost?
Payments are in Ghana cedis (GHS). The payer is charged 1% when they pay by Mobile Money, never more than GHS 25 on one payment, or 1.95% when they pay by card. It is added to what they pay, so you receive the full amount. There is no setup or monthly fee, and topping up and withdrawing are free. The full list is at berrapay.com/fees.
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.