=== OrderProof – OTP Order Verification for WooCommerce ===
Contributors: medsalemkhattat
Tags: whatsapp otp, cash on delivery, fake orders, order verification, woocommerce
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.2.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Verify Cash on Delivery orders with a WhatsApp OTP code (no SMS). Block fake COD orders, duplicate orders and blacklisted customers in WooCommerce.

== Description ==

Fake Cash on Delivery orders cost you shipping, return fees and stock that sits in a courier van. **OrderProof** makes every COD customer prove their phone number before you ship: they receive a one-time code on **WhatsApp** and type it to confirm the order.

No SMS gateway, no per-SMS bills: codes are sent from **your own WhatsApp Business number** through Meta's official WhatsApp Cloud API. It works for customers in any country.

= How WhatsApp OTP verification works =

1. A customer places a Cash on Delivery order.
2. The order waits in **"Awaiting WhatsApp verification"**. It holds no stock and no "New order" email is sent yet.
3. The customer gets a 6-digit code on WhatsApp and types it on the verification page (with a copy-code button in WhatsApp).
4. The order becomes a real order: stock is reserved and your usual emails go out.
5. Orders that are never verified are cancelled automatically after a few hours.

Test mode lets you try the whole flow before you connect WhatsApp: the code is shown on the verification page instead of being sent.

= Free features =

* **WhatsApp OTP verification** for Cash on Delivery orders (WhatsApp Cloud API, no SMS)
* **Worldwide phone validation**: numbers are read with the calling code of the customer's billing country
* **Duplicate order limit**: max X orders per phone number in Y hours
* **Blacklist** phone numbers, emails and IP addresses, one click from the order page
* **Order statuses**: "Awaiting WhatsApp verification", "Awaiting confirmation" and "Delivery refused" (which restocks products)
* **One-click WhatsApp confirmation** message from the order page ({name}, {items}, {total}, {address}…)
* **Customer history** on every order: delivered vs refused orders
* Classic checkout **and** the Checkout block, with or without HPOS
* Translation-ready (French and Arabic translations coming to translate.wordpress.org)

= OrderProof Pro =

* **Smart OTP**: skip the WhatsApp code for trusted repeat customers
* **Risk score (0–100)** on every order, and automatic blocking of high-risk customers
* **Auto-blacklist** after X refused deliveries
* **More WhatsApp templates**: shipped, out for delivery…
* **Delivery success-rate report**

== Installation ==

1. Install and activate the plugin.
2. Go to **WooCommerce → Settings → OrderProof**.
3. Turn on **WhatsApp OTP** and **Test mode** to try the flow on your store.
4. To send real codes, follow the guide on the settings page: create a WhatsApp Business app in Meta for Developers, create an approved message template of the **Authentication** category (with a copy-code button), and enter your Phone number ID, access token and template name. Then turn Test mode off and use "Send test code" to check the setup.

== Frequently Asked Questions ==

= Does OrderProof send SMS? =
No. Codes are only sent on WhatsApp, from your own WhatsApp Business number.

= What does WhatsApp verification cost? =
OrderProof does not charge per message. Meta bills your WhatsApp Business account for each authentication message; prices depend on the customer's country and are listed on Meta's pricing page.

= Which countries are supported? =
All of them. Each phone number is read with the calling code of the customer's billing country, so a store in France can verify customers in Belgium, Morocco or Canada.

= What happens if a customer never enters the code? =
The order stays in "Awaiting WhatsApp verification" without holding stock, and is cancelled after the number of hours you choose (2 by default).

= Does it work with other payment methods? =
Phone rules, limits and the blacklist can protect every payment method (uncheck "Only Cash on Delivery orders"). WhatsApp OTP applies to Cash on Delivery orders.

== External services ==

This plugin connects to the **WhatsApp Business Platform (Cloud API)**, operated by Meta Platforms, Inc., to deliver one-time verification codes.

* **When:** only if you turn on WhatsApp OTP, turn Test mode off and enter your own Cloud API credentials; then each time a Cash on Delivery order needs verification or the customer asks for a new code.
* **What is sent:** the customer's phone number, the one-time code, and the name and language of your message template, to `https://graph.facebook.com/` with your access token.
* **Terms:** https://www.whatsapp.com/legal/business-terms
* **Privacy policy:** https://www.whatsapp.com/legal/privacy-policy

No other data leaves your site, and nothing is sent while WhatsApp OTP is off or in Test mode.

== Screenshots ==

1. The WhatsApp verification page customers see after a Cash on Delivery order.
2. Order page: verification status, customer history and the WhatsApp confirmation button.
3. Settings: WhatsApp OTP, phone rules, duplicate limits and blacklist.

== Changelog ==

= 1.2.2 =
* Admin and verification-page CSS and JavaScript are now loaded with wp_enqueue_style / wp_enqueue_script.
* Translations are delivered by translate.wordpress.org.

= 1.2.1 =
* Faster orders list: each customer's order history is looked up once per page load.
* Plugin name in readme.txt now matches the plugin header.

= 1.2.0 =
* New: step-by-step guide on the settings page for connecting your own WhatsApp Business number.
* New: "Send test code" button that sends a real code to your WhatsApp and shows Meta's exact error if the setup is wrong.

= 1.1.0 =
* New name: OrderProof (formerly COD Guard).
* New: WhatsApp OTP verification for Cash on Delivery orders through the WhatsApp Cloud API. No SMS.
* New: worldwide phone numbers, read with each customer's billing country calling code.
* New: "Awaiting WhatsApp verification" order status; unverified orders hold no stock and are cancelled automatically.
* Fix: the store's "New order" email and the customer's "Processing" email are now sent for orders that use OrderProof statuses.

= 1.0.1 =
* Fix: on stores using the classic order storage, the per-phone order limit and customer history counted every order in the store instead of only that customer's orders.

= 1.0.0 =
* First release.
