=== IvoryPay Payment Gateway ===
Contributors: ivorypay, ppmunga
Tags: payment, crypto, woocommerce, africa, fintech
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.2
License: MIT

Accept crypto and fiat payments in your WooCommerce store via IvoryPay Business.

== Description ==

Display crypto payment instructions or fiat payment details on the WooCommerce order payment page. IvoryPay verifies the payment on the server before marking the order paid.

Features:
* Crypto collection with wallet address, network and copy button
* Fiat collection with bank details or supported provider instructions
* Authenticated payment status checks and signed webhook confirmation
* One saved payment reference per order, including retries and lost responses
* WooCommerce High-Performance Order Storage (HPOS) support
* Classic checkout and Checkout Blocks support

Both checkout types use the same order payment page and verified payment confirmation. Automatic WooCommerce refunds are not implemented.

== Installation ==

1. Upload the built ivorypay ZIP using Plugins > Add New > Upload Plugin.
2. Activate the plugin with WooCommerce active.
3. Go to WooCommerce > Settings > Payments > IvoryPay.
4. Enter your IVB merchant Secret Key and select its Test or Live environment.
5. Select the payment type, crypto or settlement token, and crypto network.
6. Save changes. The order's currency is used for pricing. Fiat supports NGN bank transfer, ZAR EFT authorization, and the default IVB mobile-money currencies when enabled for your business. USD fiat needs a separate provider integration and is not offered by this plugin.
7. Configure the webhook below and verify a test payment before enabling live checkout.

The package preserves the public WordPress plugin basename ivorypay/ivorypay.php and gateway identity ivorypay_gateway. Existing 1.0.2 installations need WordPress 5.8+, PHP 7.4+ and WooCommerce 6.0+ before upgrading. Do not run this package alongside the older private ivorypay-payment-gateway package. Legacy unpaid payment references require reconciliation; order history and metadata are retained.

Public-key-only configurations from older versions must be updated with the merchant secret key. IVB keys use pk_ and sk_ prefixes; the prefix does not identify the environment. Use the key from the selected environment in your IVB dashboard.

== Webhook Setup ==

Set the webhook URL in the same business and environment in the IvoryPay dashboard:

    https://yoursite.com/?wc-api=ivorypay_webhook

Subscribe to cryptoCollection.success and fiatCollection.success for the payment types you accept. IVB signs the exact data JSON bytes using HMAC-SHA512 with that environment's merchant Secret API Key. The plugin verifies x-ivorypay-signature and checks current authenticated transaction state, order, merchant, environment, currency and amounts before completing an order. Browser polling also uses authenticated server requests and requires the private WooCommerce order key.

== Payment Recovery ==

Retrying checkout reuses the saved payment. A lost initiation response is reconciled against that same reference and the existing IVB allocation. The plugin never replaces the reference automatically. Do not delete payment metadata to force another payment.

ZAR EFT requires an HTTPS order payment URL and an enabled EFT method in IVB. The plugin requests a bound fiat quote and presents the returned IVB hosted bank authorization page. Direct provider POST forms and legacy hosted checkout fallbacks are not offered. Missing native EFT quote support is rejected before a payment reference is saved.

Crypto order totals are quoted from the order's fiat currency before token-unit initiation. Current IVB API crypto quotes are not bound atomically to admission. If returned totals differ from the saved quote, payment instructions and automatic completion are blocked for store-owner reconciliation. The original reference remains saved. Fiat rounding and crypto token precision differences are checked exactly.

Changes to order totals, currency, site URL, merchant keys or environment require reconciliation of existing unpaid orders. Older unpaid orders without the new verification binding also require review. Keep the original merchant and environment available until their payments are resolved. Completed orders retain their payment history.

== External Services ==

The plugin connects to https://api.ivorypay.io/api. It sends the order amount, currency, token/network, billing name, email and (for fiat when present) phone number to initiate a payment. Order metadata contains the order ID, a hash of the store URL, amount and currency. Crypto pricing uses the authenticated merchant quote API. Status checks, payment detail queries and recovery requests use the saved reference. The merchant Secret Key is used only in server-side authorization and webhook verification; it is never sent to the customer's browser.

This service is provided by IvoryPay Ltd:
* Terms of Service: https://www.ivorypay.io/legal/terms-of-service
* Privacy Policy: https://www.ivorypay.io/legal/privacy-policy

== Changelog ==

= 1.1.2 =
* Add Checkout Blocks with the existing payment, receipt and verification flow.
* Hide unavailable payment configurations and keep merchant credentials server-side.

= 1.1.1 =
* Require signed and authenticated payment confirmation bound to the order.
* Match current IVB API payloads and crypto pricing units.
* Connect payment instructions to the WooCommerce receipt page.
* Preserve references across retries and recover lost initiation responses.
* Restore package creation and add regression checks.

= 1.0.0 =
* Initial crypto and fiat collection implementation.
