=== Changelog ===

*** WooCommerce ***
2026.08.24 - version 2.1.7
    * Change: Load the Ecart Pay SDK (pay.js) from pay.ecart.com in production (sandbox host in test mode), decoupled from the API host (ecartpay.com). Aligns the classic checkout with the SDK host already used by Cart/Checkout Blocks.

2026.08.12 - version 2.1.6
    * Fix: Republishes the complete plugin files. Version 2.1.5 was released with several core files empty (settings, checkout scripts/styles), which caused a fatal "Class EcartPaySettings not found" and broke the checkout. No functional changes beyond restoring the intended 2.1.5 code.

2026.08.07 - version 2.1.5
    * Feat: Installment (split-rate) plans are rendered as selectable radio cards across classic and Cart/Checkout Blocks, each showing "{n} pagos mensuales de $X {CUR}", the plan type ("Modalidad de pago diferido" / "Modalidad de meses sin intereses") and, for deferred plans, "Total $Z {CUR}" (per-installment × months). Amounts use thousands separators.
    * Feat: The store currency is sent to the frontend so installment labels show the correct currency code.
    * Feat: Free-trial ($0 initial) subscriptions persist the Ecart Pay parent order id and are handled with a trial status so renewals can be charged via MIT.
    * Feat: Store name, URL and description are sent to Ecart Pay for prohibited-products screening.
    * Feat: Saving the gateway settings is blocked when the account is inactive or the store is flagged (HTTP 403); the real Ecart Pay message is shown in the admin.
    * Fix: The gateway class dependencies (settings, logger, services) are now loaded before the gateway is defined, preventing a fatal "Class EcartPaySettings not found" when WooCommerce instantiates gateways early (e.g. admin onboarding tasks).

2026.07.20 - version 2.1.4
    * Fix: API error handling no longer passes string backend codes into Exception (PHP 8+ TypeError); direct checkout now shows the real API message instead of WooCommerce's generic "error processing your order" notice.
    * Fix: process_payment / process_refund catch Throwable so TypeError and similar failures are logged and returned as payment failures.

2026.07.13 - version 2.1.3
    * Fix: Closing the payment popup in Cart/Checkout Blocks no longer redirects to order-received when payment was not completed; the customer stays on checkout to retry.

2026.07.08 - version 2.1.2
    * Feat: Automatic store registration with Ecart Pay on settings save and on order creation, so WooCommerce stores are tracked as integrations in the backend.
    * Feat: Stable `shop_id` derived from WooCommerce's store id (plugin-generated fallback) sent with the store URL, name, WordPress/WooCommerce versions and gateway settings to avoid duplicate integrations.

2026.06.25 - version 2.1.1
    * Fix: Card `exp_month` / `exp_year` are now sent as 2/4-character strings (e.g. "05"/"2027") so the backend stops rejecting tokens with `card.expiration_month length must be 2 characters long`.
    * Fix: Webhook race condition with `process_payment` resolved (retry + 200 response when transaction_id is not stored yet).
    * Fix: Webhook responses are flushed clean so PHP notices/debug output cannot corrupt the JSON the backend reads.
    * Fix: PHP 8.2+ "dynamic property" deprecation notices removed across `EcartPayGateway`, `EcartPayApi`, `EcartPaySettings`, `EcartPayOrders` and `EcartPayRefunds`.
    * Fix: Idempotent `confirm_ecartpay_order` prevents duplicate payment_complete calls when several webhooks land at the same time.
    * Fix: Direct mode tolerates intermediate backend statuses and lets the webhook close the transaction (no more failed checkouts when the backend responds asynchronously).
    * Fix: Popup checkout redirect time reduced from 15s to 5s; asynchronous payment methods (OXXO, bank transfer) no longer block the customer on the checkout page.
    * Fix: Safety net on the "thank you" page re-syncs the order status if the webhook never arrived.
    * Feat: Unified, modern card form design across classic checkout and Cart/Checkout Blocks (`direct` mode).
    * Feat: Automatic card brand detection (Visa / Mastercard / AMEX) with active state inside the input.
    * Feat: Client-side validation (Luhn, expiration, brand-aware CVC length) with inline error messages.
    * Feat: CVC masked by default with a show/hide eye toggle.
    * Feat: Installments selector loaded with debounce and hidden when no options are available.
    * Chore: Centralised card data extraction in a single helper, removing duplicated code in three call sites.

2026.05.21 - version 2.1.0
    * Fix: Cart/Checkout Blocks payment method registration race condition removed.
    * Fix: Payment method now appears in Block Checkout when settings have not yet been saved (defaults applied).
    * Fix: `woocommerce_rest_checkout_missing_payment_method` error resolved by returning paymentMethodData and bridging payment_data to $_POST through `woocommerce_rest_checkout_process_payment_with_context`.
    * Fix: Removed unreliable `is_block_based_checkout()` page detection; SDK is now enqueued via both the shortcode and the Blocks checkout enqueue hooks.
    * Fix: Removed duplicate registration on `woocommerce_payment_gateways` (gateway no longer added twice).
    * Fix: Subscription hooks no longer registered multiple times per request.
    * Feat: React-based card form for `direct` mode inside Cart/Checkout Blocks.
    * Feat: Declared HPOS (`custom_order_tables`) and `cart_checkout_blocks` compatibility.
    * Feat: Block script now uses canonical `onPaymentSetup` API with `emitResponse.responseTypes`, decoded HTML entities for title/description and `Pay.Popup` guard for `window` mode.
    * Chore: Tested up to WordPress 6.8 and WooCommerce 10.7.

2024.07.23 - version 2.0.0
    * Initial release.
