
Testing M-PESA STK Push Callbacks Locally Without Exposing Your Server
If you've ever built an M-PESA STK Push integration, you've probably hit this wall: M-PESA needs a publicly accessible callback URL to send payment confirmations, but your app is running on localhost. How do you test this without deploying every single time? In this guide I'll show you a simple approach using webhook.site and a small Node.js poller script that automatically forwards M-PESA callbacks to your local machine. What We're Building When a user completes an STK Push payment, M-PESA sends a POST request to your callback URL with the payment result. Normally that URL has to be publicly accessible. Since localhost isn't public, we'll use webhook.site as a middleman — it catches the callback from M-PESA, and our poller script picks it up and forwards it to our local app automatically. The flow looks like this: M-PESA → webhook.site → our poller script → localhost Prerequisites Node.js installed on your machine Your Laravel app running locally An M-PESA Daraja API account (sandbox
Continue reading on Dev.to JavaScript
Opens in a new tab


