=== Myagency Pay ===
Contributors: myagency
Tags: woocommerce, payment gateway, mvola, orange money, airtel money, myagencypay
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
WC requires at least: 6.0
WC tested up to: 9.0
Stable tag: 3.0.0
License: GPLv2 or later

Accept MVola, Orange Money, Airtel Money and card payments through MyAgencyPay's
hosted payment page, with HMAC-signed Payment Intents. Architecture confirmed against
MyAgencyPay's official PrestaShop module and OpenAPI 3.1 specification.

== How it works ==

1. Customer places the order → `POST /api/payment-intents` is called (HMAC-signed with
   your store key, full JSON body) and returns a `pi_...` uid plus a `url_pay` URL.
2. The customer is redirected to `url_pay` — MyAgencyPay's own hosted page — where they
   choose MVola / Orange Money / Airtel Money / Card and complete payment. WooCommerce
   does not collect phone numbers or card details directly.
3. MyAgencyPay redirects the browser back to your site's `success_url` or `failed_url`
   (registered as `/wc-api/wcmmg_return/?result=...`).
4. On return, the plugin **always re-verifies** via `GET /api/payment-intents/{uid}`
   before trusting the result (the query string alone is never trusted) and updates the
   order accordingly.
5. If the status is still pending at that point, the order-received page polls every few
   seconds until it resolves.
6. The order admin screen has a "Check status via API" button and a "Force mark as paid"
   manual override.

== Status codes (confirmed) ==

PaymentIntent.status: `1`=init, `2`=pending, `3`=success, `4`=failed, `5`=cancelled, `6`=expired
PaymentTransaction.status: `1`=pending, `2`=success, `3`=failed

== Configuration ==

WooCommerce > Settings > Payments > MyAgencyPay:

* **API base URL** — `https://api-pay.mypreprod.xyz` for sandbox.
* **Store key** — `pk_sandbox_...` / `pk_live_...`; the mode is determined by which
  prefix you use.
* **JWT token** (optional) — only needed for `/api/payment-transactions/{uid}` detail lookups.
* **Currency** — defaults to `MGA`.

== Notes ==

* The `customer` field sent to the API is the order's billing email by default.
  Override with the `wcmmg_customer_id` filter if MyAgencyPay expects a different
  identifier format for your account.
* An inline (non-redirect) flow is possible via `POST /api/payment-transactions`
  (collecting operator + phone directly on your site) — the API client supports this
  (`WCMMG_Api_Client::create_transaction()`) but it is not wired into the checkout flow,
  since the confirmed reference implementation uses the hosted redirect instead.

== Changelog ==

= 3.1.0 =
* Code quality pass: PSR-ish autoloader, centralized constants (no more magic
  strings for meta keys/option names), typed method signatures, proper
  WCMMG_Plugin bootstrap class instead of loose global functions, uninstall.php,
  PHPCS ruleset (WordPress Coding Standards) + composer.json for linting.
* Fixed: the API client no longer writes to the options table on every single
  page load (a leftover `update_option()` call in the gateway constructor).

= 3.0.0 =
* Corrected to match the confirmed MyAgencyPay API contract (field names success_url/
  failed_url, full-body HMAC signature, hosted url_pay redirect flow, confirmed status codes).
* Added WooCommerce Blocks (Cart/Checkout block) payment method registration —
  required for the gateway to appear on sites using the block-based checkout.

= 2.0.0 =
* Real API integration (inline flow, later found to not match the actual API contract).

= 1.0.0 =
* Initial release (manual transaction-reference verification, no live API).
