=== AuxCORE Payment Gateway/HR ===
Contributors: auxpay
Tags: woocommerce, payment, hosted page, credit card, ach, text-to-pay
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.2
Stable tag: 6.2.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A WooCommerce payment gateway that allows customers to pay securely online, by credit card, ACH, or text-to-pay with AuxCORE.

== Description ==

AuxCORE Gateway is a WooCommerce payment gateway plugin that lets your customers pay seamlessly using:

* **Secure Online Payment**
* **Credit Card Payments**
* **ACH Payments**
* **Text to Pay** links

It integrates with the AuxCORE platform and supports both **classic WooCommerce checkout** and the new **WooCommerce Blocks checkout**.

= Features =

* **Secure Online Payment** — same-page slide-out iframe drawer; customers never leave your store
* Securely accept credit card payments
* ACH payments (no tokenization required)
* Text to Pay option that generates a secure link
* Built-in support of AuxCORE SDK for card payments
* Payrix integration for card payments through PayFields
* Full/Partial Refunds for all AuxCORE gateways
* Optional technology/convenience fee
* Signed webhook (HMAC-SHA256) for authoritative payment confirmation
* Customizable payment settings in admin
* Debug logs option for monitoring

= Requirements =

* WordPress 6.0+
* WooCommerce 7.0+
* PHP 7.2+

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/auxpay-payment-gateway` directory, or install directly through the **WordPress Plugins screen**.
2. Activate the plugin through the **Plugins** screen in WordPress.
3. Navigate to **WooCommerce → Settings → Payments**.
4. Locate **AuxCORE** in the list of gateways and click **Manage**.
5. Enter your **AuxCORE API credentials** (provided in your AuxCORE merchant account).
6. Enable the payment methods you want (Secure Online Payment, Credit Card, ACH, or Text to Pay).
7. For **Secure Online Payment**: set the **AuxCORE Iframe Origin** (e.g. `https://pay.auxvault.net`) and the **Webhook Secret** (generate a random string, copy into your AuxCORE dashboard alongside the displayed Webhook URL).
8. Save changes and start accepting payments.

== Usage ==

After installation and configuration:

1. Customers will see **Secure Online Payment**, **Credit Card Payment**, **ACH Payment**, or **Text to Pay** on the checkout page.
2. When selecting **Secure Online Payment**, a secure checkout drawer will open on the same page for completing the payment.
3. When paying with **Credit Card** or **ACH**, customers enter their payment details securely during checkout.  
4. When selecting **Text to Pay**, a secure payment link will be sent to the customer’s phone number for completing the payment.  
5. Orders are automatically updated in WooCommerce when the payment is processed.  
6. Admins can view transaction details in the WooCommerce **Order Details** page.

== Frequently Asked Questions ==

= Does this plugin work with WooCommerce Checkout Blocks? =  
Yes, AuxCORE Gateway supports both the classic checkout and the new Checkout Block.

= Do I need SSL on my site? =  
Yes, for security reasons your site must use HTTPS when accepting live payments.

= Where can I find API credentials? =  
API keys are provided in your AuxCORE merchant account. Contact AuxCORE support if you don’t have them.

= Does this plugin store card data? =  
No. All sensitive card and ACH data are handled securely by AuxCORE’s API. The plugin does not store payment details.

== Screenshots ==

1. AuxCORE gateways listings in WooCommerce  
2. AuxCORE gateways settings in WooCommerce  
3. Checkout page with AuxCORE payment methods  

== Changelog ==

= 6.2.2 =
* Supports AuxCORE **Velocity Rules**. When one of the merchant's rules flags a payment, the processor approves it but AuxCORE holds it until the merchant reviews it. The order is now set to **On hold** with a note instead of being marked paid. It moves to Processing when the merchant approves the payment and is cancelled when they deny it
* The customer is told the payment was received and is being reviewed, then taken to their order. The order page shows On hold until the review is done
* Applies to Secure Online Payment, Credit Card and ACH. The hold comes from the new `transaction.in_review` notification, from the payment response, and from the payment-status check the drawer runs when no notification arrives
* After updating, the plugin re-registers its payment-notification webhook once so it receives the new event. You do not need to save the settings again

= 6.2.1 =
* The **Donation** option is now in the **Product data** header, next to Virtual and Downloadable. It used to sit at the bottom of the General tab, where it was easy to miss. Products already marked as donations stay marked
* Donations are charged on the AuxCORE gateway your merchant reserves for donations (its own MID and rate), through Secure Online Payment. A donation must be checked out separately from other items. If the merchant has no donation gateway, the plugin warns you and the payment is refused rather than charged on your sales account

