=== sild – Merit Aktiva for WooCommerce ===
Contributors: sild
Tags: merit aktiva, accounting, invoice, woocommerce, estonia
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 9.0
WC tested up to: 11.1

WooCommerce orders become Merit Aktiva invoices, credit notes and payments, with totals that match the order to the cent.

== Description ==

sild connects your WooCommerce store to **Merit Aktiva** accounting. Every order gets its sales invoice in Merit Aktiva, every refund its credit note, and payments are recorded, so your accountant no longer types orders in by hand.

Merit Aktiva in Estonia is fully supported. Merit Aktiva Finland and Poland (360 Księgowość) are in beta.

= What it does =

* **Invoices** – a Merit Aktiva sales invoice when an order reaches the status you choose (Processing or Completed), with your own invoice number prefix. VAT and rounding are worked out the way Merit Aktiva does it, so the invoice total equals what the customer paid.
* **Credit notes** – for full, partial, line and amount-only refunds, and for cancelled orders if you want (delete the unpaid invoice, credit it, or do nothing). A credit note can be offset against its unpaid invoice.
* **Payments both ways** – paid orders are recorded as paid in Merit Aktiva, per payment method and bank account. Payments you record in Merit Aktiva (for example a bank transfer that arrived) can move the order to Processing or Completed.
* **Bank reference (7-3-1)** – each order gets an Estonian reference number with a check digit. It goes on the invoice and is shown to customers who pay by bank transfer, so payments match by themselves.
* **Stock from Merit Aktiva** – stock levels of chosen Merit Aktiva warehouses update your products that manage stock. Sales not yet invoiced are taken into account.
* **Business customers** – registry code and VAT number fields at checkout (classic and block checkout). VAT numbers are checked in the EU VIES register; valid numbers from other EU countries can get zero VAT (reverse charge). Exports outside the EU use their own Merit Aktiva rate.
* **Merit Aktiva PDF on the order email** – the invoice PDF can be attached to the Completed order email, and downloaded from the order screen.
* **Preview mode** – every new store starts here. sild builds the invoices it would create and compares them with the ones already in Merit Aktiva, without writing anything. A checklist on Overview shows when it is safe to switch to Live.
* **Daily check** – every morning sild looks at yesterday: failed orders, stalled work, and whether each invoice it made is still in Merit Aktiva with the same total.
* **Alerts** – emails about failed orders, a refused Merit Aktiva API key and daily check problems, plus an optional daily summary.
* **Switching from another plugin** – imports the VAT and payment mappings of another Merit Aktiva plugin, and does not let you go live while the old plugin still creates invoices, so nothing is invoiced twice.
* **Orders & checks** – the Merit Aktiva state and invoice number on every order, a filter on the orders list, invoice preview, "Send to Merit Aktiva again", and a check or resend of past orders.

Checkout is never slowed down: order changes are queued on your site and delivered in the background, with retries. Works with High-Performance Order Storage (HPOS) and the block checkout.

= How it works =

