=== NxtPay ===
Contributors: nxtpay
Tags: woocommerce, payment-gateway, payments, hosted-checkout, subscriptions
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 2.7.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept payments in WooCommerce through the NxtPay hosted checkout. No card data ever touches your site.

== Description ==

Last updated: 2026-10-12

NxtPay is a hosted-redirect payment gateway for WooCommerce. When a customer
places an order, the plugin creates a secure NxtPay payment link and redirects
them to a hosted payment page. No card fields are rendered on your store, which
keeps your PCI scope to the minimum (SAQ A).

Orders are confirmed four ways for reliability:

* **Webhooks (primary):** NxtPay signs each webhook with an HMAC-SHA256
  signature. The plugin verifies the signature, enforces a 5-minute replay
  window, and de-duplicates deliveries before completing the order. The webhook
  is set up automatically when you save the settings with a valid API key —
  there is no secret to copy or paste.
* **Return-page poll (fallback):** on the WooCommerce thank-you page, the plugin
  queries the order status directly, so a delayed or misconfigured webhook does
  not leave a paid order stuck.
* **Background sync (safety net):** a WordPress cron task runs every few minutes
  and reconciles any recent, still-unpaid NxtPay orders directly against the
  NxtPay API — so payments settle even if the webhook is slow, blocked, or never
  arrives and the shopper never returns to your store.
* **Closed-order recovery:** if an unpaid NxtPay order is marked failed or
  cancelled, the plugin checks it again over roughly the next 24 hours. If the
  payment went through after all, a failed order is completed, and a cancelled
  order is put on hold with a note so you can fulfil it or refund it. An order
  you cancel after it was paid stays cancelled.

= Features =

* Hosted redirect checkout — no card fields on your site.
* Classic checkout **and** the WooCommerce Cart/Checkout Blocks.
* HPOS (High-Performance Order Storage) compatible.
* Refunds from the WooCommerce order screen.
* WooCommerce Subscriptions support (monthly / yearly), when that plugin is active.
* Signed, replay-protected, de-duplicated webhooks, set up automatically.
* Background reconcile sync so orders settle even if webhooks are slow or blocked.
* "Test connection" button in settings.
* `[nxtpay_pay]` shortcode for one-off payments on non-WooCommerce pages.
* Self-hosted automatic updates.

== Installation ==

1. Upload the `nxtpay` folder to `/wp-content/plugins/`, or install the ZIP from
   **Plugins → Add New → Upload Plugin**.
2. Activate the plugin.
3. Go to **WooCommerce → Settings → Payments → NxtPay**.
4. Enter your **API Key** (begins with `npk_`), then
   click **Test connection**.
5. **Save changes**. The gateway is enabled by default, and the webhook is set up automatically —
   there is no secret to copy or paste. You'll see a confirmation message telling
   you how many payment providers were connected.

== Frequently Asked Questions ==

= Does the plugin update itself? =

Ordinary releases follow your WordPress auto-update setting for the plugin. A
release NxtPay marks critical (a payment or security fix) is installed
automatically, and admins see a notice when any update is waiting. To manage
every update yourself, add `define( 'NXTPAY_DISABLE_AUTO_UPDATE', true );` to
`wp-config.php`.

= Do I have to set up the webhook myself? =

No. When you save the gateway settings with a valid API key, the plugin registers
its webhook with NxtPay automatically and stores the signing secret for you. The
webhook URL is still shown read-only in the settings (in the form
`https://your-site.com/wp-json/nxtpay/v1/webhook`) for reference.

= What if the webhook is slow or blocked on my host? =

Payments still settle. Besides the webhook, the plugin confirms orders when the
shopper returns to your store, and a background sync runs every few minutes to
reconcile any recent, still-unpaid NxtPay orders directly against the NxtPay API.
Unpaid NxtPay orders that end up failed or cancelled are checked again over
roughly the next 24 hours. If the payment went through after all, a failed
order is completed and a cancelled order is put on hold for you to review.

= What happens when a customer leaves the payment page? =

Their cart is kept. If they place the order again with the same cart, they return
to the same order and the same payment page instead of starting a second payment.
The order stays Pending payment (or Failed after a declined card) while that page
can still be paid. Once the payment provider confirms the page closed unpaid, the
order is cancelled; a new checkout then creates a new order. If a customer pays
the old page after the order was cancelled or changed, the order is put On hold
for you to review.

= Do I need WooCommerce Subscriptions? =

No. If it is installed and the order contains a subscription, NxtPay creates a
recurring payment link automatically. Otherwise it creates a one-time link.

== Changelog ==

= 2.7.7 =
* Hide card payments when the remaining daily limit is too low for the checkout total, including tax and shipping.
* Recheck availability when the cart total changes.

= 2.7.6 =
* Hide card payments on an explicit exhausted-capacity response and recheck after daily reset or a limit adjustment.
* Explain daily-limit and conversion availability errors without an ambiguous-payment warning, preserving the original order and payment key.
* Check capacity in classic and Blocks checkout without copying transaction history into WordPress.

