By Kelvin Musagala, DevOps Web Designers
Payment flow
M-Pesa integration is a checkout experience
M-Pesa is familiar to Kenyan customers, but a familiar payment method can still create checkout friction when it is poorly implemented. A buyer should not wonder whether the prompt was sent, whether the amount is correct, whether the payment was received or whether the order exists. The website should guide each step clearly.
Safaricom Daraja gives developers access to M-Pesa APIs for web and mobile payment integration. In ecommerce, businesses often think first about STK Push because the customer can receive a payment prompt on the phone and authorize the transaction. But the technical request is only one part of the store experience. The order, payment status, customer message and admin record all need to agree.
A good M-Pesa ecommerce integration connects customer action to business operations. The buyer sees clear instructions. The payment result updates the order. The team can reconcile payments. Failed attempts have a recovery path. This is what separates a reliable checkout from a payment button that creates manual cleanup.
Payment standard
The customer should know what is happening, and the business should know which payment belongs to which order.
Map the buyer journey before touching the API
Start with the customer story. The buyer adds products to cart, enters delivery details, chooses M-Pesa, enters the phone number, receives a prompt, enters the M-Pesa PIN and waits for confirmation. At each step, the page should explain what is expected. If the buyer has to guess, the checkout is too vague.
The phone number field should be forgiving but clear. The amount should be shown before the prompt. The payment waiting state should reassure the buyer that the website is checking confirmation. The success state should show the order number and next steps. The failure state should explain whether to retry, use another method or contact support.
This flow matters especially on mobile. A buyer may move between browser and phone prompt. The checkout should not lose the order state if the buyer returns after a delay. The store should also avoid charging again unless the customer clearly chooses to retry.
The wording on the payment step should be plain. Tell the customer to keep the page open, approve the prompt on the phone and wait for confirmation. Small instructions can prevent abandoned payments because the buyer understands the short pause between checkout and confirmation.
Connect payment status to order status
Ecommerce teams need to see payment status inside the order workflow. If a payment succeeds, the order should move to the right status for fulfilment. If payment fails or times out, the order should not look paid. If the result is delayed, the system should avoid confusing staff or customers.
The admin view should show useful details: order number, customer phone, amount, payment reference where available, status and time. This helps staff respond to support questions and reconcile daily payments. Without this connection, the team may spend time comparing website orders with M-Pesa messages manually.
Different businesses may need different rules. Some want orders created before payment. Some only want confirmed orders after payment. Some want unpaid orders held for a short time. Some allow manual review for high-value orders. These rules should be decided before integration begins.
Pending
Paid
Failed
Manual review
Plan failed payments and timeouts
Payment failure is normal. A customer may cancel the prompt, enter the wrong PIN, delay too long, have insufficient funds, use the wrong phone number or lose connection. The site should expect these cases rather than treating them like rare technical accidents.
A good failure state is calm and useful. It should say that payment was not completed, keep the cart or order details available and offer a retry option. It should not make the buyer start from zero unless there is a strong reason. If support is needed, show the order number so the conversation starts with context.
Staff need a process too. What happens to unpaid orders after one hour? What if a buyer pays manually after the checkout says failed? What if the amount is different? What if two attempts happen? These decisions affect order cleanup and customer support.
Test like real customers will use it
M-Pesa testing should cover more than one successful transaction. Test correct phone numbers, wrong phone numbers, cancelled prompts, delayed responses, duplicate retries, low balance cases where possible, page refreshes, mobile switching and staff order review. The goal is to see how the store behaves when checkout is not perfect.
Also test the communication. Does the customer receive a clear confirmation? Does the order email make sense? Does the admin notification include the right details? Does the customer know delivery expectations after payment? Payment is only one piece of the order experience.
If the store runs campaigns, test before campaign traffic arrives. A payment problem during an advert push wastes spend and damages trust. It is cheaper to test calmly before launch than to troubleshoot while customers are trying to pay.
Security and customer data should be treated carefully
Payment integration touches sensitive customer and order information. The store should collect only what it needs, protect access to admin areas and avoid exposing payment details in careless logs or messages. Staff accounts should have appropriate permissions, and payment configuration should not be shared casually across email or chat.
Customers also need confidence that the checkout is legitimate. The website should use secure pages, clear business identity, consistent payment names and trustworthy confirmation messages. A buyer who is unsure whether the prompt belongs to the store may abandon payment or contact support before completing the order.
Security is not only a developer task. The business should define who can view orders, who can process refunds, who can change payment settings and who reviews suspicious activity. Payment trust depends on both code and operations.
Manual fallback should be planned, not improvised
Even a strong integration can meet edge cases: delayed confirmation, customer network issues, provider downtime or a customer who paid outside the normal checkout path. The business should have a manual fallback process so staff know what to do without confusing the customer.
A fallback process can include checking the payment reference, confirming the amount, marking the order manually, adding an internal note and sending the customer a clear update. This should not become the normal way the store operates, but it prevents support chaos when unusual cases happen.
The fallback should be documented before launch. If only one person knows how to resolve payment mismatches, the store becomes vulnerable whenever that person is unavailable.
Platform choice affects payment control
WooCommerce and custom ecommerce generally offer more flexibility for shaping payment status, checkout messages and order workflows. That can be useful for deeper M-Pesa integration. The business still needs responsible maintenance because payment plugins and custom code must stay compatible with the store.
Shopify may work when a supported payment provider or manual flow fits the business, but Kenyan sellers should confirm the route before committing. If the store needs a highly specific M-Pesa checkout or reconciliation process, platform constraints become important. Do not choose a platform first and discover payment limitations later.
The WooCommerce vs Shopify guide gives a broader platform comparison, including how payment control should influence the decision.
Reconciliation and reporting protect the business
Payment integration is not complete until the business can reconcile money and orders. Daily or weekly reporting should help answer which orders were paid, which failed, which need review and whether totals match expected settlement records. This protects the finance and operations side of the store.
Reconciliation does not have to be complex on day one, but it should exist. For a small store, an admin report and payment reference may be enough. For a growing store, exports, dashboards or accounting integration may become necessary. The right level depends on order volume and business risk.
Reporting should also help the team improve checkout. If many payments fail after prompts are sent, the issue may be instructions, phone number entry, customer timing or trust. If many orders stay pending, the status logic may need review. Payment data is useful for finance, but it also reveals friction in the customer journey.
- Show payment status clearly inside each order.
- Store payment reference details where available.
- Create a process for failed, pending and manually paid orders.
- Test the checkout on mobile before launch and before major campaigns.
- Review payment reports regularly so order and money records stay aligned.
Keep planning