= 6.2.0 =
* Adds **Merchant accounts**: one store can now take payments on more than one AuxCORE merchant account, each with its own MID, fees and statement — for example donations on a nonprofit account and event tickets on your main one. Add an account's API key under WooCommerce → AuxCORE Gateway Settings → **Merchant accounts**; the plugin resolves the merchant and registers its webhook when you save
* Choose what each account takes with the new **Payment account** setting on a product, or by assigning whole product categories to an account. Anything not assigned stays on your Global Settings account, shown as **Default**
* Every order is charged on exactly one account. Items from different accounts cannot be checked out together: the shopper is told to check out separately, on both the classic and the Blocks checkout
* Confirmations, refunds and payment-status checks use the account that took the payment, and each order records which account that was. Additional accounts take Secure Online Payment only; Credit Card, ACH and Text to Pay stay on Default and are not offered for another account's items
* Payment notifications that the store refuses are now answered with a real error status, so AuxCORE retries them instead of recording them as delivered. A webhook that cannot be registered when you save is now reported on the settings page instead of failing silently
* A store with a single account works exactly as before: no new product field, no change at checkout, no change to orders
* Fixes paying from a **pay-for-order link** (an order created in wp-admin, or a failed order paid again) with Secure Online Payment: the payment drawer used to stop with "Starting your payment took too long". It now opens the secure payment page as it does at checkout
* Fixes refunds made from the WooCommerce order screen being recorded twice once AuxCORE confirmed them, which overstated the refunded total and blocked refunding the rest of the order
* Fixes **Test connection** and **Fetch configuration** on a merchant account: both now re-read the account's WooCommerce integration status and store URL from AuxCORE and update the row straight away, show "Testing…" / "Fetching…" while they wait, and say so when the status could not be read instead of showing the old value as current
* Warns when an account's store URL in AuxCORE does not match this store. Every account is its own AuxCORE merchant and needs this store's URL, or its payment page will not open here. The warning shows on the account's row, after Test connection / Fetch configuration, in the "payment accounts need attention" notice, and on the Global Settings page

= 6.1.1 =
* Adds a **Payment branding** setting under WooCommerce → AuxCORE Gateway Settings. Off by default, so this build's checkout is unchanged after the upgrade. Switch it on and a "Powered by AuxPAY" line, with the AuxPAY logo and a link to auxpay.net, appears under each payment method at both classic and Blocks checkout
* Your own business name and logo, fetched from your AuxCORE account, are what the shopper is asked to pay either way. The setting only adds the platform credit beneath them — it does not rename your checkout, your plugin in wp-admin, or your payment methods
* This is the last difference between the two distributions to become configuration. Both builds now run the same code and differ only in their defaults: the AuxPAY-branded build has the setting fixed on and shows it read-only, this one leaves it to you

= 6.1.0 =
* Splits the plugin into two distributions built from one codebase. This build is the white-label one, shipped direct to merchants: it keeps the `auxpay-payment-gateway` slug, so a store on 6.0.x upgrades in place and keeps its API key, settings and auto-update. The AuxPAY-branded build is listed in the plugin store under its own slug and is a separate, fresh install
* The two builds share the same gateway ids and the same `wc_auxpay_*` settings, so only one may run at a time. Activating the other one switches to it and deactivates this one, with a notice in wp-admin saying so — your API key and settings are shared and survive the switch. If both are somehow left active at once, this build keeps serving payments and the AuxPAY-branded one stands down, so an accident cannot rebrand a white-label checkout
* Payment-method names in wp-admin now follow the build rather than being hard-coded, so the white-label build carries no platform name on the WooCommerce Payments screen either
* Nothing changes for a store that installs only this build: the checkout, the drawer, fees, webhooks and retry behaviour are exactly as in 6.0.20

= 6.0.20 =
* The accepted-card icons at checkout now come from the merchant's AuxCORE gateway — the same setting that decides whether a card is approved or declined — instead of a separate display-only list. The plugin used to draw Visa, Mastercard, Amex and Discover regardless, so stores were advertising brands their processor had never boarded and the shopper only found out when the card was refused. Run Fetch Config after upgrading to refresh the icons
* Card brands are corrected in the AuxCORE portal under the merchant's Gateway Config, on the gateway itself. The AuxCORE hosted checkout already read the same setting, so a merchant's WooCommerce checkout and hosted checkout now show the same logos
* A fetch that cannot resolve the brands leaves the stored icons untouched rather than clearing them, so a transient API problem cannot blank a working checkout
* First HR build. Nothing a shopper can see carries a platform brand: the payment drawer, checkout labels and the hosted return screens render the merchant's own name and logo from AuxCORE, and stay blank when the merchant has set neither. Settings, API keys, gateway ids and option keys are unchanged, so a store on 6.0.19 upgrades in place

