=== CatCode Younited Pay for WooCommerce ===
Contributors: catcodestudio
Tags: younited, instalments, paiement en plusieurs fois, bnpl, woocommerce
Requires at least: 6.4
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

Let buyers pay in instalments (3x, 4x, 10x and more) with Younited Pay: plans with their cost at the checkout, order status from Younited.

== Description ==

Adds Younited Pay as a payment method to WooCommerce, for shops that sell in euros and have a Younited Pay merchant contract. At the checkout Younited is asked which plans it offers for the amount of the cart, and the buyer picks one — split payment (2x–4x) or a personal loan for longer terms, depending on your contract. The buyer then finishes the application on the Younited page, and the order follows the payment status. You use your own Younited Pay account (client ID, client secret and shop code).

* **Plans with their cost** — every plan shows the instalment, the first instalment when it differs, the total, the fees, the fixed rate of a loan and the APR, exactly as Younited computes them, plus the warning French consumer credit law asks for.
* **Classic and block checkout** — the same plan list in both, and on the order-pay page.
* **Order follows Younited** — waiting for the application, approved, accepted, executed (the order becomes paid), failed or cancelled (nothing taken; the buyer can pay the order another way). An executed amount that differs from the order total puts the order on hold.
* **Webhook without setup** — each payment is created with the shop's notification address. The event only triggers a read of the payment from Younited; with the webhook signature key saved, unsigned calls are refused (HMAC-SHA256).
* **Buyer comes back to the shop** — after the application the buyer returns to the thank-you page, or to the order-pay page with a plain message when the application was refused or cancelled.
* **Execute payment** — a personal loan has to be executed by the shop (usually once the goods are shipped): one button in the Younited Pay box of the order. "Check payment status" reads the payment from Younited if a webhook was missed.
* **Check connection** lists your active shops and fills in the online one; "Show the plans for this amount" and "Send a test notification" check the setup before the first order.
* Sandbox and production environments. HPOS compatible. The client secret and the webhook key are stored encrypted. Basket, buyer and address are sent in Younited's format (lines of 38 characters, mobile number in international form).
* Translations included: English, French.

= Pro =

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

* **Instalments on the shop pages** — "or 3× … with Younited Pay" under the product price, every plan for the cart total in the cart, and a shortcode for any page.
* **Refunds from WooCommerce** — a full or partial refund of an executed payment is sent to Younited; a refund made in the Younited portal is recorded as a WooCommerce refund.
* **Automatic execution** of accepted personal loans when the order is marked Completed, or right after acceptance.
* **Cancellation at Younited** when the order is cancelled, and a "Cancel at Younited" button; **New application link** for an open payment.
* **Background check** every 15 minutes of open payments, for webhooks that did not reach the shop.
* **Rules** — order amount range of your own and product categories without Younited Pay.
* **Shop code per billing country**, for merchants with several Younited shops.
* **Journal and report** — every Younited event of the shop, a 30-day summary by status and a CSV export.
* Updates from catcode.com.ua.

The licence runs for 1-5 years and includes updates and support for that term; a purchased licence keeps its Pro features after the term ends. One key covers two sites: the shop and its test copy.

Younited and Younited Pay are trademarks of Younited. This plugin is an independent integration made by CatCode; it is not an official plugin of Younited and is not affiliated with or endorsed by it. You need your own Younited Pay merchant contract for live payments.

== External services ==

The plugin connects to the Younited Pay API (Younited, [younited.com](https://younited.com/), documentation at [docs.younited.com/pay](https://docs.younited.com/pay/)) at `api.younited.com` (production) or `sandbox-api.younited.com` (sandbox), and only after you enter your client ID and client secret. Access tokens are issued by Microsoft Entra ID at `login.microsoftonline.com`, the sign-in service Younited uses for its API ([Microsoft privacy statement](https://www.microsoft.com/privacy/privacystatement)). The buyer is sent to the Younited application page, where Younited collects the application details.

* To get an access token (at most once an hour): the client ID and the client secret.
* When you press "Check connection": nothing but the token, to read your merchant name and active shops.
* At the checkout, to show the plans: the amount of the cart, your shop code and the numbers of instalments you chose.
* When the buyer pays: the plan, the amount, the order lines (name, quantity, unit price, SKU, product URL and picture, categories), shipping, fees and coupons, the order number, the buyer's name, e-mail, mobile number, billing and shipping address, the buyer's IP address for a personal loan, the shop's notification address and the address the buyer returns to.
* When a webhook arrives, the buyer returns, you press "Check payment status" or "Execute payment": the Younited payment ID.
* When you press "Send a test notification": the shop's notification address.
* On a refund, a cancellation or a new application link (Pro): the payment ID and, for a refund, the amount.

[Younited privacy policy](https://younited.com/fr/legal/politique-de-protection-des-donnees-personnelles-clients-et-prospects-emprunteurs/)

== Installation ==

1. Upload the plugin and activate it. WooCommerce must be active and the shop currency the euro.
2. In WooCommerce → **Younited Pay** choose the environment, paste the client ID and the client secret from the Younited Pay portal, press "Check connection" (it fills in the shop code) and save.
3. Optionally paste the webhook signature key from Younited and press "Send a test notification".
4. WooCommerce → Settings → Payments: enable "Younited Pay". Press "Show the plans for this amount" to see what the buyer will be offered, then place a test order in the sandbox.

== Frequently Asked Questions ==

= Do I need a Younited account? =

Yes: a Younited Pay merchant contract, which gives you the client ID, the client secret and the shop code. The plugin does not do the onboarding. The sandbox needs its own credentials from Younited.

= Which plans are shown? =

The ones Younited returns for the cart amount and the numbers of instalments you set (for example 3,4,10). If Younited offers nothing for an amount, the buyer is told to choose another payment method.

= Why is the order "on hold" after checkout? =

It waits for the buyer's application. It becomes paid when Younited executes the payment. A split payment is executed by Younited itself; a personal loan is executed by the shop with the "Execute payment" button.

= How do I refund an order? =

In the Younited portal. With the webhook signature key saved, the refund is noted on the order.
With Pro, a refund made in WooCommerce (full or partial) is sent to Younited, and one made in the portal is recorded as a WooCommerce refund.

= Which currencies? =

Euros only.

== Changelog ==

= 1.0.0 =
* First release.
