=== CatCode Payment Status Sync for WooCommerce ===
Contributors: catcodestudio
Tags: woocommerce, payments, pending payment, stripe, liqpay
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

The customer paid, the order still says "Pending payment". This plugin asks the payment provider and brings the order in line.

== Description ==

A card payment reaches the shop twice: the customer is sent back to the thank-you page, and the provider calls the shop's callback or webhook. When the callback never arrives — a firewall, a security plugin, a changed URL, an expired webhook secret, a server that was down for a minute — the money is on the provider's side and the order stays "Pending payment". Nobody ships it, WooCommerce may even cancel it when the "Hold stock" time runs out, and the shop learns about it from an angry customer.

This plugin asks the provider directly, through its official status API, the same question the callback should have answered.

* **List of orders waiting for payment** — WooCommerce → Payment Status Sync shows every order still waiting after the time you set (15 minutes by default), with its payment method, the time it has waited and the result of the last check.
* **One click asks the provider.** When the provider confirms the payment, the order is marked paid with a note saying where the confirmation came from. Several orders at once — from this list or with the bulk action in the WooCommerce orders list.
* **Nothing is changed on a guess.** A paid amount or currency that does not match the order puts it on hold for a human, an intent or PayPal order that belongs to another order is reported and left alone, a PayPal payment that was approved but never captured is reported — this plugin never captures money.
* **E-mail digest** — one e-mail per scan with the orders that have waited too long, each order once.
* Check log with the provider's own status for every check.
* HPOS (custom order tables) and the block checkout supported.

= Supported providers =

* **CatCode gateways** — LiqPay, monobank, WayForPay, Portmone and the other CatCode payment gateways (Fondy, Hutko, NovaPay, EasyPay, iPay, Przelewy24, Netopia, iyzico, BOG/TBC, instalments). Nothing to configure: the gateway's own credentials and its own status logic are used — LiqPay `status`, monobank `invoice/status`, WayForPay `CHECK_STATUS`, Portmone `result`.
* **Stripe** (WooCommerce Stripe Payment Gateway) — PaymentIntents and Checkout Sessions, read with a restricted key that only needs Read access.
* **PayPal** (WooCommerce PayPal Payments) — Orders v2 API with the client ID and secret of a REST app, live and sandbox.

Orders paid with other methods are listed too, marked "no status API".

// @pro-begin
= Pro =

The Pro version is sold on [catcode.com.ua](https://catcode.com.ua/modules/payment-status-sync-for-woocommerce/), with a 7-day trial that never starts by itself:

* **Automatic background sync** every 5–60 minutes: due orders are checked with their provider and paid ones are fixed without a click. Each order is re-checked with a growing pause (10, 20, 40 minutes … up to 6 hours), so abandoned carts do not cost API calls.
* **Guard against the "Hold stock" auto-cancel:** before WooCommerce cancels an unpaid order, the provider is asked first — a paid order is marked paid instead of cancelled.
* **Mark failed:** a payment the provider reports as declined, cancelled or expired moves the order to Failed (off by default — such orders are only reported).
* **Telegram alerts** — the same digest in a Telegram chat.
* **Unpaid-share alerts** — when the share of unpaid orders of a payment method jumps above its own level of the previous 14 days, the payment page or the notifications are probably broken.
* CSV export of the check log and 90 days of history (free: 14 days).

The licence runs for 1-5 years and includes updates and support for that term; a purchased licence keeps its Pro features after the term ends.
// @pro-end

= What it does not do =

It does not replace the provider's callback or webhook — fix the cause when the log shows the same gateway again and again. It never captures, refunds or voids a payment.

== Installation ==

1. Upload the plugin and activate it. WooCommerce must be active.
2. WooCommerce → Payment Status Sync → Settings: choose which order statuses to watch and when to alert.
3. For Stripe, create a restricted key with Read access to PaymentIntents and Checkout Sessions and paste it. For PayPal, paste the Client ID and Secret of a REST app (developer.paypal.com → Apps & Credentials). CatCode gateways need nothing.

== Frequently Asked Questions ==

= Will it mark an order paid when the customer only opened the payment page? =

No. An order is marked paid only when the provider says the money is there and the amount and currency match the order.

= Does it send requests to the provider for every abandoned cart? =

Only within the window you set (by default from 15 minutes to 72 hours after the order), and in Pro with a growing pause between checks of the same order.

= Where are the API keys stored? =

In the plugin settings, encrypted with a key derived from your site's WordPress salts. They are never printed back on the settings screen.

== Changelog ==

= 1.0.0 =
* First release: list of orders waiting for payment, checks with LiqPay, monobank, WayForPay, Portmone and other CatCode gateways, Stripe and PayPal, one-click and bulk checks, e-mail digest, check log; English, Ukrainian and Russian.
// @pro-begin
* Pro: automatic background sync, guard against the "Hold stock" auto-cancel, Mark failed, Telegram alerts, unpaid-share alerts per payment method, CSV export; updates from catcode.com.ua in Dashboard → Updates while the licence covers updates.
// @pro-end
