=== MrAshitey SMS Connector ===
Contributors: mrashitey
Tags: sms, woocommerce, contact-form-7, otp, notifications
Requires at least: 6.2
Requires PHP: 7.4
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect WordPress and WooCommerce to MrAshitey SMS for order alerts, Contact Form 7 notices, account SMS and phone OTP verification.

== Description ==

MrAshitey SMS Connector links a WordPress website to a customer workspace on the central MrAshitey SMS platform. Upstream gateway credentials stay on the central platform; each connected site uses its own customer API key and approved Sender ID.

Features:

* Standalone MrAshitey SMS admin menu with separate sections for connection, WooCommerce, Contact Form 7, account alerts, OTP and manual sending.
* Dedicated, nonce-protected settings save handler with save verification.
* Manual Send SMS screen with country-code selector, phone number, custom message and approved Sender ID.
* Test connection, display available SMS credits, and refresh the account's approved Sender IDs.
* WooCommerce order status SMS templates for pending, processing, on-hold, completed, cancelled, refunded and failed orders.
* Contact Form 7 customer confirmations and optional administrator alerts after a successful form email.
* Optional WordPress account-created and password-changed notices. Passwords are never sent by SMS.
* Optional `[mrashitey_sms_otp]` six-digit phone code widget with expiry and rate limits.
* Server-side helper `masms_connector_send_sms( $to, $message, $sender = '', $idempotency_key = '' )` for custom integrations.
* Credentials are never printed into the settings form, and HTTPS certificate verification stays enabled.

== Installation ==

1. In your MrAshitey SMS customer dashboard, create an API key for this WordPress website.
2. In WordPress, go to Plugins > Add New Plugin > Upload Plugin and upload this ZIP, then activate it.
3. Open Settings > MrAshitey SMS.
4. Enter the HTTPS platform root URL (normally `https://sms.mrashitey.org`) and paste the `masms_...` API key.
5. Click Save all settings. A successful-save message confirms the configuration was stored.
6. Click Test connection, then Refresh approved Sender IDs.
7. Choose an approved Sender ID, save again, and enable only the notification integrations you want.
8. Send a controlled test SMS to a number you own before enabling customer-facing notifications.

== Configuration ==

WooCommerce: enable the integration, choose statuses, and edit the corresponding message templates. Successful notification sends are stored as order metadata to avoid accidental duplicate sends for the same order/status.

Contact Form 7: enable customer confirmation, enter the exact name of the form's phone field, and optionally configure an admin alert phone number.

WordPress account events: enable account notifications and set the primary user-meta key containing a member's phone number. The connector also checks common phone meta keys as fallbacks.

Phone OTP: enable the feature and add `[mrashitey_sms_otp]` to a page. The widget confirms the phone code in the browser and fires a `mrashitey:otp-verified` browser event after successful verification. Do not treat a client-side event as authorization for a payment or other sensitive action; such workflows must perform their own server-side identity verification.

Custom integration: call `masms_connector_send_sms( $to, $message, $sender, $idempotency_key )` from server-side PHP. Use a stable unique idempotency key for safe retries of a single business event. The helper returns the decoded API success array or a `WP_Error`.

== Security and privacy ==

* The API key is saved on the connected WordPress site and used server-side. Give each site its own API key and revoke a site's key when it is no longer trusted.
* When you enable an integration, phone numbers and the configured SMS message are sent to the central MrAshitey SMS platform to deliver the requested message. The platform may record message metadata and billing usage as part of its service. Update your site privacy disclosures accordingly.
* Do not put API keys in public JavaScript, page source, URLs, or client-side code.
* Request phone location/data only where necessary and publish appropriate privacy disclosures for SMS and OTP workflows.
* Keep WordPress, this connector, WooCommerce and Contact Form 7 up to date.

== Frequently Asked Questions ==

= Why does Test connection fail? =
Confirm that the central MrAshitey SMS platform is reachable, the API key is active and belongs to an active customer workspace, and the URL is the website root such as `https://sms.mrashitey.org`.

= Why is a Sender ID rejected? =
Only sender IDs approved on the connected customer workspace can be used. Refresh the Sender ID list and select an approved value.

= Why are WooCommerce messages not sent? =
Confirm WooCommerce is active, the integration and order status are enabled, the order has a billing phone number, the connected wallet has credits, and the sender ID is approved.

= Does this plugin need MrAshitey SMS installed on the client website? =
No. It connects remotely to the central MrAshitey SMS platform using the REST API.

== Changelog ==

= 1.0.2 =
* Refresh the connected SMS-credit balance automatically after each accepted SMS, without requiring a manual connection test. A balance-refresh failure does not alter the result of the accepted SMS.


= 1.0.0 =
* First separate connector release based on the MrAshitey SMS v2.9.42 REST API contract.
* Added a reliable explicit settings save flow, API connection testing and approved Sender ID refresh.
* Added WooCommerce, Contact Form 7, WordPress account notification, OTP shortcode and custom PHP helper integrations.
