=== Mintpay for WooCommerce ===
Contributors: mintpay
Tags: bnpl, mintpay, payments, woocommerce, sri lanka
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.3
Stable tag: 3.0.0
WC requires at least: 8.3
WC tested up to: 11.2
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Mintpay — Sri Lanka's buy-now-pay-later gateway for WooCommerce. Pay now for cashback, or split into 3 interest-free installments.

== Description ==

Mintpay lets your customers pay now for instant cashback (Mint Coins) or split their purchase into 3 interest-free installments. The plugin adds Mintpay as a payment method on both classic and block-based checkouts, and shows installment / cashback messaging on product pages.

Features:

* Works on classic **and** block-based WooCommerce checkout.
* Product-page installment and cashback breakdown.
* First-purchase promo (MINT20) on the checkout — including block checkout.
* High-Performance Order Storage (HPOS) compatible.
* "Refund via Mintpay" link to the Mintpay merchant portal.

== Installation ==

1. Upload the plugin to `/wp-content/plugins/` and activate it, or install via the Plugins screen.
2. Go to WooCommerce → Settings → Payments → Mintpay.
3. Enter your Merchant ID and Merchant Secret.
4. Tick "Test mode" while testing with sandbox credentials; untick it to go live.

== Frequently Asked Questions ==

= How do I get a Mintpay merchant account? =

Apply at https://www.mintpay.lk

= The checkout redirects back to the cart after placing the order =

This usually means the gateway is in test mode with live credentials (or vice versa). Check the Test mode setting under WooCommerce → Settings → Payments → Mintpay.

== External Services ==

This plugin connects to the Mintpay API to create purchases, verify payment results server-to-server, and fetch the merchant's cashback configuration. The connection is required for the gateway to function. The service is operated by Mintpay (Private) Limited.

* API endpoints: `app.mintpay.lk` (live) and `stage.mintpay.lk` (sandbox) handle order creation, payment-status verification, and cashback configuration. The hosted checkout page the shopper is redirected to is served from the `*-gateway.mintpay.lk` host returned by the API. `static.mintpay.lk` serves promo imagery; `merchant.mintpay.lk` / `stage-merchant.mintpay.lk` is the merchant refund-portal link.
* Data sent when a purchase is created: the store merchant ID, the WooCommerce order ID, the order total, the sales channel, the customer's email, phone and IP address (as recorded by WooCommerce; the browser-supplied X-Forwarded-For header is only forwarded instead when the merchant opts in via the `mintpay_trust_forwarded_for` filter), the billing address (street, city/region, postcode), cart created/updated timestamps, the success and fail return URLs, and for each line item its name, product ID, SKU, quantity, unit price and product timestamps.
* Data sent when verifying a payment: the store merchant ID and the Mintpay purchase ID.
* Data sent when fetching cashback configuration: the store's Mintpay merchant ID and API token (the token is sent in the Authorization header and is never logged).
* Terms & Conditions: https://app.mintpay.lk/terms/
* Privacy Policy: https://app.mintpay.lk/privacy/

== Copyright ==

Mintpay for WooCommerce is Copyright (C) 2026 Mintpay (Private) Limited, licensed under GPL-3.0-or-later. "Mintpay" and the Mintpay logo are trademarks of Mintpay (Private) Limited and are not licensed for use in derivative, competing, or rebranded products. Removing copyright notices, relicensing, or redistributing without source violates the GPL and applicable copyright and trademark law.

== Changelog ==

= 3.0.0 =
* Complete rewrite on a modern PHP 8.3 architecture (PSR-4, namespaced, unit-tested, PHPStan level 8).
* Payment outcomes verified server-to-server via the Mintpay API v2 status endpoint — the browser redirect is never trusted, and the captured amount is checked against the amount at checkout before an order completes.
* Return callback gated by a per-order token (constant-time compare); unauthenticated requests cannot read or change order state.
* Charge-safety guards: an order handed to Mintpay is single-use, so a second purchase is never opened for it, and a paid-but-unconfirmed order is protected from WooCommerce's unpaid-order auto-cancel.
* Abandoning or failing the hosted checkout no longer blocks the next attempt: the abandoned order is dropped from the session, so checking out again places a fresh order with a working Mintpay checkout. The old order is settled in the background — confirmed and captured if it turns out paid, auto-cancelled if not.
* A payment Mintpay reports as failed now returns to the checkout with an error notice instead of the order-received "thank you" page, and every return redirects explicitly rather than rendering whatever page the callback URL named.
* Installment and cashback messaging is labelled "LKR" instead of a hard-coded "Rs.".
* Automatic reconciliation via Action Scheduler: an order whose customer never returned from the hosted checkout is confirmed and settled in the background.
* Merchant credentials are verified against Mintpay (including Merchant ID ownership) when settings are saved.
* Declared High-Performance Order Storage (HPOS) compatibility.
* Blocks checkout: payment method and the MINT20 promo now render on block checkout (previously classic-only).
* Cashback lookup moved from raw cURL to the WordPress HTTP API.
* "Refund via Mintpay" link opens the merchant portal (sandbox/live aware) in a new tab.
* Escaped output, sanitized input, always-on error logging, and an opt-in debug log under WooCommerce → Status → Logs.
= 2.2.3 =
* [Fix] - Forced classic-checkout promo banner styles with !important so theme CSS no longer overrides icon/text sizing and layout
= 2.2.2 =
* [Update] - Renamed payment method to "Pay with Mintpay" and refreshed description
* [Update] - Replaced payment method icon with the new checkout badge
* [Update] - Bundled the blocks-checkout icon (removes runtime dependency on S3 in normal flow)
* [Update] - Restyled the classic-checkout promo banner (text/image sizing, alignment, spacing)
= 2.2.1 =
* [Update] - Updated promo copy on price-breakdown checkout (MINT20 / 20% OFF up to Rs. 1000)
* [Update] - Bumped WordPress compatibility to 6.9
= 2.2.0 =
* [fix] - Auto-Update issue fixed
= 2.1.1 =
* [feat] - Add support for redirects with or without baseURL
= 2.1.0 =
* [fix] - Fix on translator module and double order init. Updated deprecated functions.
= 2.0.6 =
* [Fix] - Fix on 0 cashback stores
= 2.0.5 =
* [Fix] - Same URL Generation on Shopify and Wordpress
= 2.0.4 =
* [New] - Added dynamic price and cashback parameters to education URL
= 2.0.3 =
* [Fix] - Fix then price is null or empty
= 2.0.2 =
* [Fix] - Css Warning fix
= 2.0.1 =
* [Fix] - File Cleanup
= 2.0.0 =
* [New] - Added support for WooCommerce Blocs
* [New] - Added auto Cashback Value / Pay Later Value on Product Page
* [Fix] - Fixed issue with the plugin using old get price function
= 1.0.5 =
* [Fix] - Fixed issue with Admin Panel crashing when Mintpay plugin is activated
= 1.0.4 =
* [Fix] - Moved price breakdown classes to inline styles
= 1.0.3 =
* [Fix] - Moved price breakdown inline styles to classes
= 1.0.2 =
* [Fix] - Made changes to work seamlessly with `Mintpay Price Breakdown` plugin (Old version)
= 1.0.1 =
* [Fix] - Fixed issue with displaying `Product type not identified` under product price
