Installation and testing
Set up Daraja STK Push in WooCommerce
Install the free Gateway, run a sandbox payment and check that WooCommerce can update the order before you accept live payments.
Install Duka Relay Gateway
On a staging store with WooCommerce active, set the store currency to Kenyan shillings (KES). Use whole-shilling totals between KSh 1 and KSh 250,000.
In WordPress, choose Plugins → Add New Plugin → Upload Plugin. Upload and activate the Gateway ZIP, then open WooCommerce → Settings → Payments → M-Pesa STK Push.
On a store upgrading from Duka Relay 0.2, replace the existing plugin in place so WordPress keeps the same plugin directory and entry point.
Connect the Safaricom Daraja sandbox
Enable M-Pesa and select Daraja sandbox. From your Safaricom Daraja account, use the sandbox consumer key, consumer secret, provisioned shortcode and STK passkey. Select Paybill or Buy Goods for the provisioned account and enter the receiving number if it differs from the shortcode.
Keep sandbox and live credentials separate. Enter secrets in the store’s payment settings and restrict access to its WordPress database and backups.
Check that Daraja can reach your store
Daraja sends the payment result to a callback URL on your WordPress site. Use a publicly reachable HTTPS address. If you’re testing through a tunnel, set Public store URL for callbacks to the tunnel’s HTTPS address.
If the store sits behind a CDN or firewall, allow POST requests to the WordPress REST callback route and preserve their bodies and query strings. Keep callback URLs out of shared logs or unredacted screenshots.
Run a successful and a declined payment
Choose M-PESA at checkout. Confirm that sending a prompt leaves the order unpaid, then check that a successful result updates the order once. For a declined payment, review the order notes and check the shopper’s retry option on a payable order.
With Checkout Blocks, keep the Additional Information block in the Order Confirmation template so WooCommerce can show the M-PESA payment status panel.
Switch to live credentials and test again
Use the live environment, live credentials and a provisioned Paybill or eligible Till on your public HTTPS store. Run a small controlled payment and check the receipt, inventory and fulfilment state against the merchant’s M-PESA records.
If an order stays pending, run Check M-Pesa payment status from WooCommerce order actions. Read the order notes and compare any conflicting details with merchant records before fulfilling the order.