= 6.0.19 =
* Fixes a card payment that AuxCORE approved leaving the WooCommerce order in Pending and the shopper stranded on "Confirming your payment": where the merchant charges a convenience fee, the webhook reports the amount charged (order total plus the fee) and the plugin's amount check rejected every one of them with a 400, so no delivery or redelivery could ever be accepted
* The order note now records the fee that was charged on top of the order total, which WooCommerce's own totals never see
* Adds a direct AuxCORE lookup when no webhook arrives: after a few seconds without a verdict the store asks AuxCORE what happened to the order and completes or fails it from the authoritative record, so a webhook that is lost, blocked, or rejected no longer leaves a paid order Pending until WooCommerce cancels it. The lookup runs under the same per-order lock as the webhook, so the two cannot both complete the order
* Replaces the endless "Confirming your payment" spinner with a clear outcome once the wait is over: the shopper is told the result is not confirmed yet, told not to pay again, and given "Go to my order" and "Check again". "Check again" re-polls and re-checks the same order and never starts a second payment

= 6.0.18 =
* Adds a "Try again" button to the declined screen: the checkout session survives a decline, so the shopper pays again on the same session and the same WooCommerce order instead of closing the drawer and placing the order a second time
* A decline is now shown within seconds of WooCommerce recording it, rather than after the full polling budget had run down - shoppers were held on "Confirming your payment" for around a minute for a verdict the store already had
* Fixes a retry after a decline hanging on "Creating your secure payment session": a new Place Order now retires the previous attempt's state, so its guard can no longer swallow the new submission before it is sent
* Adds a timeout to the session step, so a dropped or unreleased checkout request returns the shopper to the form instead of leaving the progress spinner running indefinitely
* A background order poll is now tied to the attempt that started it and can no longer settle a later attempt with an earlier verdict
* Reports a failed payment session to the WooCommerce Blocks checkout as a real error instead of an empty success, which the Blocks checkout ignored
* Pair this with the matching AuxCORE hosted checkout release. Against an older hosted checkout the payment page still sends a declined shopper back to the store a few seconds after the decline, which closes the retry offered above before they can use it

= 6.0.17 =
* Fixes a crypto payment that cannot be started being shown as an endless "Confirming your payment": the drawer now distinguishes a payment that never began from one that was attempted and declined, and shows the former as a failure straight away so the shopper can retry or choose another method
* The reconcile-before-failing behaviour introduced in 6.0.15 is unchanged for real payment attempts, so a declined sibling attempt still cannot override a confirmed approval
* Settles the WooCommerce Blocks checkout promise when a payment could not be started, instead of leaving the checkout waiting on a payment that will never arrive
* Fades between the drawer's own overlays and the embedded payment page rather than swapping them in a single frame, which shoppers reported as the drawer "reloading"; respects prefers-reduced-motion
* Requires the matching AuxCORE hosted checkout release to report unstarted payments. Against an older hosted checkout this release behaves exactly as 6.0.16

