=== TINXDK WP - Pensopay Auto Capture ===
Contributors: tinxdk
Tags: woocommerce, pensopay, capture, payments, orders
Requires at least: 6.3
Tested up to: 6.8
Requires PHP: 8.2.35
Requires Plugins: woocommerce
WC requires at least: 8.0
WC tested up to: 9.9
Stable tag: 1.0.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Captures the remaining Pensopay amount automatically when a WooCommerce order is completed.

== Description ==

Replaces the old "OpenDIMS - Auto-capture Godkendte Ordre - Pensopay" plugin. When an order changes status, the plugin asks Pensopay for the payment first and captures only what is still open, so an order is never captured twice. Every attempt gets an order note.

**Free edition** (no licence needed, fully usable):

* Automatic capture of the full remaining amount when an order changes to "Completed".
* Test mode: logs and adds an order note what would happen, without any request to Pensopay. On by default until you switch it off.
* An order note for every capture attempt and its result.
* Double-capture protection: the payment is read from Pensopay first, a per-order lock stops concurrent status changes, and an already captured payment is skipped.
* Works with the official Pensopay for WooCommerce plugin: its transaction ids are used, and when its "Capture on complete" option is on this plugin leaves the Completed status to it (admin notice) so nothing is captured twice.
* Imports the settings of the old OpenDIMS plugin on activation and stops itself while that plugin is still active.

**Licensed edition** (licence key from https://tinxdkcloud.dk/wordpress-plugins/tinxdk-wp-pensopay-capture/#licens):

* Choose which order statuses trigger a capture (any number of statuses).
* "Capture now / retry" as an order action on the order screen and as a bulk action on the orders list (HPOS and classic screens).
* Searchable capture log (order number, payment ID or text) in the admin.
* Email to the administrator (or another address) when a capture fails.
* Automatic plugin updates through the TINXDK licence server.

Licensed settings stay visible but disabled in the free edition; the stored values are kept and apply again when a licence is activated. Without contact to the licence server the licence keeps working for 7 days.

Licence activation: WooCommerce > Pensopay Auto Capture > License, enter the key (TINX-XXXX-XXXX-XXXX-XXXX) and click Activate. The site URL, plugin/WordPress/PHP versions and the key are sent to the licence server (licens.tinxdkcloud.dk) when activating, twice daily when validating and when checking for updates. Nothing else is sent.

How it captures: the plugin reads the payment first. Only a payment that is authorized (or partly captured) is captured, for the open amount. Two APIs are supported, chosen in the settings: QuickPay-compatible (default, api.quickpay.net, the API of the official Pensopay for WooCommerce plugin) and Pensopay API v2 (api.pensopay.com/v2). The log is stored in the database (never in a file in the plugin folder) and deleted after 90 days by default. The API key is stored without autoload and is never shown again. The plugin has no public form.

Developer filters: `tinxdk_pc_payment_id` ( $id, $order ) and `tinxdk_pc_should_capture` ( $bool, $order ). Action: `tinxdk_pc_captured` ( $order, $amount_minor_units, $payment_id ).

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` and activate it (WooCommerce must be active).
2. Deactivate "OpenDIMS - Auto-capture Godkendte Ordre - Pensopay" if it is still active.
3. Open WooCommerce > Pensopay Auto Capture, save your Pensopay API key, use "Test connection", then switch test mode off.

== Changelog ==

= 1.0.0 =
* First release: capture on "Completed" through the QuickPay-compatible API (default) or Pensopay API v2, guard against the official plugin's "Capture on complete", test mode, order notes, double-capture protection, capture log, failure email, trigger statuses and capture now / retry (licensed), import from the old OpenDIMS plugin.
