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:
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:
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: https://www.thebrands.co.ke/2020/09/13/integrate-m-pesa-to-woocommerce-free-plugin-and-a-step-by-step-guide/