=== Pay Later LatAm – Addi, Kueski Pay and Aplazo for WooCommerce ===
Contributors: catcode
Tags: buy now pay later, bnpl, mexico, colombia, installments
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
WC requires at least: 7.0
WC tested up to: 11.2
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Pay later in Colombia and Mexico: Addi, Kueski Pay and Aplazo. Orders are marked paid only when the provider confirms the payment.

== Description ==

Three buy now, pay later services in one plugin, each a payment method of its own:

* **Addi** for Colombia, in Colombian pesos (COP).
* **Kueski Pay** for Mexico, in Mexican pesos (MXN), fortnightly instalments.
* **Aplazo** for Mexico, in Mexican pesos (MXN).

The buyer chooses the method at checkout, completes the application on the provider's page and comes back to the shop. The shop receives the full amount from the provider; the buyer pays the provider in instalments.

**An order is marked paid only when the provider itself confirms the payment**, never because the buyer's browser came back to a "success" address:

* Addi calls the shop back with the result of the application. The call is checked against the callback user name and password you agreed with Addi, and the approved amount is compared with the order.
* Aplazo calls the shop's webhook when the first instalment is paid. The plugin then asks the Aplazo API for the loan status before it changes the order. A declined or abandoned loan has no webhook: the plugin asks the status when the buyer comes back and on the thank-you page.
* Kueski Pay sends the buyer back to the shop; the plugin reads the payment from the Kueski API.

What the free version does:

* Block checkout and classic checkout, HPOS (custom order tables).
* Test and live credentials kept apart, with a test mode switch per method.
* "Check connection" button: asks the provider with the credentials on the screen, before you save. Kueski Pay also shows the order limits of the account.
* Each method shows only for its currency and billing country, and (Addi, Aplazo) within the order totals you set. Kueski Pay takes the limits from the account.
* Addi asks the buyer for the cédula de ciudadanía right in the payment method, or takes it from a field your checkout already has.
* One lock per order: a callback, a webhook and the buyer's return arriving together mark the order paid once, with one note, one stock reduction and one set of e-mails.
* A new attempt on the same order first checks the previous one. If it was paid meanwhile, the order is settled instead of charging twice; an unpaid Aplazo loan is cancelled at Aplazo.
* Cancelled, declined and abandoned payments: the buyer goes back to the order payment page with a plain message, the cart is kept, and the order note says what happened.
* An amount that does not match the order puts the order on hold instead of marking it paid.
* "Re-check the payment" action on the order screen.
* Thank-you page that waits for the confirmation and updates itself.
* Secrets stored encrypted with the keys of your WordPress installation.
* English, Spanish (Colombia) and Spanish (Mexico).

// @pro-begin
= Pro =

* Refunds from the order screen: Aplazo full or partial; Kueski Pay full or partial (needs the Kueski private key, which signs the request and is never sent); Addi cancels the whole credit.
* Payment watchdog: every 15 minutes, re-checks the unpaid Kueski Pay and Aplazo orders of the last 48 hours, for buyers who paid and closed the tab.
* "Pay in instalments with …" line under the price on product and cart pages, shown only where the method can be used.
* Excluded product categories per method.
* Payment journal: every payment of the three methods in one list, with a one-click re-check.
* Updates from catcode.com.ua in Dashboard > Updates.

Pro works on a licence key for two sites (the shop and its test copy), with a 7-day free trial and no card. A licence is sold for 1 to 5 years: the term covers updates and support, and the Pro features keep working after it ends.
// @pro-end

= What you need =

A merchant account with each provider you want to offer, and its credentials:

* Addi: client ID and client secret (staging and production). Give Addi the callback URL, user name and password shown in the settings.
* Kueski Pay: API key (sandbox and production); the private key for refunds.
* Aplazo: merchant ID and API token (development and production). The webhook URL travels with every loan by itself.

== External services ==

The plugin connects to the provider of the payment method the buyer chooses. Nothing is sent before you enter credentials and enable a method.

= Addi (Colombia) =

* What and when: to get an access token (auth.addi.com / auth.addi-staging.com), to open an online application when the buyer places an order with Addi, to cancel a credit when you refund (api.addi.com / api.addi-staging.com), and when you press "Check connection".
* Data sent: the order reference, totals, shipping and tax amounts, the products (SKU, name, quantity, price, image, category), the buyer's name, e-mail, mobile phone, cédula, billing and shipping address, the shop's return and callback URLs and the site icon.
* Website, with the terms and privacy notice of the service: https://co.addi.com/

= Kueski Pay (Kueski, S.A.P.I. de C.V., SOFOM, E.N.R., Mexico) =

* What and when: to validate the API key and read the order limits, to create a payment when the buyer places an order with Kueski Pay, to read the payment when the buyer returns, on the thank-you page, from the re-check action and the watchdog, and to refund (api.kueskipay.com / payments-api.staging-pay.kueski.codes).
* Data sent: the order reference and description, the total and currency, the products (name, description, SKU, quantity, price), the shipping name, address, phone and e-mail, and the shop's return URLs. Refunds send the payment ID, amount and a token signed with your private key; the private key is never sent.
* Terms: https://www.kueskipay.com/tyc, privacy notice: https://preguntas.frecuentes.kueski.com/hc/es/articles/12385430001563-AVISO-DE-PRIVACIDAD-INTEGRAL-PARA-CLIENTES-Y-USUARIOS-DE-KUESKI-SAPI-DE-CV-SOFOM-ENR-

= Aplazo (Mexico) =

* What and when: to get a token for each call, to create a loan when the buyer places an order with Aplazo, to read its status, to cancel an unpaid loan, and to refund (api.aplazo.mx, merchant.aplazo.mx, refunds-bifrost.aplazo.mx; .net for the development environment).
* Data sent: the order reference, totals, discount, shipping and taxes, the products (ID, name, description, quantity, price, image), the buyer's name, e-mail, phone, address and postal code, the shop name, and the shop's return and webhook URLs.
* Website, with the terms and privacy notice of the service: https://aplazo.mx/

// @pro-begin
= CatCode licence server (catcode.com.ua) =

Pro build only: the licence key and the site address are sent to catcode.com.ua when you activate a key or start the trial, once a day to re-check it, and when WordPress looks for updates. Terms: https://catcode.com.ua/terms/
// @pro-end

== Installation ==

1. Install and activate the plugin (WooCommerce must be active).
2. Go to WooCommerce > Settings > Payments and open Addi, Kueski Pay or Aplazo.
3. Enter the test credentials, press "Check connection", enable the method and save.
4. Place a test order. When everything works, switch the test mode off and enter the live credentials.

== Frequently Asked Questions ==

= Which currency must the shop use? =

Addi takes Colombian pesos (COP), Kueski Pay and Aplazo take Mexican pesos (MXN). A method is hidden when the shop currency is different.

= The buyer paid but the order is still "Pending payment". =

Open the order and use "Re-check the payment" in the order actions. For Addi, check that Addi has the callback URL, user name and password from the settings: Addi tells the result only through that call.

= Does the plugin show instalment amounts? =

No. The number of instalments and their amounts are decided by the provider for each buyer, so the plugin does not print them.

== Changelog ==

= 1.0.0 =
* First release: Addi (Colombia), Kueski Pay and Aplazo (Mexico) with server-side confirmation, block and classic checkout, HPOS, connection check and re-check action.
// @pro-begin
* Pro: refunds from the order screen, payment watchdog, pay later line on product and cart pages, excluded categories, payment journal, licence and updates from catcode.com.ua.
// @pro-end
