Smart World Kenya Tech Store
M-Pesa-Integrated Electronics E-Commerce Platform
E-commerce platform for electronics and smart devices tailored for Kenya, featuring M-Pesa mobile payment integration, product filtering, and dispatch tracking. Handles the operational realities of mobile-money callback delivery being unreliable.
Architecture & System Design
Checkout initiates an M-Pesa Daraja STK push, with an idempotent callback handler and a scheduled reconciliation job covering any callbacks that never arrive. Dispatch status is surfaced to customers through webhook-driven order updates.
- M-Pesa Daraja STK Push integration with idempotent, verified callback handling
- Scheduled reconciliation job for transactions with missing or delayed callbacks
- Faceted product filtering across category, brand, and price attributes
- Webhook-driven dispatch tracking surfaced directly on the order page
Engineering Challenges
Unreliable M-Pesa Callback Delivery
M-Pesa callback delivery is not guaranteed, occasionally leaving payments in an unconfirmed state despite the customer being charged.
Built a polling fallback alongside the idempotent callback handler, plus a scheduled reconciliation job that queries transaction status directly when callbacks don't arrive.
Payment confirmation reliability improved to 98.5% of transactions.
STK Push Timeout & Cancellation UX
Customers frequently missed or cancelled the STK push prompt on their phone, leaving checkout stuck with no clear feedback.
Implemented real-time status polling on the checkout page with timeout detection and a one-tap retry prompt.
Checkout abandonment at the payment step was noticeably reduced.
Order Visibility for Customers
Customers had no visibility into dispatch status after payment, generating a high volume of support inquiries.
Wired dispatch status webhooks directly into the order detail page with real-time status updates.
"Where is my order" support tickets dropped by roughly 50%.
Core Features
M-Pesa STK Push Checkout
Mobile-money checkout with idempotent callback verification and status reconciliation.
Clean Code
1<?php23namespace App\Services;45use Illuminate\Support\Facades\Http;67class MpesaStkService8{9 public function push(string $phone, float $amount, string $orderRef): array10 {11 $timestamp = now()->format('YmdHis');12 $password = base64_encode(13 config('mpesa.shortcode') . config('mpesa.passkey') . $timestamp14 );1516 return Http::withToken($this->accessToken())17 ->post(config('mpesa.stk_url'), [18 'BusinessShortCode' => config('mpesa.shortcode'),19 'Password' => $password,20 'Timestamp' => $timestamp,21 'TransactionType' => 'CustomerPayBillOnline',22 'Amount' => $amount,23 'PartyA' => $phone,24 'PartyB' => config('mpesa.shortcode'),25 'PhoneNumber' => $phone,26 'CallBackURL' => route('mpesa.callback'),27 'AccountReference' => $orderRef,28 ])->json();29 }30}