=== Pin Vandaag for WooCommerce ===
Contributors: pinvoordeel
Tags: payment terminal, pin, ccv, worldline, point of sale
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
WC requires at least: 7.0
WC tested up to: 11.1
Stable tag: 1.0.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Let customers or staff pay a WooCommerce order on a physical CCV or Worldline payment terminal through Pin Vandaag.

== Description ==

Pin Vandaag for WooCommerce sends the amount of a WooCommerce order straight to a physical payment terminal (CCV or Worldline) connected to the Pin Vandaag cloud. The customer pays on the terminal and the order is updated automatically.

It is made for shops that also sell in person: click and collect at the counter, a store with a webshop, or orders entered by staff.

**Two ways to pay**

* **Checkout** – the customer selects "Pay on the payment terminal" at checkout and follows a live status page while the amount is on the terminal.
* **Admin** – a staff member opens an order in WooCommerce, chooses a terminal and sends the amount to it.

You decide where payment on the terminal is available: in the checkout, in the admin, or both.

**Features**

* Multiple terminals, each with its own API key. Use a default terminal or let the customer or staff choose.
* The result arrives by webhook and is also requested by status checks, so no payment is missed. A background check keeps checking for up to 15 minutes.
* Amount check: if the paid amount differs from the order total, the order is put on hold.
* Refunds from WooCommerce are started on the terminal (the customer presents the card).
* Stop a payment, automatic timeout, and a "try again" link for the customer.
* Show the terminal receipt on the thank-you page, on the order, or email it to the customer.
* Test mode: only logged-in administrators see the payment method, so you can test on a live shop.
* Classic checkout and checkout blocks; compatible with High-Performance Order Storage (HPOS).
* Debug log under WooCommerce › Status › Logs (source "pinvandaag"); the API key is never logged.

**What you need**

* A CCV or Worldline payment terminal with an active Pin Vandaag cloud connection. The plugin is free; the cloud connection is a paid Pin Vandaag service. See [pinvandaag.nl/woocommerce](https://www.pinvandaag.nl/woocommerce/) for details.
* The TMS number and API key of each terminal, available in PinPortal.nl.
* A shop that charges in euros.

== External services ==

This plugin connects to the Pin Vandaag REST API, a service of Pin Voordeel B.V. (Netherlands), to start, follow, stop and refund payments on your payment terminal. Without this service the plugin cannot work.

The plugin only contacts the service when a payment is started, checked, stopped or refunded, when a receipt is emailed, and when you click "Test connection" in the settings.

What is sent, and when:

* Starting a payment: the terminal ID (TMS number), the amount in cents, an order reference (for example "WC-1042") and, on HTTPS sites, a signed webhook URL of your shop to which the result is sent back.
* Checking or stopping a payment: the terminal ID and the transaction ID.
* Refunding: the terminal ID, the amount, the original transaction ID, an order reference and the webhook URL.
* Emailing a receipt: the terminal ID, the transaction ID and the email address of the customer. This only happens when you turn on "Email receipt" or click "Email receipt" on an order.
* Testing the connection: the terminal ID.
* Every request includes the API key of the terminal and a user agent with the plugin version and the URL of your site.

Requests go to `https://rest-api.pinvandaag.com`. If that address cannot be reached, the plugin uses the backup address `https://api-backup.pinvandaag.com`.

* Terms and conditions: [https://www.pinvandaag.nl/algemene-voorwaarden/](https://www.pinvandaag.nl/algemene-voorwaarden/)
* Privacy policy: [https://www.pinvandaag.nl/privacybeleid/](https://www.pinvandaag.nl/privacybeleid/)
* API documentation: [https://www.pinvandaag.nl/rest-api/](https://www.pinvandaag.nl/rest-api/)

== Installation ==

1. Install the plugin through Plugins › Add New, or upload the zip file under Plugins › Add New › Upload Plugin, and activate it. WooCommerce must be active.
2. Go to WooCommerce › Settings › Payments and open "Pin Vandaag (payment terminal)".
3. Under "Terminals", enter one terminal per line in the format `TMS number|API key|name`, for example `50303253|a1b2c3d4e5f6|Shop counter`. The name is optional. You can find the TMS number and API key in PinPortal.nl under customer settings › "Other" tab › "API Keys".
4. Choose under "Available in" whether payments are possible in the checkout, in the admin, or both.
5. Save the settings and click "Test the connection to all terminals". Every terminal should show a check mark.
6. Keep "Test mode" on while you make a test payment, then turn it off.

A step-by-step guide (in Dutch) is available at [pinvandaag.nl/docs/woocommerce-plugin-installatie-handleiding](https://www.pinvandaag.nl/docs/woocommerce-plugin-installatie-handleiding/).

== Frequently Asked Questions ==

= Which payment terminals are supported? =

CCV and Worldline payment terminals with an active Pin Vandaag cloud connection. The terminal does not have to be on the same network as the shop.

= Does the plugin cost anything? =

The plugin is free. The Pin Vandaag cloud connection for your terminal is a paid service of Pin Vandaag.

= What happens if the customer closes the wait page? =

The payment continues on the terminal. The result still arrives by webhook, and a background check requests the status for up to 15 minutes, so the order is updated anyway.

= My site does not use HTTPS. Does it still work? =

Yes. The webhook is only used on HTTPS sites; without HTTPS the plugin relies on status checks.

= Can I refund a payment? =

Yes, from the order in WooCommerce. The refund is started on the terminal and the customer has to present the card. The result appears as an order note.

= Are my settings kept when I update? =

Yes. Settings, terminals and API keys are kept, also when you replace an older copy of the plugin.

== Changelog ==

= 1.0.3 =
* Prepared for the WordPress.org plugin directory: new plugin slug "pin-vandaag-for-woocommerce".
* All texts are now in English with a Dutch translation included.
* Scripts and styles are loaded as separate files instead of inline.
* Notice when two copies of the plugin are active.
* Requires WordPress 6.5 or higher.

= 1.0.2 =
* New setting "Available in": pay through the shop checkout and/or through the admin.

= 1.0.1 =
* API key per terminal (TMS number|API key|name) and a connection test per terminal.

= 1.0.0 =
* First version.

== Upgrade Notice ==

= 1.0.3 =
New plugin folder for the WordPress.org directory. If you used an older copy in the folder "pinvandaag-woocommerce", deactivate and delete it after installing this version; your settings are kept.
