=== CatCode Ratepay Payments for WooCommerce ===
Contributors: catcodestudio
Tags: ratepay, invoice, direct debit, buy now pay later, payment gateway
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

Buy now, pay later with your Ratepay contract: invoice and SEPA direct debit on the Ratepay payment page, classic and block checkout, capture, cancellation and refunds from the order screen.

== Description ==

A WooCommerce payment gateway for merchants who have a **Ratepay** contract (Germany and the other Ratepay markets). The buyer chooses Ratepay at checkout, is sent to the Ratepay payment page, confirms the missing details there and comes back. Ratepay checks the order and carries the payment risk; your shop never sees bank details.

* **Ratepay Hosted Payment Page** — the page, the data validation and the risk check are Ratepay's. The shop passes the order (buyer, delivery address, basket) and gets the buyer back.
* **Classic and block checkout**, the order-pay page, HPOS.
* **The order changes only after Ratepay says so** — when the buyer comes back, the plugin reads the session from Ratepay with your credentials. The address in the browser proves nothing.
* **Retries that never double** — every request to Ratepay has a stable idempotency key. A lost answer is repeated with the same key; a double click reuses the open payment page.
* **Capture after shipping** — from the order actions: "Capture the Ratepay payment". Until then the amount is only authorized.
* **Cancel and refund** — "Cancel the uncaptured Ratepay amount" in the order actions, and refunds from the WooCommerce refund screen: a captured amount is refunded, an amount that was never captured is cancelled, and Ratepay is never asked for more than the transaction holds.
* **Basket that adds up** — products, shipping and fees are sent as basket lines; if the lines could not be made to add up within Ratepay's tolerance, one line with the order total is sent instead of a basket Ratepay would refuse.
* **"Re-check the Ratepay payment"** in the order actions for an order whose result got lost. It only reads.
* **Plain messages for buyers** — no decline codes at checkout; after a hard risk rejection the method is not offered again to that buyer, as the Ratepay documentation asks.
* **Connection check** tells apart a wrong secret, integration credentials in live mode and live credentials in integration mode.
* The client secret is stored encrypted. Debug log without credentials or tokens.
// @pro-begin
* Translation included: German.
// @pro-end

// @pro-begin
= Pro =

The Pro version is sold on [catcode.com.ua](https://catcode.com.ua/modules/catcode-ratepay-payments-for-woocommerce/), with a 7-day trial that never starts by itself:

* **Automatic capture** when the order is Completed (or Processing, as you choose), and **automatic cancellation** of the uncaptured amount when the order is Cancelled or Failed.
* **Tracking numbers** — carrier and tracking number saved by a tracking plugin go to Ratepay with the capture.
* **Business customers** — an order with a billing company name is sent as a B2B order (when your Ratepay profile allows it).
* **Webhook** — Ratepay's report of a payment page is checked against its signature, then the session is read back from Ratepay.
* **Payment watchdog** — every 15 minutes settles the unpaid orders of the last 48 hours whose buyer never came back.
* **Payment journal** — every Ratepay payment with transaction, authorized, captured, cancelled and refunded amounts, integration or live.

The licence runs for 1-5 years and includes updates and support for that term. One key covers two sites: your shop and a test copy.
// @pro-end

Ratepay is a trademark of its owner. This plugin is an independent integration made by CatCode; it is not the official Ratepay plugin and is not affiliated with or endorsed by Ratepay GmbH.

== Installation ==

1. Upload the plugin and activate it.
2. Ask your Ratepay contact for the client ID, the client secret and the partner shop ID of your profile (for tests: the integration credentials), and for the Hosted Payment Page to be enabled for it. Ratepay also needs your terms and conditions link and the return addresses of the shop.
3. WooCommerce → Settings → Payments → **Ratepay (CatCode)**: choose Live or Integration, paste the client ID, the secret and the partner shop ID, and press "Check connection".
4. Enable the method and make a test payment.

== Frequently Asked Questions ==

= Do I need a Ratepay contract? =
Yes. Ratepay gives merchants their credentials when the contract is signed, and integration credentials for tests. This plugin does not sign you up with Ratepay.

= Does bank or card data touch my server? =
No. The buyer enters the missing details on the Ratepay page. The plugin sends the order data (name, address, e-mail, phone, basket) to Ratepay and receives the transaction ID.

= Which payment methods does the buyer see? =
Those your Ratepay profile allows (invoice, SEPA direct debit). In the settings you can show only one of them, if your profile has several.

= When does the money move? =
The payment is authorized when the buyer finishes on the Ratepay page. Ratepay collects it from the buyer when you capture it after shipping. An authorization that is never captured runs out, so capture promptly.

= Why is the method missing at checkout? =
The client ID, the secret or the partner shop ID is missing, the method is not enabled, or the buyer was rejected by Ratepay's risk check earlier in the same session.

= Does it work with the block checkout? =
Yes. The buyer is redirected to the Ratepay page when the order is placed.

== External services ==

This plugin connects to Ratepay, the payment service the shop owner chooses:

* Ratepay authorization server (oauth.ratepay.com) — to get access tokens: the client ID and client secret of the merchant.
* Ratepay Hosted Payment Page API (payment.ratepay.com, in integration mode payment-integration.ratepay.com) — when a buyer chooses Ratepay: the buyer's name, billing and delivery address, e-mail, phone number (if valid), the shop's customer ID of a logged-in buyer, the language, the basket (item names, article numbers, quantities, prices, tax rates), the order number and total, the partner shop ID, and the return addresses of the shop. Later the session is read back from Ratepay.
* Ratepay Payment API 2.0 (api.ratepay.com/transaction/management, in integration mode api-integration.ratepay.com/transaction/management) — when you capture, cancel or refund: the transaction ID and the amount (with the basket lines on a full capture).
// @pro-begin
* Carrier and tracking number, when the tracking option is on and a tracking plugin saved them.
* CatCode licence server (catcode.com.ua) — when the owner activates a key or starts the trial, and periodically while a key is stored: the key and the site address (plus the e-mail typed for a trial). Updates are checked there with the same key.
// @pro-end

Ratepay's legal requirements for shops that offer its payment methods: https://docs.ratepay.com/docs/legal/a_legal_requirements_for_the_integration/introduction

== Changelog ==

= 1.0.0 =
* First release: Ratepay Hosted Payment Page in the classic and block checkout and on the order-pay page, session read-back before the order changes, stable idempotency keys, Re-check order action, capture, cancellation and refunds from the order screen, basket that adds up, plain buyer messages, hard-rejection handling, connection check, HPOS.
// @pro-begin
* Pro: automatic capture and cancellation, tracking numbers, business customers, signed webhook, payment watchdog, payment journal, updates from catcode.com.ua.
// @pro-end
