=== Instalments: PrivatBank + monobank for WooCommerce ===
Contributors: catcodestudio
Tags: woocommerce, payment gateway, instalments, privatbank, monobank
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Оплата частинами ПриватБанку і покупка частинами monobank в одному способі оплати. Банк обирає покупець у чекауті.

== Description ==

Один спосіб оплати, два банки. Покупець сам обирає, де оформити розстрочку, і скільки платежів робити; магазин отримує всю суму одразу (у програмі PB ПриватБанку — частинами протягом строку).

**ПриватБанк «Оплата частинами»** — 2–25 платежів, покупець підтверджує договір на сторінці банку. Підтримуються програми II, PP, IA і PB — під те, що прописано у вашому договорі.

**monobank «Покупка Частинами»** — 3–25 платежів, редіректу немає взагалі: покупець підтверджує договір у застосунку, а магазин показує сторінку очікування, яка сама доводить замовлення до успіху або до зрозумілої відмови.

= Що вміє =

* Два банки в одному способі оплати, вибір банку покупцем у чекауті
* Назва методу підлаштовується під те, що реально ввімкнено
* Підказка «приблизно N грн на місяць» від підсумку замовлення
* Перевірка підпису кожного сповіщення обох банків
* Звірка статусу з банком, а не довіра до сповіщення
* Повторне сповіщення нічого не дублює, оплачене замовлення не йде в банк удруге
* Класичний чекаут і чекаут на блоках
* Сумісність з HPOS (окремі таблиці замовлень)
* Тестові режими на публічних пісочницях обох банків — договір для перевірки не потрібен

= Pro =

* Вибір кількості платежів покупцем на чекауті
* ПриватБанк: резерв із підтвердженням — банк утримує суму, ви списуєте після відправлення
* monobank: підтвердження видачі товару вручну з журналу або автоматично за статусом замовлення
* monobank: повне й часткове повернення
* Журнал заявок по обох банках

Pro можна спробувати 7 днів безкоштовно, без картки.

== Installation ==

1. Завантажте архів у «Плагіни → Додати новий → Завантажити плагін».
2. Активуйте плагін.
3. WooCommerce → Налаштування → Платежі → «Оплата частинами».
4. Увімкніть потрібні банки та введіть їхні реквізити. Для перевірки без договору лишіть тестовий режим ПриватБанку і режим «Пісочниця» для monobank.

== Frequently Asked Questions ==

= Чи потрібен окремий договір із банком? =

Так. Для ПриватБанку — договір «Оплата частинами» або «Миттєва розстрочка» (банк видає ID магазину й пароль), для monobank — договір «Покупка частинами» (store-id і секретний ключ). Для тестових режимів договір не потрібен.

= Чим monobank відрізняється від ПриватБанку в чекауті? =

ПриватБанк перекидає покупця на свою сторінку. monobank не перекидає нікуди: покупець отримує пуш у застосунку, а магазин показує сторінку очікування.

= Коли магазин отримує гроші за monobank? =

Одразу після схвалення заявки. Розстрочка стає активною після того, як магазин підтвердить видачу товару — кнопкою в журналі або автоматично за обраним статусом замовлення.

= Хто платить комісію банку? =

У ПриватБанку залежить від програми: у II («Миттєва розстрочка») — покупець, у PP («Оплата частинами») і PB («Оплата частинами. Гроші в періоді») — магазин, в IA («Миттєва розстрочка. Акційна») комісію ділять магазин і покупець навпіл. У monobank комісію платить магазин, для покупця розстрочка без переплат; комісію з покупця банк бере лише тоді, коли той сам збільшує кількість платежів понад ті, що дав магазин.

= Що буде, якщо сповіщення від банку не дійде? =

Модуль не покладається на сповіщення: після повернення покупця (ПриватБанк) або під час очікування (monobank) він сам запитує стан заявки в банку.

= Чи працює з сумами понад 50 000 грн? =

У ПриватБанку — ні, це обмеження банку, і модуль просто не показує цей банк. У monobank верхньої межі немає, ліміт визначає банк для конкретного покупця.

== Changelog ==

= 1.1.6 =
* Checkout: monobank and A-Bank show the number of payments and the monthly figure the way PrivatBank does, also without Pro (Pro adds the choice of the number). The block checkout works the figure out from the live cart total, so a delivery chosen later is counted.
* Checkout: correct plural forms — «4 частини», «5 частин», «4 платежі», «5 платежів».
* Checkout: the default description no longer promises that the buyer picks the number of payments when the shop's licence does not allow it; an empty description (and the old default) follows what the buyer can really choose.
* Checkout: the monobank / A-Bank phone is a full-width field in WooCommerce's own style under its label, it starts from the billing phone, and the bank options are an even grid of cards.
* Refusal screen (monobank, A-Bank): the "open the app" heading and spinner give way to "The bank did not approve the instalment plan" with "Choose another bank or payment method"; a refused order is now "Failed" (payable again) instead of "Cancelled".
* Admin: the "Instalments are working… leave a review" notice is shown only on the gateway's own settings screen; closing it is remembered.

= 1.1.5 =
* Fixed: on sites where every language has a URL prefix (Polylang), the bank notifications (PrivatBank, monobank, Abank), the status checks of the "confirm in the app" waiting screen and the buyer's return from PrivatBank all landed on a "Page not found" page, so instalment orders were not completed automatically.
* Updates from catcode.com.ua: new versions show up in Dashboard → Updates and install with one click while the licence covers updates.

= 1.1.4 =
* Fix: the "Buy a licence" link, the admin notice and the Plugin URI pointed to the OpenCart version of the module page — now they open the WooCommerce page.

= 1.1.3 =
* Fix: PrivatBank refused an order with an order-level discount (a negative fee from another plugin, or a coupon that left a kopiyka of rounding) — "bad value: product price should be no less than 0.01". The discount is no longer sent as a negative line: for all three banks it is spread over the product lines in proportion to their sums, every unit price stays at 0.01 or more and the lines add up to the order total to the kopiyka.
* PrivatBank product names are cut to 128 characters, the bank's documented limit.

= 1.1.2 =
* Fix: PrivatBank programme labels in the settings showed the fee payer the wrong way round. Per PrivatBank's API documentation: II — the buyer pays the fee; PP and PB — the shop pays (PB credits the funds over the term); IA — the fee is split 50/50. Only the labels and help texts changed; the programme sent to the bank is the same.

= 1.1.1 =
* Fix: bank credentials are now encrypted with libsodium; some hosting antivirus scanners removed the 1.1.0 helper file, which broke saving the settings. Saving no longer fails even if that file is missing.

= 1.1.0 =
* New: A-Bank "Плати частинами" as a third bank — the buyer approves the application in the Abank24 app while the shop waits on its own screen; test contour with the bank's TestMagaz store.
* Pro: confirm delivery, cancel and return for A-Bank applications from the journal and on order status.
* The phone field is now per bank, so a buyer switching banks at checkout does not send one bank's number to the other.

= 1.0.0 =
* Перший випуск: ПриватБанк «Оплата частинами» і monobank «Покупка Частинами» в одному способі оплати.
