=== PayCryptoHost Bitcoin Payments ===
Contributors: paycryptohost
Tags: bitcoin, payments, woocommerce, crypto, xpub, btc, donations, invoices
Requires at least: 5.8
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept Bitcoin payments instantly using xPub-generated addresses, automated invoices, and secure blockchain verification powered by PayCryptoHost.

== Description ==

PayCryptoHost Bitcoin Payments connects WordPress and WooCommerce to the PayCryptoHost API to accept Bitcoin payments using unique xPub-derived addresses per order, invoice, donation, or subscription renewal.

= Features =
* WooCommerce gateway: Pay with Bitcoin (PayCryptoHost)
* xPub Manager with verification and test address generation
* Unique receiving address per order — no address reuse
* Live USD/BTC exchange rate
* QR code, countdown timer, automatic confirmation polling
* Donation shortcode [paycryptohost_donation]
* Pay button shortcode [paycryptohost_pay amount="100"]
* Invoice shortcode [paycryptohost_invoice id="..."]
* Subscriptions support (WooCommerce Subscriptions)
* Admin dashboard with revenue, BTC totals, conversion rate
* Transactions, customers, logs, settings
* Secure REST webhook with HMAC signature verification
* CSV export, PDF-ready invoice template
* Dark Mode + Light Mode, mobile responsive

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install via the Plugins page.
2. Activate the plugin.
3. Go to PayCryptoHost → Settings and add your API Key, Secret Key, and Merchant ID.
4. Go to PayCryptoHost → xPub Manager and add + verify your Blockchain.com xPub.
5. (WooCommerce) Enable "Pay with Bitcoin (PayCryptoHost)" under WooCommerce → Settings → Payments.

== Frequently Asked Questions ==

= Do you store private keys? =
No. Only the public xPub is stored. Private keys, seed phrases, and recovery phrases are never sent to or stored by the plugin.

= What about confirmations? =
Required confirmations are configurable in Settings. The plugin polls the PayCryptoHost API every minute and also receives instant webhooks.

== Changelog ==

= 1.7.0 =
* Fixed: payments already confirmed on the blockchain no longer stay on "Pending Payment" on the website, payment page, invoices or transactions.
* New PCH_Verify engine is the single source of truth: the invoice, transaction record, WooCommerce order and customer payment page all render the same verified status.
* Statuses are now verified against live blockchain data before anything is marked paid: real transaction, correct coin/network, invoice's own receiving address, amount received and required confirmations.
* Customer payment page shows "Payment Completed" with amount received, coin/network, transaction hash, confirmations, payment date and an explorer link; "Payment Confirming" while waiting for blocks.
* Underpaid protection kept and made explicit: short payments show "Underpaid", hold the order and are never completed. Wrong network, wrong address, invalid transactions and duplicate transactions are never completed either.
* Status updates run automatically from webhooks plus an authenticated poller that forces a fresh blockchain re-check, so the customer does not have to refresh.
* Webhook payloads are no longer trusted for status; every event triggers a live re-verification.
* Transactions and Invoices screens deduplicated: Invoices shows order/customer/amount, Transactions shows blockchain data only.
* If the blockchain/API is unavailable, nothing is marked as completed.

= 1.6.0 =
* Fixed confirmed payments remaining Pending when a store firewall blocks incoming webhooks.
* The built-in authenticated poller now always reconciles local invoice and WooCommerce order status.
* Webhooks accept both the current nested payload and older flat payloads.
* WooCommerce orders move to Processing on detection and Completed after final confirmation.

= 1.5.1 =
* Record the actual coin and network used for each payment on the linked WooCommerce order (meta + order note), instead of always showing Bitcoin.
* WooCommerce status transition now flows through payment_complete() so virtual/downloadable orders auto-complete and physical orders go to processing per the store's own WooCommerce setup.
* Webhook + pollers now forward coin, network, and amount_received from the platform.

= 1.4.6 =
* Gateway label renamed to "Pay with PayCryptoHost.com" with the brand logo shown at checkout for stronger trust and recognition.
* Confirming animation now renders inline directly below the QR / address instead of overlaying them, so the QR and amount remain visible and copyable while the network confirms.

= 1.4.5 =
* Multi-coin checkout in WooCommerce: invoices now offer every coin the merchant has enabled + approved (BTC, USDT/TRC20, ETH, BCH, LTC, SOL, XMR, BNB).
* Live "Confirming…" animation on the invoice the moment a transaction is detected on-chain.
* Payment UI auto-locks (copy buttons, address, coin tabs) once a payment is detected or confirmed — prevents double-pay.
* Optional "Notify me by email" form on the invoice so customers can subscribe to the payment-confirmed email.
* Local invoice REST endpoint now proxies live payment_state + confirmations from PayCryptoHost.


= 1.0.0 =
* Initial release.

== Changelog ==

= 1.5.1 =
* Wording: detection panel now reads "We're scanning for your payment" for clearer scanning/confirmation messaging.

= 1.4.8 =
* Wording: clear "Waiting for you to submit payment" state until a transaction is actually detected on-chain.
* Notify form hides on submit and replaced with a confirmation note.
* On detection the payment area (QR/address/amount/coin tabs) is hidden and replaced by "We're scanning for your payment".
* On confirmation we show the invoice number, what was paid for and a "Download PDF receipt" button.

= 1.4.0 =
* API-Key only setup: Merchant ID and Secret Key are no longer required.
* Switched to Authorization: Bearer authentication on every API call.
* Endpoints now target /api/public/v1/ (merchant/ping, merchant/generate-address, merchant/invoice-status).
* Live connection badge on the Settings page reports Connected / Invalid API key / Wallet not ready.
* Invoice creation goes through the canonical platform endpoint so the wallet, address derivation and rate are always consistent with paycryptohost.com.
* WooCommerce 9.x + HPOS compatible. Tested with WordPress 6.7 and PHP 8.3.

== Changelog ==

= 1.4.5 =
* Multi-coin invoice: customers can now pay with any coin the merchant has enabled and approved (BTC, USDT/TRC20, ETH, BCH, LTC, SOL, XMR, BNB). Coin picker with logo/symbol tabs renders automatically when more than one coin is available.
* Invoice template simplified: shows only Invoice #, "Paying for" (product name), Amount (USD), the selected coin's exact amount, and the receiving address. Removed rate/customer/date noise.
* Copy buttons for BOTH the exact crypto amount AND the receiving address.
* "Send exact amount, single transaction, correct network" warning added inside every invoice.
* WooCommerce thank-you page: order details and billing table can be hidden via the new "Hide order details on thank-you page" gateway setting, leaving only the invoice block + product name + pay link.
* QR codes now use the correct URI scheme per coin (bitcoin:, litecoin:, bitcoincash:, ethereum:, monero:).
