=== securepayAPI Payments ===
Contributors: securepayapi
Tags: woocommerce, payment gateway, credit card, checkout, 3d secure
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.5.3
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Take card payments on your WooCommerce checkout with securepayAPI. Customers
pay without leaving your store.

== Description ==

The card form is an iframe served by securepayAPI, so card numbers are entered
on securepayAPI and never pass through your site. The customer stays on your
checkout the whole time, and your own "Place order" button is the only button
on the page. Where the device supports it, Apple Pay or Google Pay is offered
above the card form; the wallet pays once the customer has filled in their
details, and the order is created before anything is charged.

Works on both checkouts WooCommerce ships: the Checkout block and the classic
shortcode checkout, including the "pay for order" page.

Nothing in the browser decides that an order is paid. Once the card goes
through, this site asks securepayAPI what happened, compares the answer against
the order — amount, currency, live or test — and only then marks the order paid.
A payment that cannot be matched, or cannot be read back, puts the order on hold
for a human instead of asking the customer to pay a second time.

= What you need =

* A securepayAPI account with a registered website matching your store's domain
* Your client key and secret key from the dashboard at https://app.securepayapi.com
* HTTPS on your store. The authentication step needs a publicly reachable https
  address to return to, so the method hides itself on an http store rather than
  failing customers at the last step.
* USD. Other currencies are not supported yet, and the method hides itself when
  the store sells in one.
* For Apple Pay: your store's domain registered for Apple Pay on your
  securepayAPI account (ask securepayAPI to add it). Google Pay needs no extra
  setup beyond the registered website.

= Limitations in this version =

* USD only
* Refunds are made in the securepayAPI dashboard, not from the WooCommerce order
  screen

== Installation ==

1. Upload the plugin through Plugins → Add New → Upload Plugin, or unzip it into
   wp-content/plugins.
2. Activate it.
3. Go to WooCommerce → Settings → Payments → Credit card (securepayAPI).
4. Choose Sandbox or Live, paste the matching client and secret keys, and use
   "Test keys" to check them before saving.

== Frequently Asked Questions ==

= Do card numbers touch my server? =

No. The form is an iframe served by securepayAPI, and the card is encrypted in
the browser to securepayAPI's public key. Your site receives a payment
reference, never card data.

= Why is the payment method missing from my checkout? =

It hides itself when it cannot work: the store is not on https, the currency is
not USD, or the keys are missing. The gateway settings screen names the reason.

= An order is on hold and says the payment could not be matched. What now? =

The customer's card was charged. Open the payment in the securepayAPI dashboard
using the id in the order note, decide what happened, and complete or refund the
order yourself. Do not ask the customer to pay again — that is exactly what the
hold exists to prevent.

= Does it work with the Checkout block? =

Yes, and with the classic checkout, and with the "pay for order" page.

== Changelog ==

= 1.5.3 =
* Fixed: an order could be completed twice when the customer's browser and
  securepayAPI's server notification confirmed it at the same moment (two
  "processing" emails, the payment hooks run twice). The second confirmation
  now reads the order's status from the database after waiting its turn, and
  leaves a completed order alone. Update from 1.5.2.
* The external developer log no longer carries email addresses: WooCommerce
  puts the customer's into some of its own error messages, and those were
  forwarded as they were.
* Removed the check for an order paid through another gateway while it also
  held a securepayAPI payment. The server notification now completes such an
  order within seconds, which is what that check was a substitute for. The
  `securepayapi_unexpected_charge` action is no longer fired.

= 1.5.2 =
* securepayAPI now tells the store itself when a payment goes through, server
  to server, a few seconds after the charge. An order is completed even if the
  customer's browser never reports back (a closed tab, a checkout page that
  re-rendered). Nothing to set up: the plugin names its own address when it
  creates the payment. The store must be reachable over https.
* Removed the 10-minute background check for paid orders: it is no longer
  needed. The scheduled event of earlier versions is cleared on update.
* Checkout block: a payment is no longer abandoned when the block replaces the
  payment form while the card or wallet is being charged (for example when the
  customer switches payment method and back). The order is still confirmed with
  the server, and no second payment is prepared over the first.
* Classic checkout: the same for a wallet payment whose form is re-rendered
  while it is being charged.
* An order put on hold because its payment could not be confirmed yet is now
  completed by itself when securepayAPI confirms the payment. Orders held for
  any other reason (the payment does not match the order, or belongs to another
  one) still wait for you.
* After a successful charge, a lost confirmation request is repeated instead of
  leaving the customer on the checkout page.
* The "payment form was interrupted" message no longer states that the card was
  not charged; it asks the customer to check before paying again.