= 6.0.16 =
* Preserves the 6.0.11 → 6.0.15 hosted checkout architecture and all prior finality, duplicate-webhook, decline-reason, and expired-session protections
* Fixes transport URLs to use raw URL escaping so WooCommerce return URLs cannot be HTML-entity encoded before JSON/browser navigation
* Makes success/pending/failed/cancelled/expired drawer overlays mutually exclusive, preventing a late failure overlay from visually covering a confirmed success
* Handles `session.cancelled` for unpaid Pending orders so customer-abandoned hosted sessions do not remain as active Pending Payment orders; paid/on-hold states are preserved
* Prevents AuxCORE merchant UUIDs from being sent/rendered as shopper-facing merchant names; fetched branding now prefers brand/DBA name before legal company name
* Removes AuxCORE product naming from cardholder-facing hosted drawer copy and migrates saved checkout payment labels to neutral wording while retaining internal/admin product naming
* Adds WooCommerce order-key authorization to guest order-status polling, preventing a checkout nonce from being used to query another guest order
* Enables TLS certificate verification for hosted API calls in both live and test modes
* Uses each Woo order's own currency for checkout-session creation and webhook validation instead of the store-global currency
* Rejects late iframe messages after a drawer is closed and accepts active postMessage events only from the mounted payment iframe
* Prevents an uncorrelated sibling-attempt void event from cancelling a different transaction that WooCommerce already confirmed as paid
* Defers webhook event-ID replay marking until successful handling so validation/lock failures remain retryable
* Acquires the per-order webhook lock with an atomic `INSERT IGNORE`; `add_option()` performs a non-atomic existence check first, so two concurrent approvals could both acquire it and both call `payment_complete()`
* Commits the webhook event ID only on paths that reached a terminal decision, so a withheld or deferred approval can be recovered by AuxCORE's redelivery instead of being answered as a duplicate
* An approval whose transaction lookup cannot be completed (transport error, 408/429/5xx) is answered `503 Retry-After` for up to three redeliveries rather than immediately downgrading a paid order to on-hold; once that budget is spent, or for a permanent failure, the order is held so it is visible to the merchant and safe from WooCommerce unpaid-order cancellation
* Treats `refunded`/`reversed`/`returned`/`chargeback` as terminal non-approvals in transaction verification instead of an unknown status
* Serializes `transaction.refunded` under the per-order lock and keys its deduplication on the refund, preventing two concurrent deliveries of one refund from both calling `wc_create_refund()`
* Registers and handles `transaction.returned`: an ACH debit returned after approval now puts the order on hold with an order note instead of being logged as an unknown event
* Validates the scheme of any URL received by postMessage before `window.open()`, so a `javascript:` URL cannot execute in the merchant checkout's origin, and shows a clickable fallback when the popup is blocked
* Widens hosted status polling to ~60s with backoff and gives the confirming overlay a "Go to my order" link, so a charged shopper is never left on the drawer; the Blocks checkout promise is always settled
* Derives the settings-screen connection indicator from the resolved merchant ID, so a connected store no longer reports "Not Connected" after Test Connection or Fetch Configuration clears the cached display name
* Escapes the platform-supplied merchant name rendered on the settings screen
* Migrates branded payment labels by stripping the product name rather than replacing the whole label, so custom merchant wording such as "Pay by card with AuxPay - 2% off" survives the rebrand
* Uses each order's own currency for the drawer on the order-pay screen, matching the currency used for session creation and webhook validation
* Excludes internal review/QA documentation from the distributed plugin archive
* Minimizes hosted-session debug logs so customer name, email, phone, addresses, and line-item contents are not written to plugin logs
* Adds current-session correlation for iframe events when a session ID is supplied
* No changes to standalone Credit Card, ACH, or Text2Pay transaction logic, gateway IDs, option keys, webhook endpoint, or technical `auxvault.*` event contracts

= 6.0.15 =
* Hotfix: serializes hosted payment-state webhooks per WooCommerce order to prevent concurrent approval/decline workers from acting on the same stale Pending state
* Adds semantic webhook deduplication by transaction + session + canonical state, in addition to existing event-ID replay protection
* Hosted iframe failure messages are advisory until WooCommerce confirms the final order state, preventing a declined sibling/duplicate attempt from overriding a confirmed approval in the drawer
* Preserves and surfaces safe AuxCORE decline reasons (for example, insufficient funds) in WooCommerce order notes and the authenticated drawer status check
* WooCommerce checkout-session expiry now shows a dedicated Reload checkout recovery state instead of being presented as missing billing information
* Expired-session recovery no longer blindly re-submits payment; it checks an existing order for success first, then reloads WooCommerce for a fresh session/nonce
* No changes to Credit Card, ACH, Text2Pay gateway implementations, gateway IDs, settings keys, endpoints, hooks, or San's 6.0.11 drawer/session-creation structure

= 6.0.14 =
* Hosted checkout now fails closed on explicit non-final approval payloads such as process/processing/pending
* Legacy hosted approval webhooks are verified against the authenticated AuxCORE transaction record before WooCommerce payment_complete()
* If final transaction verification is unavailable or still processing, the order is held for confirmation instead of being marked paid
* Hosted iframe success no longer displays or redirects as paid until WooCommerce itself reaches a paid order status
* Removed the browser-side timeout path that could redirect as success without WooCommerce confirmation
* Added safe hosted-payment audit metadata/logging for event type, transaction ID, normalized status, response code, pending kind, and payment method
* Preserves 6.0.11 drawer/session structure and 6.0.13 WPay late-status reconciliation protections
* No transaction-flow changes to standalone Credit Card, ACH, or Text to Pay gateways

= 6.0.13 =
* Based on 6.0.11; preserves its hosted checkout drawer flow and session/error handling
* Added hosted-payment WPay reconciliation protection from the 6.0.12 hotfix branch
* Paid orders cannot be downgraded by late pending/decline webhooks
* Hosted pending responses distinguish settlement, customer action, and confirmation states
* Added hosted redirect-event support and final WooCommerce status reconciliation
* Updated all user-facing product branding to AuxCORE while retaining required compatibility identifiers

