WOOCOMMERCE · M-PESA · KENYA

WooCommerce M-Pesa payments for Kenyan stores

Payment Gateway Kenya is a payment gateway for M-Pesa pay-ins, plus payouts where confirmed for your account, and your WooCommerce store can connect to it by API (H2H) or a Hosted Payment Page. Postbacks send transaction status to your store so your team can update each order with a clear rule.

If you run a WordPress and WooCommerce shop in Kenya, you need two things from an M-Pesa connection. Customers must be able to pay in KES at checkout, and each order must end up in the right status without anyone checking statements by hand. This page explains how that works with Payment Gateway Kenya. For the payment method itself, see our M-Pesa payments page.

WooCommerce M-Pesa illustration
Method in Kenya:
M-Pesa only, for customer pay-ins at checkout.
Two connection routes into the same gateway:
API (H2H) or Hosted Payment Page.
Postbacks send transaction status to your store, so you can move orders to the correct status.
Plugin availability:
we do not promise a WooCommerce plugin or app. Confirm the current options with our team before you plan your build.

Two ways to connect WooCommerce to M-Pesa

API (H2H) and the Hosted Payment Page are two ways into the same gateway. They are not separate products. The right choice depends on who will build and maintain the checkout step on your WooCommerce site.

API (H2H)

Your WooCommerce site talks to the gateway directly from your server. Your developer builds the payment step, stores the API credentials server-side and handles postbacks in your own code. H2H is not white-label, so plan your checkout wording with that in mind.

Hosted Payment Page

Your store sends the customer to a hosted payment page to complete the M-Pesa payment, then the customer returns to your site. Less of the payment step lives in your theme or custom code. You still receive postbacks to update the WooCommerce order.

Choosing a connection route for WooCommerce
QuestionAPI (H2H)Hosted Payment Page
Where the payment step runsIn your own server codeOn a hosted page your store redirects to
Developer effort on your sideHigher: request, response and postback handlingLower: redirect, return and postback handling
Postbacks with transaction statusYes, to your endpointYes, to your endpoint
Gateway behind itSame gatewaySame gateway

What to confirm before you connect

Agree on these points with our team and your developer before any code reaches your live store. It avoids orders stuck in the wrong status after launch.

  1. Which route you will use: API (H2H) or Hosted Payment Page.
  2. Whether you only need M-Pesa pay-ins, or whether payouts to customers are also confirmed for your account.
  3. What plugin or integration options exist for WooCommerce today. Confirm this with our team rather than assuming.
  4. The public URL on your store that will receive postbacks, and how your code will verify them.
  5. How each transaction status maps to a WooCommerce order status, such as Pending payment, Processing, Failed or On hold.
  6. Who on your team can access API credentials and the merchant dashboard. Use MFA and role-based access, and keep credentials out of your theme files.
  7. How customers will be told about their order. Postbacks go to your store, not to your customers, so use your WooCommerce emails or your own messaging.
  8. How settlement works for your account. Merchant settlements are sent on the same day (T+0). This is a separate flow from customer pay-ins and payouts.
  9. Commercial terms. Pricing is custom, so see our pricing page and talk to sales.

Illustrative flow: postbacks and WooCommerce order status

Illustrative flow. The exact sequence, field names and statuses are confirmed during onboarding. Safaricom's Daraja documentation describes M-PESA Express (Lipa na M-PESA Online) as a prompt-style request started by a business, often called 'STK Push' in the market. Ask our team how the payment request will appear to your customers.

  1. 1. Customer places the order

    WooCommerce creates the order in Pending payment, with the total in KES and a unique order reference.

  2. 2. The M-Pesa pay-in starts

    With API (H2H), your server sends the payment request. With the Hosted Payment Page, your store redirects the customer to the hosted page.

  3. 3. Customer completes the payment

    The customer approves the M-Pesa payment on their phone. On the Hosted Payment Page route, they then return to your store.

  4. 4. A postback reaches your store

    The gateway sends the transaction status to your postback URL. Treat this postback as the source of truth, not the customer's return to your thank-you page.

  5. 5. Your store updates the order

    Your code verifies the postback, checks the order reference and KES amount, then moves the order to Processing, Failed or On hold for review. Repeat postbacks for an order already paid are acknowledged and ignored.

  6. 6. Settlement runs separately

    Merchant settlements are sent on the same day (T+0). Settlement is its own flow, separate from the customer's pay-in and from any payouts.