= 1.5.1 =
* "Pay for order" page: a 3-D Secure challenge can be completed again. The
  page's own "processing" overlay used to stay over the card form while the
  card was being charged, so the challenge could not be clicked.
* The card form is checked before the order is created (needs the current
  securepayAPI widget). An empty or incomplete card no longer leaves an unpaid
  order behind on every click of "Place order".
* A retry never charges over an earlier payment that may have gone through: if
  the order's previous payment was taken, or its outcome is not final, the order
  is completed or put on hold for review instead of being charged again; if that
  payment cannot be read, the customer is asked to try again shortly.
* The background check for paid orders left "pending" now goes through all of
  them in turn; it used to re-read the same oldest 25 and never reach newer ones
  on a store with many abandoned checkouts.
* A customer is no longer stuck on "This payment form was already used" after a
  reload: the used payment is dropped and a new one is created.
* Two orders can no longer both be completed by one payment when their
  confirmations arrive at the same moment: only the order named on the payment
  completes, the other is put on hold.
* The cart is emptied as soon as the order is confirmed, not only on the receipt
  page.

= 1.5.0 =
* The order is now created by WooCommerce itself, through its own checkout —
  the form submit on the classic checkout, the Store API on the Checkout block —
  exactly as for any other payment method. The plugin no longer creates orders
  on its own. Everything WooCommerce does at checkout now applies to these
  orders as well: field validation, shipping rules, coupons, terms, customer
  accounts, the block's additional fields, and other plugins' checkout hooks.
* Nothing is charged before WooCommerce has validated the checkout and created
  the order. The payment is then tied to that order and checked (unpaid, same
  amount, currency and mode) before the card or wallet is charged.
* Apple Pay and Google Pay: approving in the wallet sheet runs the store's own
  checkout first; the charge goes through only once the order exists.
* The payment's external reference in securepayAPI is now the WooCommerce order
  id, so a payment can be looked up by its order (card payments; an Apple Pay or
  Google Pay payment is prepared before the order exists and keeps the payment
  id).
* A declined or abandoned payment leaves a note on the order, so it can be told
  apart from a checkout the customer simply left.
* The unpaid-order cleanup no longer cancels an order whose capture was sent
  but whose outcome is not known yet; such an order goes on hold for a human.
* A customer who creates an account at checkout is no longer shown "your
  payment is being confirmed" after paying (the confirmation step was refused
  once WooCommerce had signed them in).
* "Pay for order" checks the terms checkbox and fires WooCommerce's pay-action
  hooks, like WooCommerce's own pay form.
* A declined card reports at once instead of after a few seconds of re-reading.
* Removed the plugin's own order-creation requests (begin, adopt) and the
  checkout log request.

= 1.4.0 =
* Apple Pay and Google Pay on both checkouts. The wallet button appears above
  the card form on devices that support it and is released once the required
  fields are filled in. The order-first rule is kept: after the customer
  approves in the wallet sheet — and before anything is charged — the plugin
  creates the pending order, then lets the charge proceed and finishes the
  order the way it does for a card. If the order cannot be created, nothing is
  charged and the customer is told why.
* Apple Pay needs the store's domain registered for Apple Pay on the
  securepayAPI account; without it the button is simply not shown.

= 1.3.4 =
* Checkout block: the payment form is now held for the whole place-order flow,
  from before the order is created. A cart total that changed in the instant
  between creating the order and charging the card could previously swap in a
  new payment underneath the order, charge that one, and leave the order unable
  to find it.
* The wait for a card payment to finish is now 25 minutes (was 16), longer than
  every step securepayAPI itself allows (challenge, confirmation polling), so a
  slow but live authentication is never cut short.
* The card form no longer asks for the email address a second time: the
  checkout already has it and it goes onto the order.
* An order whose payment does not exist on the securepayAPI side (or on a store
  with no secret key) is no longer kept pending for ever by the unpaid-order
  guard; WooCommerce's own cancellation decides.
* A payment kept in the session for more than six days is replaced instead of
  being offered again as expired.
* Classic checkout: after a failed attempt during which WooCommerce re-rendered
  the payment box, the card form is mounted again instead of answering "not
  ready" to the next click.
* The key-test message for a rejected secret key now mentions the other cause
  of that answer: an account that is not active.
* The guest session is now kept explicitly whenever a payment is started.
  WooCommerce persists a guest's session only once its cookie exists, and sets
  that cookie from the cart (and, in current versions, on the "pay for order"
  page itself); the plugin no longer depends on either, so a payment link opened
  in a fresh browser keeps its payment between requests on every supported
  WooCommerce version.
* Checkout block: the order created before the charge is now recorded as the
  session's awaiting-payment order, as the classic checkout already did. A
  retry resumes that order instead of creating another, and the cart is emptied
  after payment.
