=== Wayl Checkout ===
Contributors: wayl
Tags: payment, checkout, wayl, woocommerce, iraq
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 5.0
WC tested up to: 8.5

Enable Wayl Checkout payments in your WooCommerce store. Accept online payments via Visa/MasterCard, ZainCash, FIB, and FastPay.

== Description ==

Wayl Checkout is the official WooCommerce payment gateway for Wayl, a licensed payment facilitator built for the Iraqi market. Accept cards and local wallets in one native checkout, with full IQD and USD support, real-time status updates, and refunds handled directly from WooCommerce.

=== About Wayl ===

Wayl is a licensed payment facilitator focused on enabling digital commerce in Iraq. The platform connects merchants with local and international payment methods through a single, secure integration. Wayl Checkout brings that capability into WooCommerce so store owners can accept payments from Iraqi and international customers without managing multiple providers.

=== Supported Payment Methods ===

* Iraqi local Visa and MasterCard
* International Visa and MasterCard
* ZainCash
* First Iraqi Bank (FIB)
* FastPay

All methods are available in one checkout flow. No separate integrations or plugins required.

=== Why Wayl Checkout ===

* **Dual currency:** Full support for Iraqi Dinar (IQD) and US Dollar (USD), with conversion handled where applicable.
* **Security:** Webhook signature verification and encrypted API communication. No card data is stored in WordPress.
* **Real-time updates:** Payment status is updated in WooCommerce as soon as Wayl confirms the transaction.
* **Refunds:** Process full refunds from the WooCommerce order screen; the plugin syncs with Wayl automatically.
* **Native WooCommerce:** Registers as a standard payment method. Orders, emails, and reports work as with any other gateway.
* **Simple setup:** Configure with your Wayl API credentials; no coding required. Setup wizard and logging available for troubleshooting.

=== Requirements ===

* WordPress 5.0 or higher
* WooCommerce 5.0 or higher
* PHP 7.4 or higher
* SSL certificate (required for live payments)

=== العربية (Arabic) ===

وايل تشيك أوت هو بوابة الدفع الرسمية لـ WooCommerce من وايل، مزود دفع مرخص مصمم للسوق العراقي. قبول البطاقات والمحافظ المحلية في صفحة دفع واحدة، مع دعم الدينار العراقي والدولار الأمريكي، وتحديثات فورية للحالة، واسترداد المبالغ مباشرة من WooCommerce.

**عن وايل:** وايل مزود دفع مرخص يركز على تمكين التجارة الرقمية في العراق. تربط المنصة التجار بوسائل الدفع المحلية والدولية من خلال تكامل واحد وآمن. وايل تشيك أوت يجلب هذه الإمكانية إلى WooCommerce لتمكين أصحاب المتاجر من قبول المدفوعات من العملاء العراقيين والدوليين دون إدارة عدة مزودين.

**وسائل الدفع المدعومة:** فيزا وماستركارد المحلية العراقية، فيزا وماستركارد الدولية، زين كاش، البنك العراقي الأول (FIB)، فاست باي. جميع الوسائل متاحة في تدفق دفع واحد.

**لماذا وايل تشيك أوت:** دعم العملتين (IQD و USD)، أمان عبر التحقق من توقيع الويب هوك والتشفير، تحديثات فورية لحالة الدفع، استرداد المبالغ من شاشة الطلب في WooCommerce، تكامل أصلي مع WooCommerce، وإعداد بسيط باستخدام بيانات الاعتماد من وايل.

== External Services ==

This plugin connects to the Wayl payment API to create payment links and process transactions.

Service: Wayl Payment API
URL: https://api.thewayl.com

Data sent:
- Order ID
- Order total
- Currency
- Line items
- Redirect URL
- Webhook URL

Data is sent:
- When customer places an order
- When verifying payment via webhook

Terms of Service: https://www.wayl.io/terms
Privacy Policy: https://www.wayl.io/privacy

== Third-Party Service Information ==

This plugin integrates with Wayl's payment processing service to enable secure payment transactions.

**What is Wayl?**

Wayl is a payment processing service that provides secure checkout functionality for e-commerce transactions, with a focus on supporting payments in Iraq (IQD) and other currencies.

**What data is sent to Wayl and when?**

The following data is transmitted to Wayl's API (https://api.thewayl.com/api/v1):

