=== DebugPay Toolkit for Payfast ===
Contributors: ravikhadka
Tags: payfast, woocommerce, payment logs, payment gateway, diagnostics
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Payfast payment diagnostics for WooCommerce with local logs, ITN/callback checks, sandbox/live labels, and order debug reports.

== Description ==

DebugPay Toolkit for Payfast helps WooCommerce store owners, developers, and support teams investigate Payfast payment issues without changing the checkout flow or acting as a payment gateway.

Use it when Payfast payment activity appears successful but a WooCommerce order stays pending, failed, cancelled, on-hold, or unpaid. The plugin creates local payment logs, order debug panels, and copyable reports that make it easier to compare order activity, callback delivery, ITN observations, sandbox/live mode signals, and common mismatch symptoms.

The plugin is diagnostic-first. It records WooCommerce order creation events for Payfast-related orders, order status changes, likely Payfast ITN/callback metadata on recognized WooCommerce callback routes, and environment diagnostics. It does not change order statuses automatically.

This plugin does not include, register, enable, or replace a payment gateway. For full logging, your site must already have an active Payfast-compatible WooCommerce gateway that creates Payfast orders and receives Payfast callbacks. If no compatible gateway is detected, the admin screen shows setup diagnostics and a non-affiliated checklist.

DebugPay Toolkit for Payfast is an independent diagnostic tool and is not affiliated with, endorsed by, or sponsored by Payfast, WooCommerce, Woo, Automattic, or WordPress.

= Payfast and WooCommerce Diagnostics =

The plugin focuses on practical Payfast troubleshooting for WooCommerce stores:

* Payfast payment logs for order creation, status changes, and likely ITN/callback activity.
* Sandbox, live, or unknown mode labels based on safe signals such as gateway settings and endpoint hostnames.
* Gateway setup diagnostics when a Payfast-compatible WooCommerce gateway is missing or inactive.
* Order-level debug panels for support teams investigating unpaid or stuck orders.
* Human-readable reports for sharing with developers, hosting support, or gateway support teams.

= Key Features =

* Custom database table for local diagnostic logs.
* WooCommerce > DebugPay Toolkit admin page.
* Summary cards, AJAX filters, AJAX pagination, log detail view, CSV export, and clear logs action.
* Settings for logging, retention, maximum logs, customer data masking, and uninstall cleanup.
* WooCommerce order admin payment debug panel.
* Human-readable copyable debug reports.
* Issue classification for common payment/order mismatch scenarios.
* Site diagnostics for WooCommerce, Payfast gateway detection, SSL, permalinks, WP debug, and log table status.
* Setup guidance when no Payfast-compatible WooCommerce gateway is detected.
* Sandbox/live diagnostics that label activity as Sandbox, Live, or Unknown when safe signals are available.
* WordPress.org Live Preview blueprint for a quick browser-based demo environment.

= What This Plugin Does Not Do =

* It does not create, register, enable, or replace a Payfast payment gateway.
* It does not process payments or collect card or bank details.
* It does not automatically mark orders paid, cancel orders, or retry callbacks.
* It does not store Payfast passphrases, API secrets, passwords, or sensitive tokens.
* It does not claim official affiliation with Payfast, WooCommerce, Woo, Automattic, or WordPress.

= Privacy =

This plugin does not phone home, track usage, or load remote assets. It stores diagnostic data locally in your WordPress database.

The plugin avoids storing passwords, secrets, passphrases, API keys, sensitive tokens, and card or bank details. Diagnostic log rows include event details, order/payment identifiers, request IP address, and user agent to help administrators investigate callback delivery. Customer email and billing phone are not stored in log context and are masked in generated reports by default; report masking can be controlled in the plugin settings.

