=== Factro Connector for WooCommerce ===
Contributors: factro
Tags: crm, accounting, orders, invoicing, webhook
Requires at least: 6.5
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Send WooCommerce orders, cancellations and refunds to Factro CRM and accounting using one secure webhook URL.

== Description ==

Factro Connector is a free bridge from WooCommerce to Factro. When a new order is created, the
plugin sends it to your own store-specific Factro webhook URL. In Factro the buyer is created or
matched as a customer, a reviewable sales order is raised, and from there you can issue a tax-ready
invoice and track the payment.

The plugin needs no WooCommerce API keys. It sends order, line-item and billing contact fields only.
It never reads or transmits card numbers or any payment credential.

**What it does**

* Sends each new order to Factro in the background, so checkout is never delayed or blocked.
* Retries automatically with a backoff when Factro cannot be reached, so a brief outage does not
  lose an order.
* Shows the result of the last delivery on its own settings screen.
* Compatible with WooCommerce High-Performance Order Storage (HPOS).

**Requires an account**

Factro is a paid hosted service (free trial available). This plugin is free and is only useful with a
Factro account: https://app.factro.in

== External services ==

This plugin connects to Factro, a third-party hosted service operated by Factro, to deliver your
WooCommerce orders into your Factro account. This connection is the entire purpose of the plugin.

**When the service is contacted**

Factro is contacted at one moment only: when a new order is created in your store
(the `woocommerce_new_order` action). If that request fails or returns a non-2xx response, the
plugin retries the same order up to five more times with an increasing delay (1 minute, 5 minutes,
15 minutes, 1 hour, 6 hours) and then stops. Nothing is sent on page views, on admin screens, on a
schedule, or for any visitor activity.

Requests go to the HTTPS webhook URL you paste into the plugin's settings, on Factro's API host
(`https://api.factro.in/api/v1/webhooks/incoming/...`). If you have not entered a URL, the plugin
makes no external requests at all.

**Exactly what is transmitted**

For each new order:

* Order id, order number, order status, currency, order total, order creation date.
* WooCommerce customer id (a number, used to recognise a returning shopper).
* Billing first name, last name, email address, phone number, city and state.
* For each line item: product name, SKU, quantity and unit price.
* Two request headers identifying the plugin version and the delivery attempt, plus an idempotency
  key derived from the order id.

**Why it is transmitted**

* The order fields become a sales order and a tax invoice in Factro.
* The billing name, email and phone create or match the customer that invoice is raised against.
* The billing city and state support invoice address and tax-region handling.
* The line items become the invoice lines and are matched to your Factro item master by SKU.
* The idempotency key lets Factro discard a duplicate delivery, so a retry never creates a second
  sales order for the same WooCommerce order.

**What is never transmitted**

Card numbers, CVVs, bank details or any other payment credential; payment-gateway responses; order
notes; customer notes; WordPress users, posts, pages, media or settings; and anything belonging to
other plugins.

**Service terms and policies**

* Privacy policy: https://app.factro.in/privacy
* Terms of service: https://app.factro.in/terms
* Support: https://app.factro.in/support
* Integration guide: https://app.factro.in/integrations/woocommerce

== Installation ==

1. In Factro, open Dashboard > Integrations and create a WooCommerce connection using the free
   plugin option.
2. Copy the store-specific webhook URL Factro shows you. Treat it like a password.
3. Install this plugin from Plugins > Add New > Upload Plugin, then activate it.
4. Open WooCommerce > Factro Connector.
5. Paste the webhook URL and save.
6. Place one test order and verify the customer and sales order appear in Factro.

== Frequently Asked Questions ==

= Do I need WooCommerce API keys? =

No. The plugin pushes orders out to Factro; Factro never reads back from your store, so no API keys
are created or stored.

= Will this slow down or break my checkout? =

No. Delivery is queued through Action Scheduler and runs in a background request after the order
already exists. A failure to reach Factro never affects the shopper.

= What happens if Factro is unreachable? =

The order is retried automatically with an increasing delay, up to six attempts over about seven
hours. Retries are idempotent, so a delivery that eventually succeeds still produces exactly one
sales order in Factro.

= A delivery failed and was not retried. Why? =

A 4xx response other than 408 or 429 means the request itself was rejected — almost always a webhook
URL that has been regenerated in Factro. Retrying cannot fix that, so the plugin stops and shows the
failure on its settings screen. Paste the current URL from Factro and place another test order.

= What happens when I delete the plugin? =

Deleting it removes the stored webhook URL, the delivery status and any queued retries from your
WordPress database. Your WooCommerce orders are untouched, and orders already imported stay in your
Factro account.

= Where do I get help? =

Email support@factro.in with your store URL and the last delivery message shown on the plugin's
settings screen.

== Changelog ==

= 1.2.0 =
* Cancellations, refunds and failed payments are now sent to Factro. Previously only newly created
  orders were delivered, so an order cancelled or refunded in WooCommerce stayed open in Factro and
  had to be cancelled by hand in both systems.
* The idempotency key is now scoped to the order *and* its status, so a retry of one delivery is
  still deduplicated while a later cancellation is not mistaken for that same delivery.
* Which statuses are reported can be adjusted with the `factro_connector_reportable_statuses` filter;
  the default is cancelled, refunded and failed.
* Verified against PHP 7.4 (the declared minimum) and PHP 8.2.

= 1.1.0 =
* Added automatic retry with backoff for failed or non-2xx deliveries, using Action Scheduler.
* Deliveries are now idempotent: an order already delivered is never sent twice, and each request
  carries a stable idempotency key.
* Added a connection-status panel showing whether the last delivery succeeded and whether a retry is
  pending.
* Added uninstall.php so deleting the plugin removes its settings, delivery status and queued
  retries (multisite aware).
* Deactivating the plugin now cancels pending retries.
* Added the required External services disclosure.

= 1.0.0 =
* Initial free connector with HPOS compatibility and asynchronous order delivery.

== Upgrade Notice ==

= 1.1.0 =
Failed order deliveries now retry automatically instead of being lost. Recommended for all users.