**During Checkout (when customer clicks to pay):**
* Order reference ID (generated by the plugin)
* Order total amount and currency
* Line items (products, shipping, taxes, fees, discounts)
* Customer redirect URL (order confirmation page)
* Webhook URL (for payment status updates)
* Payment page language preference
* Product names and images (if available)

**During Webhook Processing (when Wayl sends payment status):**
* Webhook signature verification
* Payment status updates
* Order status updates

This data is sent **only when a customer initiates a payment** during the checkout process. The plugin does not send any data to Wayl until a payment is initiated.

**What data is received from Wayl?**

When Wayl processes a payment, it sends webhook notifications to your site containing:

* Payment status (Paid, Failed, etc.)
* Payment method and processor information
* Transaction details
* Customer information (name, phone) if provided during payment

**Privacy and Service Terms:**

* Wayl Privacy Policy: https://www.wayl.io/privacy
* Wayl Terms of Service: https://www.wayl.io/terms
* Wayl Website: https://www.wayl.io/

**User Consent:**

By using this payment method, customers consent to having their payment information processed by Wayl according to Wayl's privacy policy and terms of service. The plugin itself does not store payment card details or sensitive payment information.

**Privacy Statement:**

This plugin does not track users. No user tracking, analytics, or personal data collection is performed by this plugin beyond what is necessary for payment processing through Wayl's service.

== Support ==

**Need Help?**

* **Email Support**: support@wayl.io
* **WhatsApp Support**: +964 775 227 7781
* **Website**: https://www.wayl.io
* **Dashboard**: https://dashboard.thewayl.com

**Common Issues:**

* **Payment not processing**: Check that your API key is correct and your account is active
* **Webhook not working**: Ensure your server can receive POST requests and the webhook URL is accessible
* **Currency conversion issues**: Make sure your WooCommerce store currency is set to USD when using IQD mode
* **Payment methods not showing**: Verify your API key is valid and your account has payment methods enabled

== Privacy & Security ==

**Data Privacy:**
* This plugin does not store payment card details or sensitive payment information
* Payment data is processed securely through Wayl's encrypted API
* Customer consent is required for payment processing
* No user tracking or analytics are performed by this plugin

**Security Features:**
* Webhook signature verification
* Secure HTTPS communication
* Input sanitization and output escaping
* WordPress security best practices
* Regular security updates

**Third-Party Services:**
* This plugin integrates with Wayl's payment processing service
* Payment data is transmitted to Wayl's secure API (https://api.thewayl.com)
* Wayl Privacy Policy: https://www.wayl.io/privacy
* Wayl Terms of Service: https://www.wayl.io/terms

== Webhook Setup ==

The plugin automatically generates a webhook secret and URL. The webhook URL will be:
`https://yourdomain.com/?wc-api=waylchp_webhook`

Make sure this URL is accessible and your server can receive POST requests.

== Logging ==

When logging is enabled, the plugin creates log files in:
`wp-content/uploads/wayl-checkout/`

Log files are created daily and include:
- API requests and responses
- Webhook processing
- Payment status updates
- Error messages

== Screenshots ==

1. Modern checkout interface with multiple payment options
2. Easy-to-use admin settings page with setup wizard
3. Payment method selection (Visa, MasterCard, ZainCash, FIB, FastPay)
4. Order management with refund capabilities
5. Real-time payment status updates

== Frequently Asked Questions ==

= What payment methods does Wayl support? =

Wayl Checkout supports Iraqi local and international Visa/MasterCard, ZainCash, FIB (First Iraqi Bank), and FastPay. All payment methods are aggregated in one unified checkout solution. Accept payments from both Iraqi local cards and international cards.

= What currencies are supported? =

The plugin supports Iraqi Dinar (IQD) and US Dollar (USD). For IQD mode, your WooCommerce store must be configured to use USD as the base currency, and the plugin will handle the conversion.

= How do I get an API key? =

1. Register your account at dashboard.thewayl.com
2. Submit your merchant information
3. Contact Wayl Support via email (support@wayl.io) or WhatsApp (+964 775 227 7781) to obtain your Merchant Token API Key
4. Add your API key in WooCommerce > Settings > Payments > Wayl

= Is this plugin secure? =

