=== Libyan Payments for MyPay ===
Contributors: mypayly, mypay
Tags: woocommerce, payments, mypay, gateway, libya
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

WooCommerce payment gateway for MyPay local payments in Libya.

== Description ==

Libyan Payments for MyPay connects your store to the MyPay payment platform ([mypay.ly](https://mypay.ly)) so you can accept secure local payments across Libya.

This plugin allows merchants to accept payments directly on their WooCommerce store using Libya's local payment methods, including bank cards, Edfali, Sadad, Mobicash, Yaser Pay, Sahara Pay, Masrafi Pay, and optional prepaid card when enabled for your merchant in MyPay. Orders are confirmed using a signed webhook, not by relying on the customer's browser return alone.

= Key features =

* Seamless integration with WooCommerce and WooCommerce Blocks checkout
* Secure payment processing through MyPay hosted checkout
* Customizable payment gateway title and description
* Signed webhook verification using `X-MyPay-Signature`
* Alias gateways for supported MyPay payment methods
* Logging for troubleshooting

= Requirements =

* WordPress 6.5 or newer
* WooCommerce (from WordPress.org)
* PHP 7.4 or newer
* A MyPay merchant account with API credentials

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/libyan-payments-for-mypay` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Use the WooCommerce -> Settings -> Payments screen to configure the plugin.

== Configuration ==

1. Go to WooCommerce -> Settings -> Payments.
2. Click on "MyPay" to configure the gateway.
3. Enable the gateway by checking the "Enable MyPay Gateway" box.
4. Enter your MyPay Client ID and Secret ID from your MyPay merchant dashboard.
5. Use the environment switch:
   * Production = unchecked, which targets `/pay/api/v1`
   * Sandbox = checked, which targets `/pay/sandbox/api/v1`
6. Paste the Webhook Secret from your MyPay merchant dashboard.
7. Keep the generated Webhook URL configured in your MyPay merchant API settings.
8. Customize the title and description if desired.
9. Save changes.

== External services ==

This plugin connects to MyPay (https://mypay.ly) to process payments and synchronize merchant connection status when API credentials are configured. MyPay is required for checkout and order confirmation.

**What is sent and when**

* **Payment API** (`/authentication/token`, `/payment/create`): order amount, currency, billing name, email, phone, order ID, return/cancel/webhook URLs, and selected gateway alias when a customer pays.
* **Webhook** (incoming to your site): signed payment status payload from MyPay to finalize WooCommerce orders.
* **Connection sync** (`/plugin/connect`, `/plugin/disconnect`, `/plugin/heartbeat`): site URL, plugin/WP/WC versions, environment (production/sandbox), enabled gateway flags, and plugin active state when you save MyPay credentials or change gateway settings. This supports merchant setup verification on MyPay.
* **Optional health telemetry** (`/plugin/telemetry-consent`): only when you explicitly enable "Share optional plugin health data with MyPay" in gateway settings (disabled by default). No customer, order checkout payload, or admin personal data is included.

This service is provided by MyPay:

* Terms of Service: https://mypay.ly/page/terms-and-conditions
* Privacy Policy: https://mypay.ly/page/privacy-policy

== Production notes ==

* The plugin uses an embedded MyPay host and only needs the environment switch.
* The webhook secret in WooCommerce must match the webhook secret configured for the merchant key in MyPay.
* Alias gateways such as `yasr-pay`, `masrafi-pay`, `sahary-pay` (shown in the store as **Sahara Pay**), `moamalat` (shown as **Banking Card**), `edfali`, `sadad`, and `mobicash` must also exist and be enabled in the merchant gateway settings on MyPay.
* The `prepaid-card` alias requires prepaid card payments to be enabled for your merchant in MyPay.
* A customer returning from MyPay does not complete the WooCommerce order by itself; the signed webhook is the source of truth for final order completion.

== Privacy & tracking ==

* Payment processing requires MyPay API calls once credentials are saved (Software as a Service).
* Operational connection sync is sent when credentials are configured to support merchant setup on MyPay.
* Optional plugin health telemetry is **disabled by default** and can be enabled in WooCommerce -> Settings -> Payments -> MyPay.
* No customer checkout payload or admin personal data is sent as part of optional plugin health metadata.

== Frequently Asked Questions ==

= Where do I get API credentials? =

From your MyPay merchant dashboard at [mypay.ly](https://mypay.ly).

= Does this plugin work with WooCommerce Blocks checkout? =

Yes. MyPay and its alias gateways register WooCommerce Blocks payment method support.

= How does the plugin communicate with MyPay? =

Outbound API calls use the WordPress HTTP API (`wp_remote_post`).

== Changelog ==

= 1.0.7 =

* Restored production mypay.ly Author URI, API host, and Terms/Privacy links (removed local mypay.test URLs).

= 1.0.6 =

* Removed bundled Guzzle; all MyPay API calls now use the WordPress HTTP API.

= 1.0.5 =

* WordPress.org review updates: Tested up to only in readme; documented MyPay Terms and Privacy links.

= 1.0.4 =

* Renamed plugin to Libyan Payments for MyPay for WordPress.org trademark compliance.

= 1.0.3 =

* Verified webhooks before logging; WordPress.org directory compliance updates.

= 1.0.2 =

* Added alias gateways for Sadad (`sadad`) and Mobicash (`mobicash`), including Blocks checkout support and merchant documentation.
* Added optional plugin health telemetry opt-in (disabled by default) for WordPress.org compliance.

= 1.0.1 =

* Added optional alias gateway for prepaid card (`prepaid-card`), including Blocks checkout support and merchant documentation.

= 1.0.0 =

* Added operational plugin tracking for MyPay support and compliance workflows
* Documented server-side tracking and privacy expectations in the readme

= 1.0 =

* Initial release

== Upgrade Notice ==

= 1.0.7 =

Uses production mypay.ly URLs for Author URI, Terms, and Privacy links.

= 1.0.6 =

Removes bundled Guzzle and uses the WordPress HTTP API for all MyPay API calls.

= 1.0.5 =

Documentation and WordPress.org review compliance updates.

= 1.0.4 =

Plugin renamed to Libyan Payments for MyPay (permalink: libyan-payments-for-mypay).

= 1.0.3 =

Security and WordPress.org review updates for webhook handling.

= 1.0.2 =

Adds Sadad and Mobicash alias gateways. Optional telemetry is now opt-in and disabled by default.

= 1.0.1 =

Adds optional prepaid card alias gateway support.

= 1.0.0 =

Maintenance and documentation updates.

== Credits ==

Developed by MyPay - https://mypay.ly
