SDKs and tools

LabPay for WooCommerce

WordPress plugin that adds Mobile Money payments (M-Pesa, Airtel Money, Orange Money) to WooCommerce, with no code: deposit, waiting page, signed webhook, refunds.

"LabPay for WooCommerce" plugin (labpay-for-woocommerce), version 0.1.0 (preview), built on the PHP SDK and API V2. Source code and full README: wordpress folder on GitHub.

ItemValue
RequirementsWordPress 6.4+, WooCommerce 8.0+, PHP 8.1+, shop currency CDF or USD
CompatibilityHPOS (order tables), block and classic checkout, "Pay for order" page
Gateway IDlabpay
LicenseGPL-2.0-or-later (bundled SDK and dependencies: MIT)

Installation#

Once published: Plugins › Add New › search for "LabPay for WooCommerce", install then activate.

Coming soon

This SDK is not published on WordPress.org yet: the command above will work once it is released. Until then, install it from the SDK GitHub repository, as shown below.

From the repository: build the plugin archive, then upload it in Plugins › Add New › Upload Plugin.

HTTP
git clone https://github.com/Labyrinthe-Team/labyrinthe-pay-packages.git
cd labyrinthe-pay-packages/wordpress
composer install            # outils, puis vendor-prefixed/ (SDK préfixé)
php bin/build-zip.php       # → dist/labpay-for-woocommerce.zip

Settings#

WooCommerce › Settings › Payments › LabPay (Mobile Money):

SettingRole
Enable, Title, DescriptionAs for any gateway.
Test modeUses the test key (test_…, sandbox); on by default.
API token (live), Test key, Signing secretStored encrypted; a test key is refused in the live field.
Reference prefixWC by default; change it if several shops share one token.
Debug logLogs every request (errors always are), without keys or full numbers.

Without HTTPS, no notification can be received: the waiting page and status refreshes still update the orders. The signing secret is read on GET /V2/account with the live token.

How it works#

  1. Checkout: the customer types their Mobile Money number (prefilled with the billing phone) and may pick their operator; otherwise it is detected from the number (POST /V2/predict-provider).
  2. Deposit: POST /V2/deposits with the order total and currency, reference = WC-<order>-<attempt>, metadata.wc_order_id and, on an HTTPS site, the plugin webhook as callback_url. The order stays "Pending payment".
  3. Waiting page: the confirmation page follows the payment (every 5 s, 10 min max); the server re-reads the status with POST /V2/payments/{id}/sync.
  4. Webhook: POST /wp-json/labpay/v1/webhook verifies X-Labyrinthe-Signature with the SDK and applies the status to the order.
  5. Refunds: a WooCommerce refund calls POST /V2/refunds on the paid deposit; a refusal (REFUND_IN_PROGRESS, DEPOSIT_NOT_COMPLETED…) cancels the WooCommerce refund with the error. Fees are not refunded.
  • An order is only paid when the amount and currency received match it; otherwise it is put "On hold" with a note.
  • Never a double payment: a double click, a network error or a retry reuses the same reference; a new attempt is only opened after a final failure.
  • A test order keeps using the test key even after switching to live.

Developer filters#

FilterRole
labpay_wc_base_url (or constant LABPAY_WC_BASE_URL)API root (/V2 is added).
labpay_wc_callback_urlNotification address sent with payments (null: none).
labpay_wc_referenceReference of an attempt (keep <prefix>-<order>- at the start).
labpay_wc_currenciesAccepted currencies (CDF, USD).
labpay_wc_http_clientPSR-18 client used by the SDK.

See also: all SDKs and tools, test mode and test numbers, notifications.