Yes, the plugin follows WordPress security best practices and includes:
* Webhook signature verification
* Secure API communication (HTTPS)
* Input sanitization and output escaping
* No storage of sensitive payment data
* Regular security updates

= Can I use this plugin in test mode? =

Yes, you can use test API keys provided by Wayl for development and testing before going live.

= How do refunds work? =

You can process refunds directly from the WooCommerce order management page. The plugin will automatically refund the full order amount to the customer through Wayl's API.

= Do I need technical knowledge to set up this plugin? =

No, the plugin includes a simple setup wizard and clear instructions. Basic WordPress and WooCommerce knowledge is sufficient.

= Is this plugin suitable for Iraqi merchants only? =

While Wayl is designed for the Iraqi market, it supports both Iraqi local and international Visa/MasterCard cards, making it suitable for merchants serving customers in Iraq and internationally.

= What languages are supported? =

The plugin supports both Arabic and English. You can configure the payment page language in the plugin settings.

= How do I monitor my payments? =

All payments can be monitored through the Wayl dashboard at dashboard.thewayl.com. The plugin also provides order status updates in WooCommerce.

== Installation ==

1. **Upload the plugin:**
   * Upload the plugin files to `/wp-content/plugins/wayl-checkout/`, or
   * Install the plugin through the WordPress admin interface by searching for "Wayl Checkout"

2. **Activate the plugin:**
   * Go to Plugins > Installed Plugins
   * Find "Wayl Checkout" and click "Activate"

3. **Configure the plugin:**
   * Go to WooCommerce > Settings > Payments
   * Find "Wayl" in the payment methods list
   * Click "Manage" to configure your API key and settings

4. **Get your API key:**
   * Register at dashboard.thewayl.com
   * Contact Wayl Support (support@wayl.io or +964 775 227 7781) to obtain your Merchant Token API Key
   * Enter your API key in the plugin settings

5. **Go live:**
   * Save your settings
   * Test a transaction in test mode (if available)
   * Start accepting payments from your customers

== Configuration ==

**Required Settings:**

1. **API Key** (Required)
   * Contact support@wayl.io or WhatsApp +964 775 227 7781 to obtain your Merchant Token API Key
   * Enter the API key in the "API Key" field

2. **Language** (Optional)
   * Choose between Arabic (ar) or English (en) for the payment page
   * Default: English

3. **Currency Mode** (Optional)
   * **Site Currency**: Use your store's default currency
   * **Force IQD**: Convert USD to Iraqi Dinar (requires USD as site currency)

4. **Logging** (Optional)
   * Enable to log API requests and responses for debugging
   * Logs are stored in `wp-content/uploads/wayl-checkout/`
   * Recommended: Enable during setup, disable in production

**Recommended Settings:**

* Enable the payment method for your store
* Set a clear payment method title and description
* Test the integration before going live
* Monitor your first few transactions

== Changelog ==

= 1.0.0 =
* Initial production release for WordPress.org
* Payment facilitator for WooCommerce: Visa/MasterCard, ZainCash, FIB, FastPay
* IQD and USD support with Arabic and English
* Secure processing with webhook verification and refund support
* Admin settings with setup wizard and comprehensive logging

== Upgrade Notice ==

= 1.0.0 =
Initial production release. Enable Wayl Checkout payments in your WooCommerce store.

== Developer Information ==

**Plugin Structure:**
* Main plugin file: `wayl-checkout.php`
* Payment gateway class: `includes/class-waylchp-payment-gateway.php`
* API client: `includes/class-waylchp-api.php`
* Webhook handler: `includes/class-waylchp-webhook-handler.php`
* Logger: `includes/class-waylchp-logger.php`

**Hooks & Filters:**
* `waylchp_payment_channels` - Filter payment channels before display
* `waylchp_checkout_data` - Filter checkout data before API call
* `waylchp_webhook_data` - Filter webhook data before processing

**API Endpoints:**
* Checkout: `https://api.thewayl.com/api/v1/checkout`
* Refund: `https://api.thewayl.com/api/v1/refunds`
* Webhook: `https://yourdomain.com/?wc-api=waylchp_webhook`

**Requirements:**
* WordPress 5.0+
* WooCommerce 5.0+
* PHP 7.4+
* SSL certificate (for production)
* cURL extension enabled
