M-Pesa Daraja Integration
Full guide to connecting your Safaricom Daraja Paybill to Jasiyo — credentials, callback registration, C2B, STK Push, and troubleshooting.
The Daraja integration connects your Safaricom Paybill directly to Jasiyo. When customers pay using their unique account number, Safaricom sends a real-time notification to Jasiyo which automatically renews their subscription and re-enables them on the router.
Getting your Daraja credentials
You need four things from Safaricom:
| Credential | Where to find it |
|---|---|
| Consumer Key | developer.safaricom.co.ke → My Apps → your app → Consumer Key |
| Consumer Secret | developer.safaricom.co.ke → My Apps → your app → Consumer Secret |
| Shortcode (Paybill) | Your Safaricom business account — the 5-7 digit Paybill number |
| Passkey | Provided by Safaricom when they activate C2B on your Paybill. Contact your Safaricom account manager if you don't have it. |
Setup in Jasiyo
Go to Payments
In your ISP dashboard, go to Settings → Payments.
Click Connect M-Pesa (Daraja)
Click the M-Pesa Daraja card to open its form. Each gateway carries a status chip — Active for the one currently collecting, Configured for one that has credentials saved but is not in use.
Enter your credentials
Fill in Consumer Key, Consumer Secret, Shortcode (Paybill number), and Passkey.
Leave Sandbox mode OFF for live payments. Only enable sandbox when testing with Safaricom's test credentials.
Set your Account Reference
The Account Reference is the label customers see when they initiate STK Push. Set this to your business name (e.g. FastNet Internet). For C2B payments, customers use their unique JSY-XXXXXX account code as the reference.
Save
Click Save. Your credentials are encrypted and stored securely.
Register the callback URL
After saving credentials, click Register Now. This makes an API call to Safaricom to register Jasiyo's webhook URL with your Paybill. Without this step, Safaricom won't know where to send payment notifications.
Jasiyo registers the following callback URL with Safaricom:
https://www.jasiyo.com/api/admin/mpesa/callback
Customer account numbers
Every customer in Jasiyo has a unique account number (e.g. JSY-A1B2C3). When customers pay to your Paybill, they enter this as the account reference.
Jasiyo uses this reference to match the incoming M-Pesa payment to the right customer. You can find a customer's account number on their profile page.
STK Push
STK Push sends a payment prompt directly to a customer's phone. To use it:
You do not send the prompt yourself — there is no STK button in the dashboard. The prompt is triggered by the customer, in one of two ways:
- Expand the customer's row on the PPPoE page and copy their Payment Link
- Send it to them — it opens a payment page carrying their own account code
- They enter their phone number and amount, and get the M-Pesa prompt
- They enter their PIN and approve
- Jasiyo receives the callback and renews their subscription
Hotspot customers need none of this: STK Push runs on the captive portal itself, so they pay without you being involved at all.
Troubleshooting
⚠ Callback registration fails
Ensure C2B v2 is activated on your Daraja app. Check Consumer Key and Secret are correct (no extra spaces). Try switching to sandbox, registering, then switching back to production.
⚠ Payments are not showing up in Transactions
Check the callback is registered (green status in Payments page). Verify customers are paying to the correct Paybill using their exact JSY-XXXXXX account code. Check Jasiyo's Alerts page for any webhook error notifications.
⚠ STK Push times out or fails
Ensure the customer's phone number is correctly formatted (2547XXXXXXXX). STK Push requires the phone to be on and have M-Pesa active. Check your Daraja app has STK Push (Lipa Na M-Pesa Online) activated.
⚠ Customer paid but wasn't renewed
Check Transactions — does the payment appear? If yes, check if the account reference matches a valid customer account number. Unmatched payments (wrong account code) appear in Transactions with 'Unmatched' status.
