=== Papi Payment Gateway for WooCommerce ===
Contributors: ibonia
Tags: woocommerce, payment gateway, mobile money, madagascar, papi, mvola, airtel money, orange money
Requires at least: 5.0
Tested up to: 6.7
Stable tag: 1.0.0
Requires PHP: 7.2
Requires Plugins: woocommerce
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept payments via Mobile Money (MVola, Airtel Money, Orange Money) and bank cards on your WooCommerce store using the Papi API.

== Description ==

**Papi Payment Gateway for WooCommerce** integrates the [Papi](https://papi.mg) payment platform into your WooCommerce store. It is designed for merchants in Madagascar and allows customers to pay using:

* MVola
* Airtel Money
* Orange Money
* Bank cards

When a customer places an order, they are redirected to a secure Papi-hosted payment page. Once the payment is completed, Papi sends a webhook notification back to your store to automatically update the order status.

**Features**

* Secure redirect to Papi-hosted payment page
* Automatic order status update via webhook (SUCCESS / FAILED / PENDING)
* Token-based webhook verification to prevent spoofing
* All settings managed from the WooCommerce Payments admin page
* Admin settings link directly from the plugin list

== Installation ==

1. Download the plugin as a `.zip` file.
2. In your WordPress admin, go to **Plugins → Add New → Upload Plugin**.
3. Upload the `.zip` file and click **Install Now**.
4. Click **Activate Plugin**.
5. Go to **WooCommerce → Settings → Payments** and click on **Papi Payment** to configure it.

Alternatively, you can upload the `papi-woocommerce-gateway` folder directly to your `/wp-content/plugins/` directory via FTP, then activate the plugin from the **Plugins** page.

== Configuration ==

= Payment gateway =

1. Navigate to **WooCommerce → Settings → Payments → Papi Payment**.
2. Enable the gateway using the **Enable/Disable** checkbox.
3. Enter your **Papi API key** (available from [dashboard.papi.mg](https://dashboard.papi.mg) under Boutiques → Developer).
4. Optionally customise the **Title** and **Description** that customers see at checkout.
5. Click **Save changes**.

= Webhook (notification URL) =

Papi will automatically call your store's notification URL when a payment status changes. This URL is generated automatically and requires no manual configuration. Make sure your store is publicly accessible (not behind a local or staging environment firewall) so Papi can reach it.

== Frequently Asked Questions ==

= Where do I get my Papi API key? =

Log in to [dashboard.papi.mg](https://dashboard.papi.mg), open your store, and go to **Developer**. Your API key is listed there.

= Does this plugin support sandbox / test mode? =

Not in the current version. A test mode toggle is planned for a future release. For now, use a dedicated test store on the Papi dashboard.

= What happens if a customer's payment fails? =

The order is automatically marked as **Failed** in WooCommerce. The customer is redirected back to the checkout page and can try again.

= What currency does this plugin use? =

The plugin is designed for the Malagasy Ariary (MGA). Amounts are passed as-is from WooCommerce to the Papi API, so make sure your WooCommerce store currency is set to MGA.

= Does the plugin work with the WooCommerce block-based checkout? =

Yes. The payment gateway works with both the classic checkout and the WooCommerce block-based checkout.

= What data is deleted when I uninstall the plugin? =

When you uninstall the plugin (delete it from the Plugins page), the following data is removed from your database:
- The gateway settings option (`woocommerce_papi_gateway_settings`)
- All Papi-related order meta (`_papi_payment_reference`, `_papi_notification_token`, `_papi_payment_link`, `_papi_merchant_reference`, `_papi_payment_method`)
- The notification log file (`wp-content/papi-notifications.log`)

Order records themselves are **not** deleted.

== Screenshots ==

1. Papi Payment settings page.
2. Papi Payment option at checkout.
3. Papi-hosted payment page (redirected).

== Changelog ==

= 1.0.0 =
* Initial release.
* Papi payment gateway integration (redirect flow + webhook).
* All settings unified on the WooCommerce Payments settings page.
* Block-based checkout (Cart & Checkout blocks) support.