* Paying an older order from its payment link no longer empties an unrelated
  cart the shopper has in progress; only the cart the order was made from is
  emptied, as WooCommerce itself does.
* The background re-check stops after about 20 seconds and continues on its
  next run, so a slow payment service cannot have it killed mid-batch by the
  host's PHP time limit.

= 1.3.3 =
* A payment confirmed in the instant before it settles is no longer mistaken for
  an unpaid one. Confirmation can reach the store a fraction of a second before
  the payment finishes recording, while it still reads "awaiting payment"; the
  store now re-reads it until it settles — as it already did for a payment still
  "processing" — so a card that was charged completes the order instead of being
  left pending.
* Restored a background re-check for orders stranded by a dropped confirmation.
  If the browser never delivered the confirmation at all (the tab was closed
  between the charge and the confirm step), a scheduled check now re-reads such
  orders by payment id and completes any that succeeded — even on a store where
  WooCommerce's own "cancel unpaid orders" task is switched off. It only ever
  completes a genuinely succeeded payment, through the same amount/currency/mode
  and duplicate-order checks as every other payment, and never cancels an order.

= 1.3.2 =
* A payment caught mid-flight is no longer mislabelled as a charge. Confirmation
  can run within a second or two of the card attempt, when the payment is still
  "processing" — on a fast issuer decline especially. The store now re-reads the
  payment until it settles (succeeded or failed) before deciding, so a declined
  or never-charged attempt is a clean "please try again" with no order left on
  hold and no stock or emails spent, instead of an order parked as "card was
  charged but not settled". The one case that stays on hold — a payment that is
  still unresolved after the re-reads — now says so honestly ("the payment did
  not confirm … the money may or may not have moved") rather than asserting a
  charge the store never saw.

= 1.3.1 =
* Block checkout: the order now always carries the shopper's shipping line and
  its total matches the amount charged. The block keeps the chosen shipping
  method in its own session, which the order builder did not read, so some
  block orders were created with no shipping and a total short of the payment —
  which then showed as "paid but doesn't match this order" (on hold) or an order
  shipped without its shipping charged. Shipping is now rated and a valid method
  locked in before the order is created, on both the block and classic paths.
* Confirmation is retried through a transient hiccup. A one-off network blip or
  server error while reading the payment back no longer parks a genuinely paid
  order for manual review, and the already-paid check before a retry no longer
  misreads a blip as "not paid"; a definitive answer (unknown payment, missing
  key) is still acted on at once.

= 1.3.0 =
* Order-first checkout. The pending order is now created BEFORE the card is
  charged and finished afterwards by its order id, instead of charging first and
  then re-submitting the checkout form (which a theme could intercept). A dropped
  browser can no longer leave a charged card with no order at all — the cause of
  the rare "paid but no order" report.
* The Checkout block gets the same protection. WooCommerce's Store API creates
  its order only at place-order time, after the card is charged, so the block
  checkout now creates the pending order first and hands it to the Store API as
  its draft; the place-order request adopts that order rather than making a
  second one.
* Safety net with no new scheduled task: a paid order left pending by a dropped
  browser is completed automatically, by re-reading the payment when WooCommerce
  next revisits the unpaid order. A still-unpaid order is cancelled as before.
* Fixes: the "pay for order" page no longer double-submits; the gateway hides
  itself on a fully-discounted (zero-total) cart; two near-simultaneous place-order
  clicks no longer create two orders; the billing email is validated server-side
  before an order is started; the developer log now also redacts secret-shaped
  values, not only known field names.

= 1.2.0 =
* Removed the webhook and background recovery added in 1.1.0. The payment result
  is known synchronously the moment the card is charged, so the store no longer
  needs a webhook or a scheduled re-check to decide paid-or-not. Any sweep left
  scheduled by 1.1.0 is cleared automatically on update.
* Added an optional email field toggle: the embedded widget can be mounted with
  email:false to hide its receipt-email field for stores that already collect it.
* Added an optional External developer log (off by default) that streams the
  full checkout and order lifecycle to securepayAPI for diagnosing a specific
  problem. Card data, CVV and keys are never sent.

= 1.1.0 =
* Recover payments the browser never finished recording. If a customer pays but
  closes the tab or loses connection before the order is confirmed, the order no
  longer stays stranded as unpaid: the store re-reads the payment from
  securepayAPI and completes the order on its own.
* Added an optional webhook so securepayAPI can notify the store the moment a
  payment settles. Set a signing secret on the gateway settings screen to turn on
  signature checking; the webhook URL is shown there.
* Added a background check that re-examines recent unpaid orders, so recovery
  works even with no webhook configured.
* Every recovered or recheckable order is linked to its payment as soon as
  checkout starts, so nothing is lost if the final step never runs.

= 1.0.0 =
* First release.
