=== Pagai Payments for WooCommerce ===
Contributors: ignaciocrdenas
Tags: payments, webpay, mercado pago, chile, checkout
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Take payments in WooCommerce with Webpay, Mercado Pago, Flow, Getnet, Stripe, PayPal and more through Pagai's secure checkout.

== Description ==

Pagai is a Chilean invoicing and payments platform. This plugin adds Pagai as a payment method in your WooCommerce store: at checkout your customer picks "Pay with Pagai", pays on Pagai's secure page with the method they prefer and comes back to your store. The order is marked as paid automatically.

Your customers can pay with every method you have enabled in your Pagai account:

* **Webpay (Transbank)** - credit, debit and prepaid cards in Chile
* **Mercado Pago** - cards and wallet
* **Flow** - cards and bank transfers
* **Getnet** - cards
* **Fintoc** - direct bank transfers
* **Stripe** - international cards
* **PayPal** - global payments
* **Pagopar** - Paraguay
* **NOWPayments** - crypto

You turn payment methods on or off in Pagai, without touching WordPress. The money goes straight to your own account at each provider; Pagai does not hold it.

**Features**

* Works with the Cart & Checkout blocks (the default checkout since WooCommerce 8.3) and with the classic checkout.
* Compatible with High-Performance Order Storage (HPOS).
* Sets up its own webhook when you save your API key, and checks the key's permissions.
* Signed webhooks (HMAC-SHA256 with timestamp) mark orders as paid, failed or cancelled when the checkout link expires.

**Requirements**

* A Pagai account (https://pagai.cl) with at least one payment provider connected.
* A Pagai API key with the permissions `checkout:create`, `clients:create` and `webhooks:manage`.

== External services ==

This plugin connects to the Pagai API (https://api.pagai.cl), operated by Pagai, to process payments. Without it the plugin cannot work.

* **When an order is placed with Pagai:** it sends the order total and currency, a description with the order number and store name, the customer's name and email, the order ID and number, the store URL and the return URLs. Pagai uses them to create the payment page and the payment document.
* **When you save the settings:** it sends your API key to verify its permissions and registers the store's webhook URL so Pagai can report payment results.
* **When the plugin is deactivated:** it deletes that webhook in Pagai.

The customer is redirected to Pagai's payment page (https://pagai.cl) and, from there, to the payment provider they choose, each with its own terms.

* Terms of service: https://pagai.cl/terms
* Privacy policy: https://pagai.cl/privacy

== Installation ==

1. Install the plugin from Plugins > Add New, or upload the zip in Plugins > Add New > Upload Plugin, and activate it.
2. In Pagai, create an API key (Settings > API keys) with the permissions checkout:create, clients:create and webhooks:manage.
3. In WordPress, go to WooCommerce > Settings > Payments > Pagai, enable it, paste the API key and save.
4. The plugin checks the key and registers the webhook. If something is missing, it tells you at the top of the page.

== Frequently Asked Questions ==

= Which payment methods will my customers see? =

All the ones you have enabled in your Pagai account. To add or remove one, change it in Pagai; nothing changes in WordPress.

= Does Pagai keep my money? =

No. Payments go to your own account at each provider (Transbank, Mercado Pago, etc.).

= My orders stay pending after the customer pays =

Check that your API key has the webhooks:manage permission and that your site is reachable from the internet over HTTPS. Then save the plugin settings again: the page shows any problem it finds.

== Changelog ==

= 1.2.0 =
* Works with the Cart & Checkout blocks.
* Declares compatibility with HPOS (High-Performance Order Storage).
* Fix: the webhook is registered on the first save.
* Checks the API key permissions on save and shows what is missing.
* Translatable strings.
* Tested with WordPress 7.1 and WooCommerce 11.2.

= 1.1.0 =
* Renamed to Pagai. Default API URL is https://api.pagai.cl.

= 1.0.0 =
* Initial release: redirect checkout, webhook auto-registration and signature verification.

== Upgrade Notice ==

= 1.2.0 =
Adds support for the block checkout, which new WooCommerce stores use by default.
