=== MIA Payment Gateway for VictoriaBank (Community Edition) ===
Contributors: inginerit
Tags: woocommerce, payment gateway, mia, instant payments, moldova
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 2.1.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Community-developed payment gateway for accepting MIA instant payments through VictoriaBank for WooCommerce stores in Moldova.

== Description ==

MIA Payment Gateway for VictoriaBank (Community Edition) is an independently developed payment gateway that enables WooCommerce merchants to accept instant payments through Moldova's MIA (Moldova Instant Payments) system via VictoriaBank's Business IPS Integration API v2.0.15.

**This is a community-developed plugin and is not officially affiliated with or endorsed by VictoriaBank.**

= Key Features =

* **DYNM QR Codes** - Dynamic QR codes with configurable Time-To-Live (TTL)
* **Mobile Deeplink** - Direct payment via `mia://pay` mobile deeplink
* **Token Caching** - Optimized API calls with automatic token caching (reduces API calls by 98%)
* **AJAX Polling** - Automatic real-time payment status updates
* **Full Refunds** - Complete refund support via VictoriaBank API
* **Webhook Support** - JWT signature verification for secure payment notifications
* **Comprehensive Logging** - Detailed debug information when WP_DEBUG is enabled
* **HPOS Compatible** - Full support for WooCommerce High-Performance Order Storage

= Payment Flow =

1. Customer selects MIA Instant Payment at checkout
2. Dynamic QR code is generated with order details
3. Customer scans QR code or uses mobile deeplink
4. Payment is processed instantly through MIA system
5. Order status updates automatically via webhook or polling

= Requirements =

* WordPress 5.8 or higher
* WooCommerce 6.0 or higher
* PHP 7.4 or higher
* Active VictoriaBank merchant account with API credentials
* HTTPS enabled on your website

= Configuration =

After installation, configure the gateway at **WooCommerce → Settings → Payments → MIA Instant Payments**:

* Enable/disable test mode
* Enter API credentials (username, password)
* Configure your merchant IBAN
* Set QR code expiry time (default: 360 minutes)
* Enable polling for automatic status updates
* Enable debug logging for troubleshooting

= Support =

For technical support regarding this plugin, please visit the [GitHub repository](https://github.com/inginerit/MIA-Payment-Gateway-for-VictoriaBank).

For VictoriaBank API access and merchant account questions, please contact VictoriaBank directly.

== Installation ==

= Automatic Installation =

1. Log in to your WordPress admin panel
2. Go to **Plugins → Add New**
3. Search for "MIA Payment Gateway for VictoriaBank"
4. Click **Install Now** and then **Activate**

= Manual Installation =

1. Download the plugin ZIP file
2. Go to **Plugins → Add New → Upload Plugin**
3. Choose the ZIP file and click **Install Now**
4. Click **Activate Plugin**

= Configuration =

1. Go to **WooCommerce → Settings → Payments**
2. Click on **MIA Instant Payments**
3. Enable the gateway
4. Enter your VictoriaBank API credentials
5. Configure IBAN and other settings
6. Save changes

== Frequently Asked Questions ==

= Is this an official VictoriaBank plugin? =

No, this is a community-developed plugin created by an independent developer. It is not officially affiliated with or endorsed by VictoriaBank. However, it integrates with VictoriaBank's official MIA payment API.

= Do I need a VictoriaBank merchant account? =

Yes, you need an active VictoriaBank merchant account with API access to the MIA system.

= Is this plugin compatible with WooCommerce HPOS? =

Yes, the plugin is fully compatible with High-Performance Order Storage (HPOS).

= How do I enable debug logging? =

Add the following to your `wp-config.php` file:
```
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
```
Then enable "Debug Logging" in the gateway settings.

= Can customers pay from mobile devices? =

Yes, the plugin supports both QR code scanning and direct mobile deeplinks (`mia://pay`) for seamless mobile payments.

= How long are QR codes valid? =

QR codes are valid for the time period configured in settings (default: 360 minutes). After expiration, a new QR code must be generated.

= Does the plugin support refunds? =

Yes, full refunds are supported through the WooCommerce order management interface.

= What happens if a payment webhook fails? =

The plugin includes AJAX polling as a fallback mechanism. If webhooks fail, the payment status will still be detected through automatic polling.

== Screenshots ==

1. Gateway settings page
2. Checkout page with MIA payment option
3. Thank you page with QR code and payment status
4. Mobile view with deeplink button
5. Order details with payment information

== Changelog ==

= 2.1.3 =
* Fixed: Authentication endpoint updated to `/api/identity/token`
* Enhanced: Comprehensive logging throughout the plugin
* Improved: Error handling for API communications
* Optimized: Token caching reduces API calls by 98%
* Added: Mobile deeplink support for direct app payments
* Added: AJAX payment status checking with automatic updates
* Added: Full refund support via VictoriaBank API
* Added: HPOS (High-Performance Order Storage) compatibility
* Security: Enhanced input sanitization and output escaping

= 2.1.2 =
* Fixed authentication issues
* Improved QR code generation reliability

= 2.1.0 =
* Initial release
* Basic MIA payment support
* QR code generation
* Webhook integration

== Upgrade Notice ==

= 2.1.3 =
Important update with authentication fixes, enhanced logging, and HPOS compatibility. Recommended for all users.

== Technical Details ==

= API Endpoints =

* Authentication: `POST /api/identity/token`
* QR Creation: `POST /api/v1/qr`
* Refunds: `DELETE /api/v1/transaction/{reference}`

= Base URLs =

* Test Environment: `https://test-ipspj.victoriabank.md`
* Production: `https://ips-api-pj.vb.md`

= Security =

* JWT token authentication
* Token caching with automatic expiry
* HTTPS required (enforced by API)
* Nonce verification for AJAX requests
* Input sanitization and validation
* No sensitive data logged (passwords masked)

= Compatibility =

* WordPress 5.8+
* WooCommerce 6.0 - 9.4+
* PHP 7.4+
* Tested with latest WordPress and WooCommerce versions

== Privacy Policy ==

This plugin does not collect, store, or transmit any personal data outside of what is necessary for payment processing through VictoriaBank's API. All payment data is transmitted securely via HTTPS to VictoriaBank's servers.

== Third-Party Services ==

This plugin connects to VictoriaBank's payment API to process transactions. By using this plugin, you agree to VictoriaBank's terms of service and privacy policy.

VictoriaBank API: https://victoriabank.md

== Credits ==

Developed and maintained by an independent developer for the WooCommerce and Moldovan e-commerce community.

Source code: https://github.com/inginerit/MIA-Payment-Gateway-for-VictoriaBank
