=== COD Guard Bosta Acceptance ===
Contributors: plugify
Tags: woocommerce, cash on delivery, cod, fraud prevention, bosta, blacklist
Requires at least: 6.5
Requires PHP: 7.4
Stable tag: 4.5.0
Requires Plugins: woocommerce

Checkout-only Bosta acceptance protection with customer-wide local restriction rules.

== Description ==

COD Guard Bosta Acceptance protects WooCommerce payment methods before order creation.

Current v4.4.4 checkout policy:

* Existing customers already indexed before the v4.3 upgrade cutoff are grandfathered and are not batch-screened against Bosta.
* Strong phone/email policy now has precedence over unrelated secondary name/address matches, preventing false Card Only decisions when an explicitly Allowed phone/email is used.
* The active-order duplicate guard now requires the open order to match the exact current phone or email, not merely another identity inside a large merged customer cluster.
* Restriction Inspector now shows the current local checkout decision, the exact reason code/source, related active order, recent Card Only history, and secondary signals when relevant.
* Active-order Card Only can be bypassed by an authenticated merchant for the exact phone/email for 2 hours; this bypass never overrides permanent blacklist or Bosta Orange/Red.
* Existing protected manual/cancel/return restrictions remain Restricted.
* New eligible Egyptian phone numbers are checked silently against Bosta during checkout.
* High / Green: all otherwise-available payment methods remain available.
* New / No Data / Grey: all otherwise-available payment methods remain available.
* Average / Orange: card payment only.
* Low / Red: card payment only.
* Non-Egyptian or incomplete phone: all otherwise-available payment methods remain available unless a local protected restriction matches.
* Temporary Bosta transport/API failure: one safe checkout retry is attempted when appropriate; if no reliable result is available, checkout fails open and all otherwise-available payment methods remain available. No permanent restriction is created from the API failure.
* Persistent manual/order/shipment restriction always has priority over Bosta acceptance.
* If a shopper already has an active non-terminal order that was created with the full payment-method set, a concurrent follow-up order is temporarily card-only until the first order reaches a terminal state. There is no day-based expiry. This duplicate-order guard never writes to the blacklist.
* WooCommerce cancellation may restrict the linked customer except when it is an unpaid card auto-cancel; confirmed Bosta cancel/return/refusal shipment states and protected local rules remain restrictive.
* Allow/Restrict is propagated across the linked customer identity record instead of affecting only the clicked phone/email.
* Checkout screening is silent; Bosta status/rate/reason are not exposed by the public checkout AJAX response.
* Classic Checkout and WooCommerce Checkout Blocks are protected server-side.

The plugin reads the Bosta API key already configured for the official Bosta WooCommerce integration. Historical/background Bosta customer scanning is disabled in the core plugin. The local customer database can still index WooCommerce history without making Bosta ranking requests.

== Installation ==

1. Back up WordPress files and the database.
2. Install/activate WooCommerce and the official Bosta WooCommerce plugin and configure its API key.
3. Upload this ZIP from Plugins > Add New > Upload Plugin and replace the previous COD Guard version.
4. Activate COD Guard Bosta Acceptance.
5. Open its settings and configure the customer-service/WhatsApp number and confirm the card gateway IDs.
6. Test the checkout matrix on staging before production.

== Important ==

Direct IP matching is intentionally controlled by the existing "Allow IP to block checkout directly" setting because shared/NAT IPs can belong to unrelated shoppers.

No plugin can guarantee compatibility with every third-party checkout/payment customization without a staging test. Final payment enforcement is also performed server-side so JavaScript alone is not trusted.
