Installing the Papi WooCommerce plugin
The Papi WooCommerce plugin allows you to integrate the Papi payment aggregator into a WordPress WooCommerce store.
It allows you to accept payments by Mobile Money (MVola, Orange Money, Airtel Money) and by Visa and Mastercard cards in Madagascar.
Prerequisites
Before installing the plugin, check the following points:
- You are using WordPress 5.0 or later
- You are using WooCommerce 3.0 or later (tested up to 9.9)
- Your site uses PHP version 7.2 minimum
- You have created a store with Papi with a store API key
- Your WooCommerce store is configured to use the MGA currency (Malagasy Ariary)
Download the plugin
Download the official Papi WooCommerce plugin Zip file from the Downloads page.
Use the latest release unless Papi support has specifically asked you to install another version. The Downloads page lists official releases from newest to oldest, with each release's Zip file, SHA-256 checksum, compatibility notes, and changelog.
After downloading the file, keep it as a Zip archive. You do not need to unzip it before installing it from the WordPress back office.
Install the plugin from the WordPress back office
Installation by upload
- In the WordPress back office, open Plugins → Add New Plugin.
- Click Upload Plugin.
- Select the downloaded
papi-woocommerce-gateway.zipfile. - Click Install Now.
- Once the installation completes, click Activate Plugin.
- Go to WooCommerce → Settings → Payments and click Manage next to Papi Payment to configure it.
Manual installation via FTP
Use manual installation only if your WordPress back office cannot upload the plugin Zip file.
- Extract the downloaded
papi-woocommerce-gateway.zipfile on your computer. - Check that the extracted folder is named
papi-woocommerce-gateway. - Copy the
papi-woocommerce-gateway/folder into thewp-content/plugins/directory of your WordPress installation. - In the WordPress back office, open Plugins.
- Find Papi Payment Gateway for WooCommerce and click Activate.
Mandatory MGA currency configuration
Papi currently accepts payments only in Malagasy Ariary (MGA). If the WooCommerce store is not configured with MGA as the active currency, the Papi payment option will not appear at checkout.
Set MGA as the WooCommerce currency
- In the WordPress back office, open WooCommerce → Settings → General.
- In the Currency field, select Malagasy ariary (Ar).
- Save the settings.
Once MGA is selected, prices will be displayed in Ar on product pages and in the cart.
Plugin configuration
- In the WordPress back office, open WooCommerce → Settings → Payments.
- Click Manage next to Papi Payment.
- Fill in the required fields.
| Field | Description |
|---|---|
| Enable/Disable | Activate the Papi payment method at checkout. Disabled by default. |
| Title | The label the customer sees at checkout. Default: Paiement Mobile Money / Carte. |
| Description | The description shown below the payment option. Default: Payez par MVola, Airtel Money, Orange Money ou carte bancaire. |
| Papi API key | Your store API key from dashboard.papi.mg under Boutiques → Developer. |
| Default return URL | Optional, headless mode only. Front-end page where the customer returns after payment. Leave empty if the WordPress checkout is also used. |
| Allowed front origins | Optional, headless mode only. One front-end origin per line (for example https://shop.example.mg). Only return URLs on these origins are accepted, and these origins are allowed in CORS on the Store API. |
After saving, the Papi payment method is immediately available at checkout.
The last two fields belong to the Headless front (optional) section, available from version 1.1.0. Leave them empty if your store only uses the WordPress checkout. To connect a separate front end (Next.js, Nuxt, mobile application…), see Headless WordPress.
Papi webhook configuration
The webhook is the URL of your store called by Papi after each payment status change. This mechanism allows WooCommerce to automatically update the order status.
In production
The notification URL is generated automatically by the plugin and sent to Papi with every payment. No manual configuration is required, neither in WooCommerce nor in the Papi dashboard. The URL is displayed in the Headless front (optional) section of the gateway settings.
From version 1.1.0, the URL follows this format:
https://your-store.mg/?rest_route=/papi/v1/webhook
It is built on the WordPress Address (siteurl) setting, and works whatever the permalink structure. To force another URL, for example behind a reverse proxy, use the papi_gateway_notification_url filter (see PHP filters).
The legacy endpoint used by version 1.0.0 remains active for orders created before the update:
https://your-store.mg/?wc-api=wc_gateway_papi
The notification URL must be publicly accessible from the Internet. A local server, a server behind a VPN, or an environment that is not publicly exposed will not receive Papi notifications.
In local development
If WordPress is running locally, for example on http://localhost/my-store, Papi cannot directly call your machine.
Two approaches are possible.
Option A: ngrok tunnel
- Install and configure ngrok.
- Start a tunnel to your local port:
ngrok http 80
- Retrieve the public URL provided by ngrok, for example
https://abc123.ngrok-free.app. - Make the plugin send this public URL to Papi, for example with the
papi_gateway_notification_urlfilter in a must-use plugin:
add_filter('papi_gateway_notification_url', function () {
return 'https://abc123.ngrok-free.app/my-store/?rest_route=/papi/v1/webhook';
});
Option B: direct command-line test
To test webhook processing without going through Papi, retrieve a valid JSON payload and replay it directly to your local WordPress.
First retrieve the _papi_notification_token meta value for the order you want to test. You can find it in the WordPress database (wp_postmeta or wp_wc_orders_meta if HPOS is enabled) or directly from the WooCommerce order screen under Custom Fields.
Then send a test notification.
PowerShell example:
$body = '{"paymentStatus":"SUCCESS","merchantPaymentReference":"WC-123","notificationToken":"YOUR_TOKEN","paymentMethod":"MVOLA","currency":"MGA","amount":8000}'
Invoke-WebRequest -Uri "http://localhost/my-store/?rest_route=/papi/v1/webhook" `
-Method POST `
-ContentType "application/json" `
-Body $body
curl example:
curl -X POST "http://localhost/my-store/?rest_route=/papi/v1/webhook" \
-H "Content-Type: application/json" \
-d '{"paymentStatus":"SUCCESS","merchantPaymentReference":"WC-123","notificationToken":"YOUR_TOKEN","paymentMethod":"MVOLA","currency":"MGA","amount":8000}'
A 200 OK response with {"success":true} confirms the webhook was processed correctly.
Purchase flow verification
Before going live, test the full flow:
- Select a product and add it to the cart.
- Go to checkout.
- At the payment step, check that Papi Payment appears with the Papi logo.
- Select Papi Payment and click Place Order.
- Check that WooCommerce creates an order with the Pending payment status.
- Check the redirect to the Papi-hosted payment page.
- Complete a test payment on the Papi page.
- Return to the store and check the order confirmation page.
- After receiving the webhook, check that the order status changes to Processing or Completed in the WooCommerce back office.
Order statuses
| WooCommerce status | When | Notes |
|---|---|---|
| Pending payment | As soon as the customer is redirected to the Papi payment page | The cart is cleared at this point. |
| Processing | SUCCESS webhook received | Triggered by payment_complete(). WooCommerce may move to Completed automatically depending on your product settings. |
| Failed | FAILED webhook received | The order note contains the failure reason returned by Papi. |
| Pending payment (note added) | PENDING webhook received | The order status is unchanged; a note is added to indicate the payment is awaiting confirmation. |
Logs
The plugin writes all webhook events to the WooCommerce log system. Logs are accessible from WooCommerce → Status → Logs. Select the source papi-gateway from the dropdown.
| Log level | When |
|---|---|
info | Every incoming webhook notification (full payload). |
warning | Malformed notification received (missing required fields), or front-end return URL refused because its origin is not allowed (headless mode). |
error | Order not found for reference, or notification token mismatch. |
Log files are stored in wp-content/uploads/wc-logs/ and are rotated automatically by WooCommerce.
Technical points to watch
Payment link validity period
The Papi payment link is valid for 60 minutes after creation. If the customer does not complete payment within that time, the link expires. The order remains in Pending payment status and can be canceled manually from the WooCommerce back office.
Multiple orders on the same cart
WooCommerce creates the order and clears the cart before redirecting to Papi. If the customer abandons payment and returns to the store, the cart will be empty. The old order remains in Pending payment and can be manually canceled from the back office if necessary.
Block-based checkout
The plugin is fully compatible with both the classic WooCommerce checkout and the WooCommerce block-based checkout (Cart & Checkout blocks, default since WooCommerce 8+).
HPOS compatibility
The plugin is compatible with WooCommerce High-Performance Order Storage (HPOS / custom order tables). All order data is read and written using the WooCommerce order API.
Headless WordPress
From version 1.1.0, the plugin can also be used by a separate front end (Next.js, Nuxt, mobile application…) through the WooCommerce Store API, alongside the classic checkout. The front end sends its own return page with the order, and checks the payment status with the papi/v1/order-status endpoint. See Headless WordPress for the full integration guide.
No HTTPS in development
WooCommerce may display a warning when the store is not running over HTTPS. This does not prevent the Papi payment method from appearing at checkout in a development environment. In production, HTTPS is required.
Plugin structure
papi-woocommerce-gateway/
├── papi-woocommerce-gateway.php
├── uninstall.php
├── readme.txt
├── assets/
│ ├── logo-papi-full.svg
│ ├── zone.png
│ └── js/
│ └── blocks-checkout.js
├── docs/
│ └── HEADLESS.md
└── includes/
├── class-papi-blocks-support.php
└── class-papi-headless.php
| File | Role |
|---|---|
papi-woocommerce-gateway.php | Main plugin file. Declares the WC_Gateway_Papi payment gateway class, registers WooCommerce feature compatibility (HPOS, block checkout), and loads the block checkout and headless support. |
uninstall.php | Executed when the plugin is deleted from the WordPress back office. Removes all plugin options and order meta from the database. |
readme.txt | WordPress.org standard plugin readme. |
assets/logo-papi-full.svg | Papi logo displayed at checkout next to the payment method name. |
assets/zone.png | Delivery zone map image (reserved for a future release). |
assets/js/blocks-checkout.js | Registers the Papi payment method in the block-based checkout. |
docs/HEADLESS.md | Headless integration guide shipped with the plugin (French). |
includes/class-papi-blocks-support.php | Registers the gateway with the block-based checkout (Cart & Checkout blocks). |
includes/class-papi-headless.php | Headless support: front-end return URLs, allowed origins and CORS, and the papi/v1 REST routes (webhook, order-status, payment-method). |
Order meta keys
The plugin stores the following metadata on WooCommerce orders.
| Meta key | Description |
|---|---|
_papi_payment_reference | Merchant reference sent to Papi, in the format WC-{order_number}. |
_papi_notification_token | Security token returned by Papi when creating the payment link. Used to verify incoming webhooks. |
_papi_payment_link | URL of the Papi-hosted payment page. |
_papi_merchant_reference | Merchant reference confirmed in the SUCCESS webhook. |
_papi_payment_method | Payment method used by the customer (e.g. MVOLA, AIRTEL_MONEY, ORANGE_MONEY). |
Uninstallation
Uninstallation from Plugins → Installed Plugins → Delete performs the following operations:
- Deletion of the gateway settings (
woocommerce_papi_gateway_settingsWordPress option). - Deletion of all Papi-related order meta from the database (both the classic
wp_postmetatable and the HPOSwp_wc_orders_metatable if present). - Deletion of the
wp-content/papi-notifications.logfile, if present.
Deletion of order meta is irreversible. If the transaction history must be preserved, back up the relevant meta keys before uninstalling the plugin.