=== tbi bank Installments for WooCommerce ===
Contributors: catcode
Tags: woocommerce, installments, tbi bank, romania, bulgaria
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Installments with tbi bank in Romania, Bulgaria and Greece: online application, the bank's signed decision moves the order by itself. Block and classic checkout.

== Description ==

A WooCommerce payment method for **installment financing from tbi bank**. The buyer chooses "Pay in installments with tbi bank" at checkout and fills in the online application on the tbi platform. The bank's decision comes back to the shop and the order follows it on its own.

* Romania (RON), Bulgaria (EUR and BGN) and Greece (EUR) — each with its own tbi platform, live and test (UAT).
* The application carries the order lines with tax, shipping and discounts, so the amount on the tbi side is exactly the order total.
* The order is marked paid only by the bank's notification — never by the buyer coming back from tbi. Notifications are accepted only when they are signed with your encryption key (or, if you explicitly allow it, come from the platform address) and decrypt with that key.
* Approved → Processing or Completed (your choice). Refused or cancelled → Cancelled or Failed (your choice). Annulled after an approval → On hold with a warning: the bank will not pay for that order.
* While the bank reviews the application the order is on hold, so the WooCommerce "Hold stock" timer does not cancel it.
* The method shows only for the currencies of the chosen country and for order totals inside the limits (tbi's own or yours).
* Connection check with the saved credentials; the limits reported by tbi become the defaults.
* Block checkout and classic checkout, order-pay page, HPOS.
* The tbi status of the order under the order details.
* Debug log in WooCommerce → Status → Logs (no buyer data, no keys).

= Pro =

* **Second chance after a refusal**: the order stays open (pending payment, stock returned) and the buyer gets one e-mail with a link to pay for it another way. tbi is not offered again for that order.
* **Clean-up of abandoned applications**: orders without a bank decision are cancelled after the number of days you choose, and their stock is released.
* **Categories and products without financing**: tbi is not offered when the cart holds them.
* **tbi journal** with the bank status and its history for every application, and a tbi column in the orders list.

== Installation ==

1. Upload the plugin to `/wp-content/plugins/` and activate it.
2. WooCommerce → Settings → Payments → **tbi bank installments**.
3. Choose the country of your merchant contract and the platform (live or test), enter the reseller code, the reseller key and the encryption key issued by tbi bank, save.
4. Press "Check connection".
5. Place a test order on the test platform (UAT) with the test data tbi gives you, and watch the order follow the bank's decision.

tbi sends its decisions to `https://your-shop/wp-json/api/tbi/v1/tbi-api-gateway`. Nothing to enter, but the address must be reachable from the internet.

== Frequently Asked Questions ==

= Do I need a contract with tbi bank? =
Yes. tbi bank (tbi Merchant Solutions) signs the shop up as a merchant and issues the reseller code, the reseller key and the encryption key.

= Can it run next to "Fusion Pay by tbi bank"? =
Not at the same time. tbi sends its decisions to one address of the shop, the same one both plugins listen on. While Fusion Pay is active, this plugin warns you and does not take the notifications. Keep one of them.

= The bank approved, but the order is still on hold. =
The notification did not reach the shop or was refused. Switch on the debug log and look for "Notification refused": a wrong encryption key, a site behind a password or maintenance mode, or a firewall blocking POST requests to /wp-json/ are the usual reasons.

= Free and Pro =
Checkout with tbi and the bank decisions are free, with no time limit. Pro features are unlocked with a licence key from catcode.com.ua. The 7-day trial starts only when you click it. A purchased licence keeps its Pro features after the term ends — only updates and support stop.

== Changelog ==

= 1.0.0 =
* First release: tbi application from the order (RO, BG, GR; live and test platform), signed bank notifications, automatic order statuses, amount and currency limits, connection check, classic and block checkout, order-pay page.
* Pro: second chance after a refusal, clean-up of abandoned applications, categories and products without financing, tbi journal and status column.
