=== VelPay for WooCommerce ===
Contributors: velpay
Tags: crypto payments, usdt, cash app, woocommerce, checkout
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Crypto, Cash App and card payments for WooCommerce, paid on the VelPay hosted checkout.

== Description ==

Customers who pick VelPay finish paying on a VelPay checkout page and land back on your thank-you page. An order only counts as paid once VelPay confirms it with a signed event or a direct API answer; the browser redirect never decides.

What customers can pay with:

* **Crypto**: stablecoins (USDT, USDC), BTC, ETH and more, on Bitcoin, Ethereum, Tron, Solana, BNB Smart Chain, Polygon, Base and Arbitrum among others.
* **Cash App**, paid over Lightning.
* **Card, Apple Pay and Google Pay**.

What you get:

* Separate test and live keys. In test mode nothing is charged, and the checkout has buttons that simulate each outcome.
* Events signed with Ed25519 and checked with `sodium_crypto_sign_verify_detached`; anything older than five minutes is refused.
* WooCommerce statuses that follow VelPay: paid becomes Processing (or Completed for virtual goods), a short payment becomes On hold, an expired checkout becomes Failed, a voided one Cancelled, and a full refund Refunded. Each change adds an order note.
* A choice of which methods to offer and how long customers have to pay.
* Support for the block Cart and Checkout and for High-Performance Order Storage.
* A `[velpay_button]` shortcode: a pay button for any page, no cart involved.

Setup guide: https://velpay.pro/docs/guides/woocommerce

= Data sent to VelPay =

The plugin calls the VelPay API at https://velpay.pro/api/v1 to create checkouts and read their state. For each order it sends the total, currency, order number, your site address and the customer's billing email, name and country. VelPay sends events to `/wp-json/velpay/v2/events` on your site. Terms: https://velpay.pro/legal/terms. Privacy: https://velpay.pro/legal/privacy.

== Installation ==

1. Plugins → Add New → Upload Plugin, choose `velpay-for-woocommerce.zip`, then Activate.
2. Open WooCommerce → Settings → Payments → velpay.
3. Leave Mode on Test and paste the test secret key (`vp_sk_test_…`) from Developers → API keys in your VelPay dashboard.
4. Copy the event URL from the "Payment events" section (it ends in `/wp-json/velpay/v2/events`) into Developers → Webhooks in the dashboard. Paste the signing public key from that dashboard page into the plugin.
5. Tick "Show VelPay at checkout" and place an order. On the VelPay checkout, simulate a payment: the order moves to Processing.
6. Once your VelPay account is approved for live payments, paste the live secret key, add the same URL to your live webhooks, and switch Mode to Live.

== Frequently Asked Questions ==

= When does an order become paid? =

When the signed `order.paid` event arrives. If the customer reaches the thank-you page first, the plugin asks the VelPay API once and marks the order paid if VelPay says so.

= A customer sent slightly too little crypto =

Your short-payment setting in VelPay decides. Within it, the order completes and the note says what arrived. Beyond it, the order goes On hold until you settle it in the VelPay dashboard: take what arrived, wait for the rest, or refund.

= How do refunds work? =

Refunds are made in the VelPay dashboard or API. The plugin notes each refund and moves the order to Refunded when the whole amount has gone back. Refunding from the WooCommerce order screen does not move any money.

= Can I preset the coin? =

Use the `velpay_order_body` filter:

`add_filter( 'velpay_order_body', fn ( $body ) => $body + [ 'crypto' => [ 'network' => 'tron', 'asset' => 'USDT' ] ] );`

= How does the pay button work? =

`[velpay_button amount="19.99" currency="usd" description="Workshop ticket" label="Buy a ticket"]`

Amounts are in normal units. Optional attributes: `reference` and `methods` (for example `methods="crypto,card"`). The button uses the keys from the gateway settings. To fulfil button payments, hook `velpay_event` and look for `metadata.source` equal to `wordpress_button`.

= One VelPay account for several shops? =

That works. Every checkout records the shop's address in its metadata, and each shop ignores events for the others.

== Changelog ==

= 1.1.0 =
* Accepts events signed during a signing key rotation (Velpay-Signature now carries a key id and signature per key).

= 1.0.0 =
* First release.
