=== CODShield AI – Cash on Delivery (COD) Fraud Shield ===
Contributors: zipnom
Tags: woocommerce, cash on delivery, cod, fraud, whatsapp
Requires at least: 5.8
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 1.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Prevent fake COD orders with WhatsApp confirmations, fraud checks, and smart automation to reduce RTO and cancellations.

== Description ==

**CODShield AI** helps WooCommerce stores reduce fake Cash on Delivery (COD) orders and RTO losses. It can verify suspicious orders over **WhatsApp** (free, single built-in message) and optionally via **Voice IVR calls** (PRO). You also get an **Analytics** area to track confirmations, risk distribution, and performance over time, plus an **Orders Details** table with filters and CSV export.

> **Note:** “WhatsApp” is a trademark of Meta Platforms, Inc. This plugin is not affiliated with or endorsed by WhatsApp/Meta.

### Key Features

- **Cash On Delivery Fraud Shield – Powered by AI**
  - Basic risk checks in free plugin; works with your COD flow.
  - Auto-hold or flag risky COD orders before fulfillment.
  - Clear audit trail via WooCommerce order notes.

- **WhatsApp Order Confirmation**
  - Sends a message after order creation with **Confirm** / **Cancel** links.
  - Uses a **single built-in message** (no custom/multi templates in this version).
  - Order status/notes update automatically on customer action.

- **Voice IVR Order Confirmation (PRO)**
  - Automated phone call asks the buyer to confirm/cancel via keypad.
  - Real-time callback updates the WooCommerce order.

- **Analytics Dashboard**
  - **Orders & Revenue Trend** bar chart.
  - **Fraud Risk Distribution** donut (Legitimate, Low/Medium/High risk, Blocked).
  - **WhatsApp & Confirmation Analytics** cards (messages sent, confirmed, not confirmed, fraud detected/reported).
  - Date range selector and quick “7 Days” preset.

- **Orders Details**
  - Search bar + filters (Status, WhatsApp, Voice Calls, Scores, Orders).
  - Columns: Order #, Date, Customer, Status, Total, WhatsApp, Voice Call, Fraud Score, Admin Reported.
  - **Export Orders** to CSV.

- **License & Store**
  - Enter license key and store ID; see active/expired status and time remaining.

- **Modules (Add-ons)**
  - Manage installed modules and browse extensions (if enabled in your account).

### How It Works

1. Customer places a **COD** order.
2. Plugin runs risk checks and, when required:
   - **Free:** sends WhatsApp confirmation (single built-in message).
   - **PRO:** may trigger a Voice IVR call if messages fail or are ignored.
3. Customer confirms/cancels; the plugin updates order notes/status accordingly.
4. View overall performance in **Analytics** and drill into **Orders Details**.

### Free vs PRO

- **Free**: AI-gated COD checks, WhatsApp confirmation (single built-in message), order notes, Analytics (trends, risk distribution), Orders Details with filters + CSV export, License screen.
- **PRO**: Adds **Voice IVR confirmation** and advanced options controlled by your CODShield AI account.

== Installation ==

1. Install and activate **CODShield AI** (Plugins → Add New).
2. Ensure **WooCommerce** is active.
3. Go to **CODShield AI → License & Keys** (or WooCommerce settings tab) and:
   - Enter your **License Key** and **Store ID**.
   - (PRO) Enable IVR and set call behavior/fallback.
4. Save. New COD orders will be checked and, if needed, verified.

== Usage ==

- **WhatsApp Message**: One built-in template that includes order reference + your store/site name, with **Confirm** / **Cancel** links. (Custom or multiple templates are **not available** yet.)
- **Recommended flow**: Keep new COD orders **On hold** until confirmed; move to **Processing** after confirmation.

== Frequently Asked Questions ==

= Can I edit the WhatsApp text or add multiple templates? =
Not in this version. A single built-in message is used for confirmation.

= Does it support prepaid orders? =
The verification flow is designed for COD. You can still log events for prepaid orders if you enable that option.

= Will it slow down checkout? =
No. Verification runs asynchronously after order creation.

= What data can be sent to external services? =
When enabled, the plugin may send order ID, COD flag, order total, customer name, phone number, and confirmation URLs to your configured backend/provider solely to complete verification.

== Screenshots ==

1. **Analytics – Summary & Trends** (cards for Total Orders/Revenue/Fraud Blocked/Success Rate, bar chart for Orders & Revenue Trend)
2. **Analytics – Risk Distribution** (donut chart for Legitimate/Low/Medium/High/Blocked, date range + quick preset)
3. **WhatsApp & Order Confirmation Analytics** (messages sent, confirmed, not confirmed, fraud detected/reported, Export CSV)
4. **Orders Details** (search, filters for Status/WhatsApp/Voice Calls/Scores/Orders, table with WhatsApp, Voice Call, Fraud Score, Admin Reported, Export Orders)
5. **License & Store** (license key + store ID, active/expired state, time remaining)
6. **Modules** (installed modules overview and browse add-ons)

== Privacy ==

This plugin can connect to an external service (your configured CODShield AI backend / messaging or IVR provider) to perform AI risk checks, send WhatsApp messages, and/or place IVR calls.  
**Data potentially transmitted:** order ID, order total, COD/payment method, customer name, phone number, and confirmation URLs.  
**Purpose:** verify buyer intent and reduce COD fraud/RTO.  
**Retention:** depends on your provider; review their policy.  
**Consent:** disclose verification via WhatsApp/IVR in your store policies and ensure a lawful basis for processing phone numbers for fraud prevention.

== External Services ==

- **CODShield AI Cloud / Messaging & IVR Provider** – used for risk scoring, WhatsApp delivery, and IVR calls when enabled. You control the endpoint/keys in plugin settings.

== Changelog ==

= 1.1.1 - 2025-09-08 =
* Dashboard – License status colors fixed: inactive now renders red; “Get free license” CTA shows only when inactive.
* Dashboard – **Store Usage** is accurate and data-driven: shows connected **store count** vs **plan limit**, with remaining, plan label, and expiry; progress bar now exposes ARIA attributes.
* Navigation – Added **Upgrade** button to top nav; opens subscriptions page in a new tab.
* Dashboard – Added dynamic CTA: **Manage account** when active, **Get free license** when inactive.
* Licensing – Activation/deactivation now updates all labels/badges/buttons consistently.
* Sync – Persist additional API fields: `totalUsageCount`, `fraudUsageCount`, `confirmationUsageCount`, store details, admin user; plan and expiry stored directly from API.
* Misc – Minor CSS polish and reliability fixes.

= 1.1.0 - 2025-09-05 =
* Implemented WhatsApp confirmation feature.
* Implemented plugin page assets (banner/icons/screenshots).
* Implemented performance improvements.
* Implemented security hardening.

= 1.0.0 =
* Initial release with AI-gated COD checks, WhatsApp confirmation (single built-in message), Analytics dashboard, Orders Details with filters + CSV export, License screen, and (PRO) Voice IVR confirmation.

== Upgrade Notice ==

= 1.1.1 =
Fixes license status colors and makes the Store Usage card accurate (uses connected stores and plan limits). Adds Upgrade nav button and dynamic Manage account CTA. Recommended update.

= 1.1.0 =
Adds WhatsApp confirmations, assets, and general performance/security improvements. Recommended update.

= 1.0.0 =
Review settings before going live. Configure license, WhatsApp confirmation, and (PRO) IVR options.

== Support ==

- Use the **Support** tab on the plugin page for community help.
- PRO license/account issues: contact your CODShield AI support channel.