This plugin is a free, open-source connector. Building the invoices (VAT, rounding, credit notes) and talking to Merit Aktiva happen in the **sild cloud service**, run by the plugin author. **The plugin needs a sild account to work.** The account is created when you connect, starts with a free trial and has a free plan; paid plans raise the monthly order limit and add features. Prices: [sild.cloud/en/pricing](https://sild.cloud/en/pricing). All plugin code is included and licensed under the GPL; nothing in the plugin is locked.

Your Merit Aktiva licence must include API access.

sild is an independent product. It is not made, endorsed or supported by Merit Tarkvara AS. Merit Aktiva is a trademark of its owner.

== External services ==

The plugin connects to the services below. Nothing is sent before you connect the store in the setup wizard, except where noted.

= sild cloud service (api.sild.cloud) =

The service that creates documents in Merit Aktiva for your store. The plugin itself never contacts Merit Aktiva. Every request after connecting is signed with a secret issued to this site.

Data sent to `https://api.sild.cloud`, and when:

* **Connecting** (setup wizard or Settings → Connection): your email address, Merit Aktiva country, API ID and API key, company registry code, site URL, callback URL and admin URL of this site, WordPress, WooCommerce and plugin versions, and the site language. The Merit Aktiva API key is sent once over HTTPS, stored encrypted by sild and never saved in WordPress.
* **Orders** – when an order is created, changes status, is paid, refunded, cancelled or deleted, and when you check or resend past orders or use "Sync to Merit Aktiva" / "Send to Merit Aktiva again": the order data needed for the invoice. That is order number, dates, status, currency, bank reference, billing name, company, address, email and phone, shipping country, customer account number, payment method, products (name, SKU, EAN/GTIN, quantity, prices, taxes, cost if your store records it), shipping and fees, coupons, tax rates, refunds, and the company registry code, VAT number and its VIES result if given.
* **Refunds**: the refund amount, reason and refunded lines, with the order data above.
* **Settings**: what you save on the Settings screen or in the wizard: your WooCommerce VAT rates and payment methods with the Merit Aktiva rates, payment methods and bank accounts they map to, warehouses, invoice and email options.
* **Plugin screens**: opening Overview, Orders & checks, Settings or Plan & billing asks sild for your plan and usage, order counts, settings, Merit Aktiva lists (VAT rates, payment methods, banks, warehouses, departments), sync logs and the preview report. Preview, Retry and PDF on an order ask for that order.
* **Status updates**: every minute queued order events are delivered, and every five minutes the state of orders still waiting is asked for (order IDs only).
* **Stock**: if stock from Merit Aktiva is on, sild sends stock levels (SKU and quantity) to this site; the plugin sends nothing extra for it.
* **Diagnostics**: the Diagnostics button checks the connection and fetches recent failed syncs to build a support report. The report stays on your screen; you decide whether to send it to support. It contains no keys and no customer data.
* **Disconnecting or deleting the plugin**: a signed "disconnect" request, so sild stops syncing the store and erases the Merit Aktiva API key when no other site of the company uses it.

sild sends signed messages back to this site at `/wp-json/sild/v1/callback` (order states, settings changes, stock levels). sild emails the address you connected with about failed orders and daily check problems, and invoices for paid plans.

sild keeps order details for 60 days after the invoice is done; the documents themselves stay in your Merit Aktiva.

* Terms of Service: https://sild.cloud/en/terms
* Privacy Policy: https://sild.cloud/en/privacy

= Merit Aktiva =

sild sends the invoices, credit notes, payments and customers to Merit Aktiva (Merit Tarkvara AS) with your API key, and reads VAT rates, payment methods, banks, warehouses, invoices, payments and stock from it. Your site never contacts Merit Aktiva directly.

Your agreement with Merit Tarkvara AS applies to that data: https://www.merit.ee

= EU VIES VAT number check =

When a shopper enters a VAT number at checkout (only if the business fields are on), the plugin sends the VAT number and billing country to sild, which asks the European Commission's VIES service whether the number is valid. The answer is cached on your site for a day.

* VIES: https://ec.europa.eu/taxation_customs/vies/
* European Commission privacy: https://commission.europa.eu/privacy-policy-websites-managed-european-commission_en

= Stripe (billing) =

When you choose a paid plan or click "Manage billing" on Plan & billing, sild creates a Stripe Checkout or customer portal session and your browser is sent to `checkout.stripe.com` or `billing.stripe.com`. Your card or bank details go to Stripe only, never to your site or to sild.

* Stripe terms: https://stripe.com/legal/ssa
* Stripe privacy: https://stripe.com/privacy

= Updates (copy from sild.cloud only) =

The copy of the plugin downloaded from sild.cloud checks `https://api.sild.cloud/api/v1/plugin/update` twice a day for a new version, sending only the plugin, WordPress and PHP versions. The copy from WordPress.org does not include this and is updated by WordPress.org.

== Installation ==

1. Install and activate WooCommerce (9.0 or newer).
2. Install and activate this plugin.
3. In Merit Aktiva open **Settings → Company data → API settings** and create an API key.
4. In WordPress open **sild · Merit Aktiva** in the admin menu. The setup wizard asks for your email, Merit Aktiva country, API ID, API key and company registry code.
5. Match your VAT rates and payment methods in the wizard. You can change them later under **sild · Merit Aktiva → Settings**.
6. Your store starts in **preview mode**. Start the check of past orders, read the results under **sild · Merit Aktiva → Orders & checks**, and switch to Live from the checklist on **Overview** when you are happy.

== Frequently Asked Questions ==

= Which Merit Aktiva licence do I need? =

One that includes API access. Merit Aktiva allows the API only on some licences; if yours does not, the setup wizard tells you when you connect.

= Which countries are supported? =

Merit Aktiva Estonia is fully supported. Merit Aktiva Finland and Poland (360 Księgowość) work but are in beta: check the preview report carefully before going live.

= Is my Merit Aktiva API key stored in WordPress? =

No. It is sent once to sild when you connect and never saved on your site. The only secret stored in WordPress is the site secret used to sign requests to sild.

= How do I try it without touching my accounting? =

Every store starts in preview mode. sild builds the invoices it would create and compares them with the ones in Merit Aktiva, writing nothing. See the result under **sild · Merit Aktiva → Orders & checks**. Preview checks do not count towards your plan.

= I use another Merit Aktiva plugin. Can I switch? =

Yes. sild can import its VAT and payment mappings (Settings), and the go-live checklist on **Overview** stays blocked while the other plugin still creates invoices. Turn it off, then switch sild to Live.

= What happens when I go over my monthly order limit? =

On the Free plan, orders above the limit wait and are sent after an upgrade or at the start of next month; nothing is lost. Paid plans keep syncing over the limit and show the overage on **Plan & billing**. Only live invoices count.

= What happens if the sild service is unreachable? =

Order events wait in a queue on your site and are retried automatically with growing delays. Nothing is lost; you can also resend an order from its order screen or from **Orders & checks**.

= Where do registry codes and VAT numbers come from? =

From the business fields sild can add to the checkout, or from order fields of your own checkout plugin. Choose them under **sild · Merit Aktiva → Settings → Customers**.

= What does it cost? =

The plugin is free. The sild service has a free plan and paid plans: [sild.cloud/en/pricing](https://sild.cloud/en/pricing). Change or cancel your plan under **sild · Merit Aktiva → Plan & billing**.

= Can I change the sild API address? =

For development only: define `SILD_API_URL` in `wp-config.php`.

== Screenshots ==

1. Overview: orders sent to Merit Aktiva, sync health and anything that needs attention.
2. Orders & checks: every order with its Merit Aktiva state and invoice number.
3. The sild box on the order screen: invoice, credit note for a refund, preview and the Merit Aktiva PDF.
4. Settings: WooCommerce VAT rates matched to Merit Aktiva rates, and payment methods to Merit Aktiva banks.
5. Plan & billing: orders this month and plans.

== Changelog ==

= 1.0.0 =
* First public release.
* Merit Aktiva sales invoices for orders, at the order status you choose, with VAT and rounding done exactly as Merit Aktiva does them, and your own number prefix.
* Credit notes for refunds and cancellations, optional offset against the unpaid invoice.
* Payments recorded in Merit Aktiva per payment method and bank account; payments made there update the order status.
* Estonian 7-3-1 bank reference on invoices and for bank-transfer customers.
* Stock levels from chosen Merit Aktiva warehouses.
* Business customer fields at checkout with VIES check; reverse charge and export VAT rates.
* Merit Aktiva invoice PDF on the Completed order email and on the order screen.
* Preview mode with a report and a go-live checklist; daily check and email alerts.
* Import of mappings from another Merit Aktiva plugin.
* Admin screens: Overview, Orders & checks, Settings, Plan & billing, setup wizard and diagnostics report.
* Background delivery with retries; HPOS and block checkout support.

== Upgrade Notice ==

= 1.0.0 =
First public release.
