Pay via ProxyAPI on WooCommerce

Hey All! We now have a new Plugin available for WooCommerce Clients and Admins backed by Proxy API!

The new plugin enables one to accept Lipa na M-Pesa payments on their WooCommerce sites powered by Woo Pay via ProxyAPI plugin. The plugin is integrated to use the PVP functionality introduced in the PVP API and this enables all payments made via the plugin to be initiated and completed automatically. That means the plugin also handles callbacks from Proxy API and updates the orders with the current transaction details at the back of it all.

Woo Pay via ProxyAPI (WPVP) Plugin does not keep a separate table for MPesa transactions. It receives and updates transaction results directly on the Order, allowing for a more convenient way to keep track of orders. All MPesa transactions are directly tied to their orders via the Transaction ID, which allows an Admin to easily see as soon as they open the order on their administration portals. A sample output is shown below:

Note the M-Pesa Transaction ID directly tied to the order on completion after the Payment Type description

WPVP also enables the transaction to be directly tied to its CheckoutRequest ID as received from LnM API, and one can use this to query the status transaction later if the transaction is not automatically updated within a few moments after a user responds to the Safaricom payment prompt. The callback also attaches any extra data received from Safaricom to the order. All this data is easily viewable from the order metadata as shown below:

Metadata of the transaction received from MPesa.

WPVP also has custom actions which a developer can take advantage of to initiate requests after either of three events have occurred:

  • When a payment request has been sent successfully to LnM API. This event is named ‘proxyapi_pvp_payment_pending‘ and has four parameters:
    • The orderId for the current order
    • A unique RequestID created by the Plugin for the current request
    • The MerchantRequestID and…
    • The CheckoutRequestID, both received from LnM API after sending the request
  • When a payment callback has been received, and the callback indicates a failure. The event is named ‘proxyapi_pvp_payment_failed‘ and has three parameters.
    • The orderId
    • The ResultCode and…
    • The ResultDesc, both received from LnM API when a transaction has failed.
  • When a payment callback has been received, and the callback indicates a success. The event is named ‘pvp_on_payment_complete‘ has only one parameter, the orderId of the successful request.

This events will allow you to hook into the payment process and perform any other events after the order has been updated accordingly. Some sample code on how to use the above hooks is available in the Plugin Repo on Github.

FYI, an order is automatically set to failed when an error code has been received from Daraja, and automatically set to completed when a transaction ID and confirmation callbacks have been received from either Daraja or Proxy API. There is no manual action needed for either of the two and no manual checks of transactions required either unless the transaction has not been updated for more than 5 minutes, indicating LnM API was unable to send an error callback back to the plugin.

Note that the Order Number is also used as the Account Reference when the LnM request is sent to M-Pesa. The user’s phone number is also mandatory, thus beware not to remove or skip the phone number field during checkout.

On top of it all, you also get the benefit of using Proxy API portal to confirm a transaction was sent and the callback also received if in doubt.

And v2.0.0 now has a new custom M-Pesa Report tab under reports to show you the latest received transactions from ProxyAPI.

A sample WooCommerce application showcase can be found here

For details how to on-board to Proxy API, check out the documentation

For a step-by-step process on how to onboard your Paybill or Till onto ProxyAPI, check out this detailed article written by one of our clients:

Get it on WordPress!

For all M-Pesa APIs consultation, contact Peter via

Pay Via Proxy API

Do you have an online business, store or website?

Do you have a Safaricom Till Number or Paybill Number?

Do you wish to integrate into M-Pesa or Lipa na M-Pesa and receive payment notifications automatically from your site?

Well, Proxy API has the right service for you!

We have developed a new integration named Pay via Proxy API that enables merchants and developers with online stores to easily integrate into Safaricom’s MPesa. The setup involves simply integrating a single button on your site that enables the client to initiate a Lipa na M-Pesa request from your site. By clicking on the button, a new window is opened, the client enters their phone number and an instant payment request is sent to their phone to complete the transaction. Simple, right?

Sample PVP LnM Request

This integration also combines Lipa na M-Pesa API and C2B API whereby the 3rd party/merchant or developer receives two callbacks: one from from Daraja and the other from Proxy API; or at least one callback from either, on successful completion of the request. This enables one to have more stability on their system and not have missing callbacks sometimes seen when using the Lipa na M-Pesa (LnM) API alone. This also means, for any unconfirmed callback, the 3rd party can check for the missing transaction on the Proxy API portal, similar to Query Checkout API on Daraja. This is a feature that will be integrated soon.

After initiating the request, the 3rd party can expect either one or both callbacks from Daraja or Proxy API. The callback from Proxy API comes from the C2B integration that will be automatically handled by Proxy API. This enables one to crosscheck both the LnM callback and Proxy API callback for the details of the transaction, whichever comes first.

Check out more info on the documentation available here.

Then begin onboarding here pap! 🙂