=== EU VIES VAT Exemption, Outage Auto-Refund & Aelia Migrator for WooCommerce ===
Contributors: merchantbastionhq
Tags: eu vat, vies, reverse charge, woocommerce b2b, tax exemption
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
WC requires at least: 8.6
WC tested up to: 11.3
Stable tag: 1.7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Live EC VIES VAT check, 16-digit consultationNumber proof, MS_UNAVAILABLE refund shield, AU ABN, US Resale & 1-click Aelia HPOS migration.

== Description ==

**EU VIES VAT Exemption, Outage Auto-Refund & Aelia Migrator for WooCommerce** by **MerchantBastion** provides server-side cross-border B2B tax exemption validation built natively for **WooCommerce High-Performance Order Storage (HPOS)** and **Cart & Checkout Blocks (Store API)**.

=== Key B2B Tax & Audit Safeguards ===

* **Official 16-Digit EC VIES `consultationNumber` (`requestIdentifier`) Archiving:** Automatically submits your store's own EU VAT registration (`requesterMemberStateCode` + `requesterNumber`) on every EC VIES REST lookup to secure the 16-digit proof required under **Council Directive 2006/112/EC Article 138(1a)**.
* **Real-Time Classic & Checkout Blocks Fraud Lock:** Dynamically enforces `WC()->customer->set_is_vat_exempt(false)` if a buyer enters a valid foreign VAT ID and then switches shipping back to your domestic country (`DOMESTIC_BLOCKED`) or a mismatched destination (`COUNTRY_MISMATCH_BLOCKED`). Includes Northern Ireland (`BT` postcodes -> `XI`) and Greece (`GR` -> `EL`) routing.
* **Fail-Safe `MS_UNAVAILABLE` Outage Shield:** Never grants illegal blind `0%` VAT when national Member State databases go offline. Safely collects VAT as a deposit and schedules automatic background VIES re-verification and partial VAT refund via `wc_create_refund()`.
* **1-Click Non-Destructive Migration from Retired Aelia EU VAT Assistant:** Copies historical `_vat_number`, validation flags, and consultation IDs into native WooCommerce HPOS custom order tables without deleting legacy metadata.
* **Multi-Region Expansion Built In (Australia ABR ABN & US MTC/SST Resale Vault):** Validates 11-digit Australian Business Numbers via official Modulo-89 math (`ATO GSTR 2013/1` + `47% No-ABN` alert) and verifies US B2B State Resale Certificate state-nexus locks (`Form F0003` ESIGN SHA-256).

=== External Services Disclosure (WordPress.org Guidelines #6 & #7) ===

1. **Official European Commission VIES REST Validation API (Core B2B Checkout Function):**
   * **Endpoint:** `https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number`
   * **When Triggered:** Contacted only when a B2B buyer submits an EU/XI corporate VAT ID at checkout or during scheduled `MS_UNAVAILABLE` outage recovery. Zero requests occur for standard B2C orders, and zero frontend tracking scripts are loaded.
   * **Data Sent:** Buyer corporate EU VAT prefix/number and the store's configured requester EU VAT prefix/number solely to obtain the statutory 16-digit `requestIdentifier`.
   * **Official EC VIES Disclaimer & Privacy Policy:** https://ec.europa.eu/taxation_customs/vies/#/disclaimer
2. **Optional MerchantBastion Pro License & Cloud-Signed Audit PDF Service (Opt-In Admin Only):**
   * **Cloud Endpoints:** `https://api.merchantbastion.com/api/pro/woo/activate` (asymmetric `Ed25519` store domain license binding; supports `MB-PLAYGROUND-DEMO-2026` on WordPress Playground/localhost) and `https://api.merchantbastion.com/api/pro/woo/signed-audit-pdf` (cloud-signed `%PDF-1.4` VIES/ABN/Resale audit certificates).
   * **Service Website:** https://merchantbastion.com
   * **Terms of Service:** https://merchantbastion.com/terms
   * **Privacy Policy:** https://merchantbastion.com/privacy
   * **Refund Policy (14-Day No-Questions-Asked):** https://merchantbastion.com/refund-policy
   * **Support Contact:** support@merchantbastion.com

=== Statutory Tax & Limitation of Liability Disclaimer ===

This plugin provides technical automation interfacing with the European Commission VIES API, Australian ABR Modulo-89 checksum rules, and US B2B certificate metadata. It is not an official government agency tool, does not constitute legal, tax, or accounting advice, and does not act as a tax guarantor. Under Article 138 of Council Directive 2006/112/EC and Implementing Regulation (EU) No 282/2011 Article 45a, the merchant remains solely responsible for verifying substantive intra-Community exemption conditions and retaining cross-border transport proof.

== Installation ==

1. Upload `eu-vies-vat-shield.zip` via **Plugins -> Add New -> Upload Plugin** in WordPress Admin, then click **Activate**.
2. Navigate to **WooCommerce -> EU VIES VAT Shield** and enter your store's own **Merchant Requester EU VAT ID** (e.g., `DE811115368`).
3. Optional: Click **Run 1-Click Aelia to HPOS Migration** to copy historical Aelia VAT records into WooCommerce HPOS tables.

== Frequently Asked Questions ==

= Does this plugin support WooCommerce High-Performance Order Storage (HPOS) and Checkout Blocks? =
Yes. Both `custom_order_tables` and `cart_checkout_blocks` compatibility are explicitly declared via `FeaturesUtil::declare_compatibility`, and all order metadata uses `WC_Order` CRUD methods exclusively.

= What happens when a national VIES server returns MS_UNAVAILABLE? =
The plugin never applies unverified `0%` VAT. It collects standard VAT safely at checkout, marks the order `MS_UNAVAILABLE_QUEUED`, and automatically re-queries VIES via WP-Cron to queue or execute a partial VAT refund once the official 16-digit `consultationNumber` is confirmed.

== Changelog ==

= 1.7.0 =
* Added Australia ABR 11-digit Modulo-89 ABN & ATO GSTR 2013/1 validation and US MTC/SST Form F0003 state-nexus lock alongside EU VIES, Checkout Blocks Store API, and 1-click Aelia HPOS migration.

== Upgrade Notice ==

= 1.7.0 =
Full WooCommerce HPOS & Checkout Blocks release with EU VIES outage auto-refund, AU ABN Modulo-89, and US B2B Resale state-nexus verification.