= 6.0.11 =
* Checkout drawer continues automatically once details are valid — no second click needed
* Validation errors still stop in the drawer so they can be corrected before submitting
* Renamed drawer copy from "Secure Link Checkout" / "Continue to Link" to "Secure Checkout" / "Continue"
* Drawer no longer reopens itself if it was closed while the payment session was being created
* Added error handling for checkout requests that fail before a payment session exists

= 6.0.0 =
* Upgraded to AuxCORE 2.0 backend API (x-api-key auth, new event types, Stripe-style webhook signatures)
* Same-page slide-out drawer (Pay with Link) — no redirect
* Auto-resolves merchantId on settings save
* Auto-registers webhook endpoint on settings save

= 5.0.21 =
* Secure Online Payment rebuilt as same-page iframe drawer — customers never leave the store
* HMAC-SHA256 signed webhook handler with replay protection and idempotency
* Webhook Secret and AuxCORE Iframe Origin settings added
* Session expiry retry flow added to drawer
* Security hardening: order status poll restricted to authenticated order owner

= 5.0.0 =
* Major version — iframe drawer architecture introduced
* Drawer-based checkout replaces redirect flow for Pay with Link
* Pre-submission field validation with contextual error messages
* WooCommerce Blocks checkout support (preliminary)

= 4.0.1 =
* Pay with Link method added
* Moneyeu gateway integrated
* Order status webhook

= 3.0.8 =
* Moneyeu gateway integrated
* Order status webhook

= 3.0.6 =
* 3DS flow with consent

= 3.0.5 =
* 3D Secure (3DS) flow implemented
* Configuration webhook added

= 3.0.4 =
* Dynamic display of credit card logos
* Security checks as per WordPress guidelines

= 3.0.3 =
* Dynamic gateway support for credit card payments
* Code improvements and fixes

= 3.0.2 =
* Added support for Payrix Payment Gateway
* Refunds support for all gateways
* Updated configuration settings for merchant
* Security check added on payment fields
* Logger added for error monitoring

= 3.0.1 =
* Initial release on WordPress.org
* Added Credit Card, ACH, and Text to Pay gateways
* WooCommerce Blocks checkout support
* Technology/convenience fee support

== Upgrade Notice ==

= 6.2.2 =
Upgrade in place; settings are kept. Payments flagged by the merchant's AuxCORE Velocity Rules now leave the order On hold until the merchant approves or denies them. The webhook re-registers itself once after the update.

= 6.2.1 =
Upgrade in place; settings and donation-marked products are kept. The Donation option moves to the Product data header.

= 6.2.0 =
Upgrade in place; your API key, settings and checkout are unchanged. New in this release: Merchant accounts, for stores that need some products charged on a different AuxCORE merchant account. Nothing changes unless you add one.

= 6.1.1 =
Upgrade in place; your API key, settings and checkout are unchanged. New in this release: a Payment branding setting that lets you show a "Powered by AuxPAY" line at checkout if you want one. It is off unless you turn it on.

= 6.1.0 =
Upgrade in place as usual — your API key and settings are preserved and nothing at your checkout changes. If you also install the AuxPAY-branded build from the plugin store, only one of the two can run at a time; the other will tell you in wp-admin and stay switched off.

= 6.0.20 =
Card icons at checkout now follow the brands your AuxCORE gateway actually accepts instead of always showing four. Run Fetch Config in the plugin settings after upgrading; if the icons are wrong, correct Card Brand Configuration on the gateway in the AuxCORE portal and fetch again. Your API key and settings are preserved.

= 5.0.21 =
"Pay with Link" is now called "Secure Online Payment." Your existing title and description settings are preserved — update them in WooCommerce → AuxCORE Gateway Settings if desired. Includes a compatibility fix for Elementor and custom-theme checkout pages.

= 5.0.2 =
Security update and webhook hardening for Secure Online Payment. Configure the Webhook Secret and AuxCORE Iframe Origin in plugin settings after upgrading.

= 3.0.8 =
Moneyeu gateway integrated with redirection.

= 3.0.6 =
3DS flow, with user consent.

= 3.0.5 =
3DS flow, auto configuration through webhook.

= 3.0.4 =
Dynamic display of credit card logos, Security checks.

= 3.0.3 =
Dynamic gateway support for credit card payments.

= 3.0.2 =
Payrix Gateway, Refunds, Security check and error monitoring. Recommended update for all users.

= 3.0.1 =
First stable release with support for AuxCORE Credit Card, ACH, and Text to Pay.
