=== RedFace Pay for WooCommerce ===
Contributors: redfacesa
Tags: woocommerce, payments, redface, checkout, africa
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
WC requires at least: 7.0
WC tested up to: 9.0
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

WooCommerce checkout powered by RedFace Pay — one API, one merchant identity.

== Description ==

**RedFace Pay for WooCommerce** registers a payment gateway that creates Commerce API payment sessions and redirects customers to RedFace hosted checkout.

* Official RedFace plugin — same connection wizard as RedFace Pay
* Idempotent order payments (`wc-order-{id}`)
* Webhook + thank-you page sync completes WooCommerce orders
* HPOS compatible (custom order tables)
* Modules loaded: core, auth, payments, orders

Works alongside **RedFace Product Sync for WooCommerce** — shared merchant identity and API keys.

== Installation ==

1. Install and activate WooCommerce.
2. Upload `redface-pay-for-woocommerce` to `/wp-content/plugins/` and activate.
3. Complete **RedFace Pay → Connection** (Merchant ID + API key with payments scope).
4. Enable **WooCommerce → Settings → Payments → RedFace Pay**.
5. Register the webhook URL from plugin Settings in your RedFace Account.

== Configuration ==

* API key must include **payments** scope.
* Webhook secret must match RedFace Account webhook settings.
* Use sandbox mode until your Developer API plan is live.

== External services ==

This plugin connects to the **RedFace Commerce API** to create WooCommerce payment sessions and receive payment webhooks.

**What is sent and when**

* On checkout, the plugin sends your **Merchant ID**, **API key**, order total, currency, customer email, and order reference to create a hosted payment session.
* Webhooks confirm payment status back to your WooCommerce order.
* A connection test (`ping`) runs when you complete the connection wizard or test settings in wp-admin.

**Default API endpoint**

`https://bpzzgilwlkghgfkvkkxx.supabase.co/functions/v1/commerce-api`

Merchants may override the API base URL in plugin settings (e.g. for staging).

**Service provider**

RedFace (RedFace Pay), African commerce infrastructure.

* Terms of use: https://www.redfacepay.co.za/legal/terms
* Privacy policy: https://www.redfacepay.co.za/legal/privacy

== Frequently Asked Questions ==

= Does this store card data in WordPress? =

No. Checkout runs on RedFace; settlement uses licensed payment partners.

= How are orders marked paid? =

Primarily via signed webhook (`payment.success`). The thank-you page also polls the session once as a fallback.

= Does this replace WooCommerce? =

No. WooCommerce remains your storefront; RedFace handles hosted checkout and settlement.

== Troubleshooting ==

* **Gateway not visible** — confirm WooCommerce is active and the plugin Connection wizard is complete.
* **Orders stay pending** — register the plugin webhook URL in RedFace Account → Developers.
* **401 on checkout** — API key needs payments scope; verify Merchant ID matches your RedFace business.

== Support ==

Email support@redfacepay.co.za or visit https://wordpress.org/plugins/redface-pay-for-woocommerce/

== Screenshots ==

1. Connection wizard — Merchant ID and API key setup
2. WooCommerce payment gateway enabled in checkout settings
3. Overview — payments today and webhook status

== Changelog ==

= 1.0.2 =
* Text domain aligned with WordPress.org slug `redface-pay-for-woocommerce`.
* Tested up to WordPress 7.1.
* Directory listing icons removed from plugin package (upload via SVN assets after approval).

= 1.0.1 =
* Preserve API key and webhook secret characters during settings sanitization.
* Require a configured webhook secret and valid x-redface-signature HMAC on public webhook requests.

= 1.0.0 =
* Initial release — WooCommerce gateway, Commerce API client, webhooks, admin hub.
