=== HUCH for WooCommerce ===
Contributors: huchplugin
Tags: payment, woocommerce, payment-gateway, bank-transfer, open-banking
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 2.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept instant bank-to-bank payments in your WooCommerce store via HUCH Open Banking.

== Description ==

**HUCH for WooCommerce** adds the HUCH instant bank-to-bank payment gateway to your WooCommerce store. Customers pay directly from their bank account using Open Banking — no cards, no intermediaries, no card data stored.

= Why HUCH? =

* **Instant settlement** — payments are confirmed in real time
* **Lower transaction fees** — no card-network costs
* **Bank-grade security** — regulated Open Banking authentication
* **Reduced PCI-DSS scope** — no card data ever touches your server

= Features =

* Separate sandbox and production credential fields
* One-click **Test API connection** button in the settings page
* Automatic pending-payment status polling via WP-Cron (hourly fallback)
* Full WooCommerce refund support via the HUCH payout API
* Real-time payment status updates via signed webhooks
* Detailed order notes and WooCommerce log integration
* HPOS (High-Performance Order Storage) compatible
* Sandbox mode for development and QA testing

= Requirements =

* WordPress 5.8 or higher
* WooCommerce 6.0 or higher
* PHP 7.4 or higher
* An active HUCH merchant account (sandbox accounts available at huch.tech)

== Installation ==

1. In your WordPress admin go to **Plugins → Add New → Upload Plugin**.
2. Upload the plugin zip file and click **Install Now**, then **Activate Plugin**.
3. Go to **WooCommerce → Settings → Payments** and click **Manage** next to HUCH.
4. Enter your **Merchant ID** and the **Client ID / Client Secret** for each environment.
5. Select the active environment (**Sandbox** for testing, **Production** for live payments).
6. Click **Save changes**.
7. Register your webhook URL in your HUCH merchant dashboard (see FAQ).

= Obtaining your credentials =

Log in to your HUCH merchant dashboard, navigate to **API Settings**, and copy your:

* **Merchant ID** — shared across environments
* **Sandbox Client ID & Client Secret** — for test payments
* **Production Client ID & Client Secret** — for live payments

== Frequently Asked Questions ==

= Where do I get my API credentials? =

Log in to your HUCH merchant account at huch.tech and navigate to the API settings section to retrieve your Merchant ID, Client ID, and Client Secret for each environment.

= How do I test the integration before going live? =

Set the Environment to **Sandbox** in the plugin settings and enter your sandbox credentials. Use the **Test API connection** button to verify they are correct. No real transactions are processed in sandbox mode.

= What is my webhook URL? =

Your webhook endpoint is:

`https://yoursite.com/?woocommerce-api=wc_huch_webhook`

Register this URL in your HUCH merchant dashboard to receive real-time payment status updates. Replace `yoursite.com` with your actual domain.

= What currencies are supported? =

HUCH supports all currencies available in your WooCommerce store. The currency is passed automatically from the order at the time of payment.

= Are refunds supported? =

Yes. Full and partial refunds can be issued directly from the WooCommerce order screen. The refund is submitted automatically to the HUCH payout API and a confirmation note is added to the order.

= What happens if a payment fails? =

The customer is redirected back to the checkout page with an error message. The order remains in "Pending" status and no charge is made.

= What happens if my site misses a webhook? =

A WP-Cron job runs hourly and polls the HUCH API for any HUCH orders still in "Pending" or "On Hold" status, so payment statuses are reconciled automatically even if a webhook was not delivered.

= Is HPOS / High-Performance Order Storage supported? =

Yes. The plugin uses `wc_get_orders()` for all order lookups, which is fully compatible with both classic and HPOS order storage.

== External services ==

This plugin connects to the HUCH Open Banking API in order to initiate payments, retrieve payment statuses, process webhook notifications, and handle refunds.

Services used:

* Sandbox API: https://api-gateway-sandbox.huch.tech
* Production API: https://api-gateway.huch.tech
* Documentation: https://apidocs.huch.tech

Data transmitted may include:

* Order amount
* Currency
* Order reference
* Merchant identifier
* Customer email
* Billing information
* Payment metadata required for payment processing

Data is transmitted when:

* A customer places an order
* Payment status is checked
* A webhook notification is processed
* A refund request is triggered

Service provider: HUCH

Terms of Service: https://huch.tech/terms-of-use/
Privacy Policy: https://huch.tech/privacy-policy/

== Screenshots ==

1. Payment gateway settings page — sandbox and production credential blocks with environment toggle.
2. HUCH payment option at checkout with trust badges and sandbox mode notice.
3. HUCH secure bank selection interface after WooCommerce checkout.

== Changelog ==

= 2.0.1 =
* Added separate sandbox    and production credential fields
* Added one-time automatic credential migration for installs upgrading from 2.0.0
* Added Test API connection button in the settings page
* Added WP-Cron fallback to poll pending payment statuses hourly
* Added full and partial refund support via the HUCH payout API
* Improved admin settings layout with two-column credential blocks
* Improved webhook handling with idempotent order-status transitions
* Added HPOS-compatible order lookups via wc_get_orders()

= 2.0.0 =
* Initial public release
* OAuth2 client-credentials authentication with token caching
* Sandbox and production environments
* Real-time webhook payment status handler
* Debug logging via WooCommerce log system

== Upgrade Notice ==

= 2.0.1 =
Adds separate sandbox/production credentials, API connection test, hourly cron fallback for pending payments, and full refund support. Existing credentials are migrated automatically on first page load after upgrade — no manual steps required.