Developer note: handling postbacks in WooCommerce

The sketch below shows the logic your WordPress code needs, not a published plugin or SDK. Keep API credentials on the server only, verify every postback, and make the handler safe to run more than once for the same order. For a wider view of API work, read our M-Pesa API guide for Kenya.

Conceptual PHP: WooCommerce postback handler
// Conceptual only - not a published plugin or SDK
add_action('rest_api_init', function () {
  register_rest_route('store/v1', '/paygate-postback', [
    'methods' => 'POST',
    'callback' => 'handle_paygate_postback',
    'permission_callback' => '__return_true',
  ]);
});

function handle_paygate_postback(WP_REST_Request $request) {
  // 1. Verify the postback using the method agreed at onboarding
  if (!verify_postback($request)) {
    return new WP_REST_Response(null, 401);
  }

  $data  = $request->get_json_params();
  $order = wc_get_order($data['merchant_reference']); // placeholder field
  if (!$order) {
    return new WP_REST_Response(null, 404);
  }

  // 2. Repeat postback for a paid order: acknowledge and stop
  if ($order->is_paid()) {
    return new WP_REST_Response(null, 200);
  }

  // 3. Check the KES amount before changing status
  if ((float) $data['amount'] !== (float) $order->get_total()) {
    $order->update_status('on-hold', 'Amount mismatch - review');
  } elseif ($data['status'] === 'success') {
    $order->payment_complete($data['transaction_id']);
  } elseif ($data['status'] === 'failed') {
    $order->update_status('failed', 'M-Pesa payment not completed');
  }

  return new WP_REST_Response(null, 200);
}

Conceptual example only. Field names, status values, verification method and endpoints are placeholders and will be confirmed with our team during onboarding. Test on a staging site before going live.

WooCommerce M-Pesa FAQ

Short answers to the questions WooCommerce store owners and developers ask most often. If your question is not covered, ask our team.

Is there a Payment Gateway Kenya plugin for WooCommerce?

We do not promise a plugin, app or automatic install. Ask our team what integration options are available for WooCommerce today. Otherwise, your developer can connect through API (H2H) or the Hosted Payment Page.

Which payment methods can my WooCommerce store accept in Kenya?

In Kenya, the supported method is M-Pesa. This page covers M-Pesa pay-ins at checkout, plus payouts where they are confirmed for your account.

What is the difference between API (H2H) and the Hosted Payment Page?

They are two ways into the same gateway. With API (H2H), the payment step runs from your own server code. With the Hosted Payment Page, the customer is redirected to a hosted page to pay. H2H is not white-label.

Do postbacks notify my customers that they have paid?

No. Postbacks send transaction status to you, the merchant, so your store can update the order. Use your WooCommerce order emails or your own messaging to inform customers.

What happens if the same postback arrives more than once?

Build your handler so it is safe to run repeatedly. If the order is already marked as paid, acknowledge the postback and make no further changes. This prevents duplicate stock reductions or emails.

When are my funds settled?

Merchant settlements are sent on the same day (T+0). This describes when settlement is sent, not when funds are credited to your account. Settlement is a separate flow from customer pay-ins and payouts.

How much does a WooCommerce M-Pesa connection cost?

Pricing is custom, so talk to sales for your terms. Existing merchants can add supported payment methods at no extra connection fee, and the number of enabled methods does not change the connection price.

I also sell on Shopify. Does the same approach apply?

Shopify works differently. Kenya was not on Shopify's official Shopify Payments country list when checked on 5 November 2026, and we do not promise any third-party app. See our Shopify M-Pesa page for details.

Ready to add M-Pesa to your WooCommerce store?

Tell us about your store, your preferred connection route and whether you need payouts. We will confirm what is available for your account and what your developer needs to build. Start on our get started page, or review pricing and talk to sales.

Running Shopify as well? Read our Shopify M-Pesa page for that platform.