= 2.7.5 =
* Keep the cart when a customer leaves the hosted checkout, and resume the same order and payment session when they return.
* Cancel an order only after the payment provider confirms its checkout closed unpaid; record declines with a readable reason.
* Never resend a changed order under the original payment key, and hold a payment for an order whose total or subscription changed since checkout for review.
* Record, instead of applying, NxtPay events for an order the customer finished with another payment method.
* Install releases NxtPay marks critical automatically (opt out with NXTPAY_DISABLE_AUTO_UPDATE), notice new releases within the hour, and show an update notice in the admin.

= 2.7.4 =
* Re-check failed or cancelled orders for about 24 hours, even when the webhook is blocked. If the payment went through, a failed order is completed and a cancelled order is put on hold for review.
* Never fail an order because a status check timed out; only an answer from NxtPay closes it.
* An order that was paid and then cancelled stays cancelled.
* Use shorter status timeouts so slow stores do not stall the thank-you page or the background sync.

= 2.7.3 =
* Add a Settings link to the NxtPay row on the Plugins screen.
* Rename the dashboard button to Settings and keep it beside the description when other plugins show admin notices.

= 2.7.2 =
* Show connected organization, ready payment accounts, checkout and notification status in a compact dashboard.
* Enable new installations by default and resolve Test / Live mode automatically.
* Mask saved API keys and add Show / Hide controls when entering a replacement.
* Manage signing secrets automatically without exposing a settings field.

= 2.7.1 =
* Show a clear expired-checkout notice without replacing the original order or payment attempt.
* Keep checkout response tokens and URLs out of diagnostic logs.

= 2.7.0 =
* Organization keys now connect one merchant site without a Payment Group selector.
* Preserve historical order identity and webhook signatures during upgrade.

= 2.6.1 =
* Fix Test connection on the first admin AJAX request and show useful connection errors.
* Show a compact checkout illustration beside the Title and Description settings.
* Refresh settings assets immediately after plugin updates.

= 2.6.0 =
* Connect with an organization API key and select its Payment Group when needed.
* Test connection discovers groups; Save configures instant confirmation.
* Keep original group and idempotency on retries, refunds and subscription cancellation.
* Verify each webhook with the original order group secret and exact remote order identity.

= 2.5.6 =
* Support CAD checkout alongside USD, using the order currency without conversion. CAD requires platform enablement and a compatible verified payment account.

= 2.5.5 =
* **Expired payment links now time out.** The plugin remembers when a hosted
  checkout link expires and, once it has, marks a still-unpaid order as failed
  instead of leaving it stuck on "pending" forever — even if the shopper never
  returns, no webhook arrives, and NxtPay can't be reached at that moment. The
  background sync also now looks back 14 days (was 3), so an older stalled order
  still settles or fails cleanly.

= 2.5.4 =
* **Safer retries.** The plugin keeps one stable idempotency key for each order.
  NxtPay pins that key before contacting the processor, so a timeout or routing
  change cannot move the retry to a second payment site.

= 2.5.3 =
* **New NxtPay dashboard.** A top-level "NxtPay" menu now gives you a home for
  the plugin — connection, environment and instant-confirmation status, your
  recent NxtPay orders, and a quick link to settings.
* **Environment is now Automatic by default.** NxtPay uses Test while the site
  is in preview and Live only after Go Live. Force Sandbox/Production remains
  available for an explicit environment check.
* **Testing your key now sets up instant confirmation too.** Clicking "Test
  connection" registers the webhook right away, so you don't have to Save first.

= 2.5.2 =
* **Fixed a fatal error on the Cart/Checkout Blocks.** On PHP 8+ the blocks
  integration declared its settings property more strictly than the WooCommerce
  parent class, which crashed the block-based checkout as soon as it loaded.
  The property visibility now matches the parent, so the Blocks checkout works.

= 2.5.1 =
* **Fail-safe loading.** If any part of the plugin fails to load, WordPress now
  shows a clear admin notice and the rest of your site keeps working — a plugin
  fault can no longer take the whole site down.
* **Subscription renewals and cancellations now arrive automatically.** NxtPay
  now delivers `subscription.renewed` / `subscription.canceled` /
  `subscription.payment_failed` webhooks to the plugin. **After updating, open
  WooCommerce → Settings → Payments → NxtPay and click Save once** — the plugin
  refreshes its webhook registration to enable these events.
* The gateway now only offers itself on USD stores (the platform's supported
  currency) instead of failing at the payment page — and each order's own
  currency is re-checked at pay time.
* The webhook endpoint now rate-limits floods of unsigned requests.
* Saving unchanged settings no longer re-registers the webhook (faster saves);
  a version update or key/URL change still refreshes it automatically.

