=== OTP Wire OTP ===
Contributors: otpwire
Tags: otp, one-time-password, whatsapp, email, verification, authentication
Requires at least: 6.2
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.9.0
License: GPLv2 or later

Add OTP Wire verification to any WordPress page, form, or WooCommerce flow. The plugin sends OTP requests from your WordPress server, so the API key is never exposed to visitors.

== Installation ==
1. In WordPress, open Plugins > Add New Plugin > Upload Plugin.
2. Select the `otpwire-otp.zip` package and activate OTP Wire OTP.
3. Open OTP Wire in the admin menu.
4. Enter the API base URL and a dedicated API key from your OTP Wire application.
5. Set the application ID, webhook secret, channel, application name, support number, template key, validity period, and message language.
6. Save the settings and use **Test connection**. This validates the API key without sending an OTP.
7. Configure the displayed webhook endpoint and the same secret in OTP Wire → Webhooks. Set the application ID so the site ignores events for other applications in the organization.
8. If using WooCommerce classic checkout or the Checkout block, enable its OTP requirement in the plugin settings.
9. In Widget branding, choose the site logo, button colors, corner radius, and whether to show the optional OTP Wire credit. Review changes in the live preview before saving.

== WooCommerce customer accounts ==
Enable WooCommerce accounts in OTP Wire settings to offer WhatsApp sign-in on My Account. The native password form remains available. Use a Live OTP Wire key and enable WhatsApp on the application. For the default registration mode, enable Email too. New accounts follow the WooCommerce registration setting for My Account or checkout.

Follow **Set up customer sign-in** at the top of OTP Wire settings. Save the API URL and key, test the connection, then send a test code to your own number. Preview the branding before enabling WhatsApp sign-in. Test delivery consumes trial allowance or wallet balance.

Existing customers first sign in with their password and link a WhatsApp number from the account dashboard. A billing phone alone is insufficient. By default, new customers verify WhatsApp, enter their name and email, and verify the email code. If that email already belongs to an account, they must sign in to that account and link their number. Use a test site to verify compatibility with store-specific account restrictions before enabling this optional login method.

Customers can choose a country or paste a full international number. The verification screen displays the destination and lets customers edit their WhatsApp number or resend the code once the countdown ends.

Enable **WhatsApp sign-in at checkout** for Classic and Checkout Blocks. Signed-in and newly registered customers continue on checkout with their cart. **Require a verified OTP before an order can be placed** still controls order verification independently.

Under **WhatsApp registration**, choose whether email verification is required and set the name field to required, optional, or hidden. With phone-only registration, WooCommerce collects a valid billing email before placing an order. This is the order contact. Email-based account recovery requires an account email.

In **My Account → WhatsApp sign-in and recovery**, customers can verify a replacement number or disconnect WhatsApp. A verified replacement revokes the old number and signs out other sessions. Customers who registered by phone can add a recovery email with a separate email code, then use WooCommerce's password reset. They need a confirmed recovery email to disconnect their WhatsApp number. Security changes require signing in again if the latest sign-in was more than 15 minutes ago.

Under **Widget branding**, edit the account form copy in English and Arabic. Preview the sign-in form in either language while choosing its colors.

== Add the verification form ==
Add this shortcode to any page, post, or shortcode block:

[otpwire_otp]

Optional wording:

[otpwire_otp title="Verify your account" button="Send code"]

Choose the purpose and channel for individual forms:

[otpwire_otp title="Create account" channel="whatsapp" purpose="signup"]
[otpwire_otp title="Confirm order" channel="whatsapp" purpose="transaction"]
[otpwire_otp title="Verify email" channel="email" purpose="recovery"]

== Settings ==
* API base URL: use the URL for your OTP Wire environment, including `/api`.
* API key: create a separate key for each website. The key stays server-side. Leaving the password field empty keeps the saved key.
* Webhook secret: shared with the OTP Wire webhook configuration and used to verify the HMAC signature.
* Application ID: filters organization webhooks to the application connected to this site.
* Template key: use a template key enabled for the selected channel and locale.
* Application name: shown in the OTP message so customers know which site requested the code.
* Support phone: shown as the support contact, including its country code.
* OTP validity: 1–10 minutes. The API enforces this duration.
* Channel, purpose, code length, and message language are configurable.
* WhatsApp destinations: allow all calling codes, use the Middle East preset, or enter your own codes (for example, +963, +966, +971). Restrictions use the recipient's phone number prefix, rather than physical location, and apply to sends from this WordPress site. Email verification is unaffected.
* Widget branding: optionally use the active theme logo or a custom media-library image, choose accessible button colors and corner radius, and preview the result before saving.

WhatsApp message wording and approved templates are managed by the OTP Wire provider configuration. The WhatsApp sender display name is managed by the connected WhatsApp Business account.

== Security and privacy ==
The API and webhook secrets are stored in WordPress options and never printed into page markup. API calls are server-to-server. The plugin applies a per-recipient resend cooldown, and OTP Wire enforces account and recipient limits as well. Local activity keeps only masked recipients and the 200 most recent operations.

The Usage page loads per-key requests and charges from `GET /sdk/v1/usage` when the API version provides it, then falls back to the site's local log. The endpoint returns masked recipients and a maximum of 50 recent records. On older API releases, **Test connection** can still check the saved key without sending an OTP. Webhook delivery attempts and their transport failures remain available in the OTP Wire dashboard.

When enabled, WooCommerce checkout (classic or block) displays the OTP widget and blocks order placement until a verified OTP matches the billing email or phone. For WordPress core login/registration and other form builders, shortcodes support `login`, `signup`, `transaction`, `recovery`, and `custom` purposes and fire the PHP action `otpwire_otp_verified` and browser event `otpwire:verified`; the target form/theme must enforce its own submit rule.

== Changelog ==

= 1.9.0 =
* Add WooCommerce customer sign-in and registration on Classic checkout and Checkout Blocks.
* Add a calling code selector, support Arabic numerals, and display the verification destination.
* Add phone-only registration, name field options, and English and Arabic form customization.
* Let customers replace or disconnect their WhatsApp login number and verify a recovery email for phone-only accounts.

= 1.8.1 =
* Add a resend countdown for WooCommerce account codes and let customers change their WhatsApp number from the verification screen.
* Show the latest failed send in the plugin settings to help troubleshoot delivery.

== Support ==
Visit https://otpwire.com/ for product documentation and support.
