M-Pesa paybill setup and go-live
Connect your Safaricom paybill to Metron: credentials, Save and test, register C2B URLs, the go-live check and what to do when Safaricom already holds URLs.
Without a paybill, payments cannot post. Do this before you tell customers to pay.
What you need from Safaricom#
- Your paybill (shortcode)
- Daraja API consumer key and consumer secret
- The passkey for STK push
- Whether you are on sandbox or production
Add the paybill#
- Open SettingsIntegrations Console (or SettingsM-Pesa / Daraja).
- Add a connection of kind M-Pesa Paybill.
- Enter the shortcode, consumer key, consumer secret, passkey and environment.
- Choose which branches it serves, or make it your default.
- Press Save & test. Metron signs in to Daraja with your key and secret. The passkey is only shape-checked, because it can only be proven with a real STK prompt.
The connection should show Working.
Register the C2B URLs#
C2B URLs tell Safaricom where to send payment notifications.
- On the paybill connection, press Register C2B URLs.
- Expected result: "C2B URLs registered".
The URLs end in a key specific to your paybill. A payment is accepted only if it arrives through them.
If Safaricom says it already holds URLs#
Safaricom kept older URLs for this shortcode. If the paybill was used with another system, email apisupport@safaricom.co.ke from the paybill owner's address and ask them to change the Confirmation and Validation URLs to the two shown on screen.
A payment that arrives without a valid key#
It is held, not credited and not lost. The customer is never bounced at the till. A critical event is raised and the finance check "C2B inbox drained" fails until someone resolves it. If it was a real payment, confirm it against your M-Pesa statement. If nobody paid, it was a forgery and nothing happened.
Test it#
Several paybills#
You can connect more than one, for example one per branch. Each payment resolves to its owner from the shortcode Safaricom sends. A shortcode that no ISP owns is refused and held for a person to resolve.
If payments are not arriving#
- Is the paybill Working? Open the failure details.
- Credentials rejected: edit, paste the new key and secret, Save & test, then Register C2B URLs again.
- STK push fails with "integration not configured": the branch has no paybill and you have no default. Set one.
- Payments missing from the ledger: look for unverified or failed items in the inbox. See Unassigned payments and exceptions.