=== Persjay Webhook Rescue ===
Contributors: jaypeeperos
Tags: woocommerce webhooks, failed webhooks, failed emails, retry, monitoring
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

Never lose a WooCommerce order sync again. Persjay Webhook Rescue stops silent webhook deaths, shows exactly what failed, and replays it in one click.

== Description ==

WooCommerce disables a webhook after 5 failed deliveries in a row. It does not retry, and it does not tell you beyond a status change on a settings screen. Most store owners find out days later, when orders stop arriving at the warehouse, ERP, CRM, Zapier or Make.

Persjay Webhook Rescue catches every failed delivery, alerts you, and lets you send it again once the receiver is fixed.

= What Persjay Webhook Rescue does, free =

* **Stops the 5-strike silent deactivation.** WooCommerce keeps sending to a struggling endpoint instead of switching the webhook off. Persjay Webhook Rescue keeps its own failure count per webhook and alerts you instead.
* **Failure log with a payload inspector.** Every failed delivery is saved with its status code, headers, body, the receiver's response and a timeline of every attempt. Secrets (authorization headers, signatures, API keys, tokens, passwords) are hidden on screen until you click Reveal, and every reveal is logged.
* **E-mail alerts** after a run of failures (default 3 in a row), straight away when credentials break (401, 403) or the URL disappears (404, 410), and an "all clear" when the destination recovers.
* **Failed e-mail capture.** E-mails WordPress could not send are logged with the exact SMTP or mailer error (wrong password, host unreachable...), and you can send them again once the mailer is fixed. Recipients, subject and message are stored encrypted.
* **One-click re-enable** if WooCommerce did disable a webhook (for example while Persjay Webhook Rescue was switched off).
* **Health dashboard widget** with each webhook's status, failures in a row and last successful delivery.
* **Single replay**, re-signed with the webhook's current secret and a new delivery ID. Send the stored payload, or rebuild it from the order as it is now.
* **Smart failure classification.** Timeouts and server errors are temporary; bad credentials, missing URLs and rejected payloads are not, and Persjay Webhook Rescue tells you what to fix.
* **Duplicate guard.** Events whose order was later delivered successfully on the same topic are flagged so you do not send them twice.
* **Built for privacy.** Payloads are encrypted at rest (libsodium), purged automatically after 30 days (choose anything from 1 to 365), included in WordPress's personal data export and erase tools, and a suggested privacy policy paragraph is added for you.
* **Light.** Successful deliveries only reset a counter. Nothing is written to the database unless a delivery fails, and the dashboard widget never queries the log.

= Persjay Webhook Rescue Pro =

Persjay Webhook Rescue Pro is a separate plugin, sold at persjay.com. Everything in this plugin works fully without it; nothing here is limited, disabled or waiting for a license.

* Automatic retries with exponential backoff and jitter (1 min, 5 min, 15 min, 1 h, 3 h, 6 h, 12 h, 24 h by default), honouring Retry-After, then "dead" with an alert.
* Bulk replay, oldest first, paced (one request every 2 seconds by default) and paused automatically after repeated failures, with duplicates left unticked.
* Edit a payload before replay.
* Endpoint circuit-breaker: after repeated failures a destination is paused, new WooCommerce deliveries and site e-mails for it are held instead of failing, and everything is sent, paced, once a test delivery succeeds.
* Slack, Discord, Telegram and custom-webhook alerts.
* Daily digest e-mail.

= Persjay Webhook Rescue Business =

* Lead rescue for Gravity Forms (Webhooks add-on, resend through its own feed), WPForms and Fluent Forms.
* Action Scheduler failure monitoring: failed, timed-out and crashed background tasks, re-queued in one click.
* Custom destinations: capture failed requests from any plugin to hosts you choose.
* CSV export of the failure log (payloads excluded).
* WP-CLI: `wp webhook-rescue list`, `show`, `replay`, `purge`, `discard`, `export`, `health`.

= Persjay Webhook Rescue Agency =

* Monthly "Rescued orders and leads" report, on screen and by e-mail, including the order value rescued.
* White-label: your name, icon, colour, logo and footer in the admin, alerts and reports.
* Multisite network dashboard.
* Cross-site retry presets: save your retry, alert and circuit-breaker rules (or use the built-in Standard, Real-time and Patient presets), apply them in one click, push them to many sites of a network, or export and import them between installs.

== Installation ==

1. Install and activate Persjay Webhook Rescue.
2. Go to **Persjay Webhook Rescue** in the admin menu. Your WooCommerce webhooks are watched straight away.
3. Optional: in **Persjay Webhook Rescue → Settings**, set who receives alerts and send a test alert.

For a dedicated encryption key, add this to wp-config.php before Persjay Webhook Rescue stores anything:

`define( 'HOOKGATE_KEY', 'a long random string' );`

Without it, Persjay Webhook Rescue derives its key from AUTH_KEY.

== Frequently Asked Questions ==

= Does Persjay Webhook Rescue slow my store down? =

No. It does not intercept HTTP requests. It reads the result WooCommerce already reports after each webhook delivery and only writes to the database when a delivery fails.

= Will a replay be accepted by my receiver? =

Yes. Replays carry the same X-WC-Webhook-* headers WooCommerce sends, with a fresh X-WC-Webhook-Signature computed with the webhook's current secret, a new X-WC-Webhook-Delivery-ID, and an X-Persjay-Replay header with the event ID so the receiver can tell it is a replay if it wants to.

= What happens to WooCommerce's own failure counter? =

While "Stop WooCommerce from disabling webhooks" is on, WooCommerce's limit is raised so it keeps delivering. A successful replay resets WooCommerce's counter to 0.

= What if a payload is very large? =

Bodies over 256 KB are cut when stored. Such events are replayed by rebuilding the payload from current data.

= Which e-mail setups are supported? =

The default WordPress mailer and SMTP plugins built on it (WP Mail SMTP, Post SMTP and similar), plus any mailer plugin that reports failures through WordPress's wp_mail_failed action. Attachments are re-sent if the files still exist.

= What is never retried automatically? =

401/403 (credentials), 404/410 (URL gone) and other 4xx (payload rejected): a retry cannot fix them. Persjay Webhook Rescue alerts you instead. Action Scheduler tasks are never re-run automatically either, because a re-run can repeat side effects such as e-mails.

== Privacy ==

Persjay Webhook Rescue stores copies of failed outbound deliveries, which can contain customer data from orders or forms. Copies are encrypted, kept for the number of days you set in Settings (30 by default) and removed by WordPress's personal data eraser. Persjay Webhook Rescue sends no data to Persjay Apps.

== Screenshots ==

1. The overview: what needs you right now, every WooCommerce webhook and e-mail destination with its recent results, and the latest failed deliveries.
2. The failure log: failed deliveries on the left, the selected one on the right with the receiver's error and what to fix.
3. The inspector shows the exact request (headers and payload, with secrets masked) and tells you what to fix before you replay.
4. One click on Replay now sends the original payload again. The attempts list keeps every try and the receiver's response.
5. Settings: e-mail alerts, recovery notices, WooCommerce webhook protection and failed e-mail logging.

== Changelog ==

= 1.0.0 =
* First release.