= 2.5.0 =
* **Fixed: `[nxtpay_pay]` quick-pay buttons could hand two different shoppers
  the same payment link.** Each button click now gets its own signed,
  single-use identifier, so the payment link created for one visitor can never
  be reused for — or block — another. This only affected the `[nxtpay_pay]`
  shortcode on non-WooCommerce pages; the WooCommerce checkout was unaffected.
* Hardening: the auto-updater now only installs update packages served from the
  NxtPay domain over HTTPS.

= 2.4.0 =
* **Free trials and sign-up fees are now supported.** A subscription's free
  trial is honoured (the first recurring charge waits until the trial ends), and
  a sign-up/setup fee — plus any one-time products bought alongside the plan — is
  charged once on the first invoice. The recurring amount continues to bill each
  cycle as normal.
* Now blocked instead: more than one subscription in a single order, and a
  discount that makes the first payment smaller than one billing cycle (each with
  a clear message at checkout).

= 2.3.0 =
* **More subscription billing schedules.** Daily, weekly, monthly, and yearly
  plans are now supported, including "every N" intervals (e.g. every 2 weeks,
  every 3 months), up to Stripe's one-year maximum. Schedules beyond that, free
  trials, and sign-up fees are still blocked at checkout with a clear message
  rather than mis-billed.

= 2.2.0 =
* **Full WooCommerce Subscriptions lifecycle.** Provider-billed renewals now
  create a matching WooCommerce renewal order and keep the subscription active;
  a failed renewal puts the subscription on hold; and cancelling in WooCommerce
  cancels at the provider (and vice-versa) so billing and WooCommerce never
  diverge.
* The gateway now declares `gateway_scheduled_payments` (the provider schedules
  the renewals) and only advertises the subscription features it actually
  supports. Subscription schedules it can't bill faithfully (anything other than
  a simple monthly/yearly plan, free trials, or sign-up fees) are blocked at
  checkout with a clear message instead of being mis-billed.
* Refunds reported by webhook are de-duplicated by the provider refund id, so a
  single refund (including one issued from the WooCommerce order screen) is
  recorded exactly once.
* An order whose payment couldn't be confirmed immediately is left pending (not
  failed) so the background sync can settle it, and the shopper is told not to
  pay twice.

= 2.1.0 =
* **Automatic webhook setup.** Saving the gateway with a valid API key now
  registers this site's webhook across your payment providers and stores the
  signing secret automatically — no more copying a `whsec_` secret out of the
  dashboard. The settings confirm how many providers were connected.
* **Background reconcile sync.** A new WordPress cron task runs every 5 minutes
  and reconciles recent, still-unpaid NxtPay orders directly against the NxtPay
  API, so orders settle even if a webhook is slow, blocked, or never arrives and
  the shopper never returns to your store.
* Webhook, return-page poll, and background sync now share one idempotent
  confirmation path, so an order is never double-completed.

= 2.0.0 =
* Rebuilt for the NxtPay v2 hosted-redirect API (`/v1/payment-links`,
  `/v1/subscriptions`, `/v1/orders`, `/v1/refunds`).
* New signed webhook scheme (`X-Nxtpay-Signature: t=,v1=`) with replay and
  de-duplication protection.
* Return-page status poll as a webhook fallback.
* WooCommerce Cart/Checkout Blocks integration.
* HPOS compatibility.
* Refunds and WooCommerce Subscriptions support.
* `[nxtpay_pay]` shortcode for non-WooCommerce pages.

== Upgrade Notice ==

= 2.5.5 =
Expired checkout links now fail stuck "pending" orders automatically instead of
leaving them hanging. Recommended for all stores.

= 2.5.3 =
Adds a NxtPay dashboard page, an Automatic environment default, and webhook
setup on Test connection.

= 2.5.2 =
Fixes a fatal error that crashed the WooCommerce Cart/Checkout Blocks on PHP 8+.
Recommended for all stores using the block-based checkout.

= 2.5.1 =
Adds fail-safe loading, subscription renewal/cancellation delivery, and
supported-currency checks. After updating, open the NxtPay settings and click
Save once to refresh the webhook registration.

= 2.5.0 =
Fixes a bug where `[nxtpay_pay]` shortcode buttons could share one payment link
between different shoppers. Recommended for anyone using the shortcode on
non-WooCommerce pages.

= 2.4.0 =
Free trials and sign-up fees are now supported for subscriptions. One
subscription per order; first-payment discounts aren't supported.

= 2.3.0 =
Adds daily/weekly/monthly/yearly and "every N" subscription billing schedules
(up to one year). Free trials and sign-up fees remain unsupported for now.

= 2.2.0 =
Completes WooCommerce Subscriptions support: provider renewals now post as
renewal orders, dunning and cancellations stay in sync both ways, and refunds
are de-duplicated. Recommended for anyone selling subscriptions.

= 2.1.0 =
The webhook now sets itself up automatically — just re-save your gateway settings
once after upgrading. A new background sync settles orders even if webhooks are
slow or blocked.

= 2.0.0 =
Major release on the NxtPay v2 API. Re-enter your API key, environment, and
webhook signing secret after upgrading.