Sandbox/live diagnostics are read-only. The plugin may inspect safe gateway settings, endpoint hostnames, and callback context to label activity as Sandbox, Live, or Unknown. It does not modify gateway mode and does not read or store Payfast passphrases, API secrets, or sensitive credentials.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/debugpay-toolkit-for-payfast/`.
2. Activate the plugin from the Plugins screen.
3. Make sure a Payfast-compatible WooCommerce payment gateway is installed and enabled if you want full payment logging.
4. Open WooCommerce > DebugPay Toolkit.
5. Confirm logging is enabled and review diagnostics.

== Frequently Asked Questions ==

= Is this a Payfast payment gateway for WooCommerce? =

No. This plugin is a Payfast payment diagnostics and logging tool for WooCommerce. You still need an active Payfast-compatible WooCommerce gateway to accept payments and receive full logging.

= Will this fix Payfast orders that stay pending? =

No. The plugin does not change order status or alter payment processing. It helps identify why a Payfast-related WooCommerce order may remain pending, failed, cancelled, on-hold, or unpaid.

= Does this plugin change WooCommerce order statuses? =

No. The plugin only logs diagnostics and builds reports. It does not mark orders paid, cancel orders, or retry callbacks.

= Can it diagnose Payfast ITN or callback problems? =

Yes, it can log likely Payfast ITN/callback activity on recognized WooCommerce callback routes and show whether an ITN was observed. It does not take over gateway validation or guarantee that a callback was accepted by the payment gateway.

= Does this plugin validate Payfast signatures? =

Only when a verified value is available from a safe integration point. The plugin does not request or store your Payfast passphrase and does not replace the gateway validation flow, so callback observations usually show signature status as "Unknown" rather than pretending validation passed.

= Does it compare Payfast paid amount with the WooCommerce order total? =

Only when both values are safely available. If the plugin cannot confidently compare the paid amount and order total, the amount check remains "Unknown".

= Does it detect Payfast sandbox and live mode? =

The plugin labels activity as Sandbox, Live, or Unknown when safe signals are available from gateway settings, endpoint URLs, or callback context. If the mode cannot be verified confidently, it displays "Unknown".

= Does this plugin change sandbox or live mode? =

No. Sandbox/live diagnostics are read-only. If the mode cannot be verified confidently, the plugin displays "Unknown".

= What should I do if it shows "Gateway mode unknown"? =

Review your Payfast-compatible gateway settings and confirm whether the gateway is configured for sandbox or live credentials. The plugin will not modify that setting.

= What happens if WooCommerce or Payfast is inactive? =

The plugin does not fatal error. It shows an admin notice if WooCommerce is unavailable and reports Payfast gateway detection as no or unknown where appropriate. If no Payfast-compatible WooCommerce gateway is detected, it shows setup guidance and a checklist. It does not provide or enable a payment gateway.

= Is customer data stored in the logs? =

The plugin stores local diagnostic data such as event details, order/payment identifiers, request IP address, and user agent. Customer email and billing phone are not stored in log context and are masked in generated reports by default.

= Does the plugin send data to an external service? =

No. It does not phone home, track usage, or load remote assets. Diagnostic data is stored locally in your WordPress database.

= Can I delete plugin data on uninstall? =

Yes. Enable "Delete data on uninstall" in WooCommerce > DebugPay Toolkit before uninstalling.

== Screenshots ==

1. DebugPay Toolkit logs screen with Payfast payment diagnostics, filters, pagination, and issue labels.
2. WooCommerce order payment debug panel with timeline, mode labels, and copyable support report.
3. Setup and diagnostics view for Payfast-compatible gateway detection, sandbox/live mode, and site checks.

== Changelog ==

= 1.0.0 =
* Initial release of DebugPay Toolkit for Payfast, a WooCommerce payment diagnostics plugin for investigating Payfast order and payment issues.
* Added local Payfast payment logging for WooCommerce order creation, order status changes, and likely ITN/callback activity.
* Added AJAX log filters, pagination, log detail views, CSV export, and clear logs action for easier payment gateway troubleshooting.
* Added WooCommerce order admin debug panel with payment timeline, Payfast mode labels, diagnostic checks, and copyable support reports.
* Added sandbox/live diagnostics that label Payfast activity as Sandbox, Live, or Unknown when safe signals are available.
* Added setup diagnostics and checklist when no Payfast-compatible WooCommerce gateway is detected.
* Added issue labels for common payment gateway problems, including missing ITN callbacks, amount mismatch, merchant mismatch, duplicate ITN activity, and sandbox/live mismatch.
* Added privacy-aware masking and safeguards to avoid storing Payfast passphrases, API secrets, passwords, sensitive tokens, card details, or bank details.
* Added HPOS-compatible WooCommerce order diagnostics and safe behavior when WooCommerce or a Payfast-compatible gateway is inactive.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
