=== DigitalBrains Payment Gateway for Paynet.am ===
Contributors: digitalbrainsam
Tags: woocommerce, payments, armenia, arca, idram
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
WC requires at least: 7.0
Stable tag: 1.7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept payments in Armenia via Paynet.am (ARCA, Idram, Telcell, and partner banks) in WooCommerce.

== Description ==

Official WooCommerce plugin for the Paynet.am payment platform. Paynet.am is our own product, operated by Digital Brains LLC (https://digitalbrains.am). Connect your store to your Paynet.am account in one click - no API keys to copy - and accept card and wallet payments.

Includes:

* One-click Connect (no API keys typed by hand)
* Card and wallet processors (ARCA, Idram, Telcell, ACBA, Evocabank, Inecobank, Ameriabank, and more)
* Each connected processor appears as its own named choice at checkout - on both the classic and the block-based (Gutenberg) checkout
* Automatic order-status sync with pull-verification (a forged webhook can never mark an order paid)
* The e-HDM fiscal receipt QR shown to the customer on the thank-you page
* Refunds from the WooCommerce order screen
* Compatible with High-Performance Order Storage (HPOS) and the Cart/Checkout Blocks
* Translation-ready (the translation template ships in the languages folder), with your own method names per store language; the Paynet and bank payment pages open in Armenian, Russian or English

= External services =

This plugin relies on the Paynet payment platform at https://paynet.am, operated by Digital Brains LLC. Without a connected Paynet account the gateway does nothing. The plugin calls no other service: every request below goes to https://paynet.am over HTTPS, and once the store is connected most of them carry the store's connect token and the plugin version.

What is sent, and when:

* Connecting the store (POST /connect/auto, or the paynet.am /connect/start sign-in popup): your store domain, store name, the WordPress admin email address, the admin's language, and a one-time code that Paynet may confirm with your own site to prove the request came from it.
* Opening your Paynet dashboard from the settings page (POST /connect/dashboard): the connect token, to sign you in.
* Saving the plugin settings (POST /embed/configure): the processors you selected. Your custom method names stay in your store.
* Showing the payment methods (GET /api/v1/processors, on the settings page, on Test connection and at checkout, where the answer is cached for two minutes): your store domain and, at checkout, the shopper's language. The answer lists the methods Paynet offers and the latest plugin version.
* When a customer pays (POST /api/v1/payments): the order id, the order total and currency (AMD), the chosen processor, the payment page language, your store domain, the store's return, cancel and notification URLs, and the order lines (product name, SKU, quantity and price, plus fee and shipping lines) for the e-HDM fiscal receipt. No customer name, email address, phone number or postal address is sent.
* Checking an order (GET /api/v1/orders/{order id}/payment): the order id, when a payment notification arrives, on the customer's thank-you page, and every 10 minutes for orders still pending.
* Showing the fiscal receipt on the thank-you page (GET /api/v1/payments/{payment id}): the Paynet payment id. The customer's browser then loads the receipt QR image from paynet.am.
* Refunding from the order screen (POST /api/v1/payments/{payment id}/refund): the refund amount and the reason you type.
* Renewing the connection (POST /connect/rotate): the current connect token, when Paynet asks for it and otherwise at most once a day, to swap it for a new one before it expires.

Paynet also contacts your store: it sends a payment notification to the store's notification URL (it only names the order to re-check), and while you connect it asks your site to confirm the one-time code.

To pay, the customer leaves your store for the Paynet payment page and the bank's or wallet's own page, where they enter their card or wallet details. No card numbers ever touch your store.

Service terms: https://paynet.am/terms
Privacy policy: https://paynet.am/privacy

== Installation ==

1. Upload the plugin ZIP via Plugins > Add New > Upload Plugin, or copy the `digitalbrains-payment-gateway-for-paynetam` folder to `wp-content/plugins/`.
2. Activate the plugin through the Plugins screen.
3. Go to WooCommerce > Settings > Payments > Paynet and click Connect to authorize your store.

== Frequently Asked Questions ==

= Do I need a Paynet account? =

Yes. Clicking Connect creates a free-tier account automatically if you do not have one; otherwise a login window links the store to your existing account at paynet.am.

= Which currencies are supported? =

Armenian Dram (AMD) only. The gateway refuses checkout in any other store currency to protect you from under-charged orders.

= Which payment processors can my customers use? =

Any processor connected to your Paynet account: ARCA and the ARCA member banks (ACBA, Evocabank, Converse Bank, AraratBank, IDBank, Ardshinbank and others), Ameriabank, Inecobank, and the Idram and Telcell wallets. Each one you enable appears as its own named option at checkout.

= Does it work with the new block-based (Gutenberg) checkout? =

Yes. The per-processor picker renders on both the classic shortcode checkout and the Cart/Checkout Blocks.

= Can a forged webhook mark an order as paid? =

No. The webhook is treated only as a hint to re-check an order; the plugin always fetches the authoritative payment status from your Paynet account (authenticated with your connect token) and additionally verifies the paid amount and currency against the order before completing it.

= Where are the fiscal (e-HDM) receipts? =

If e-HDM is configured on your Paynet account, the fiscal receipt QR is shown to the customer on the thank-you page. When the receipt is already issued as the payment completes, its link is also added to the order notes.

= Can I test before taking real payments? =

Yes. While your store takes no real payments, Paynet can offer a Sandbox (Test) method. A completed test payment completes the order exactly like a real one (no money moves), so test with orders you will cancel. Test methods are never offered once the store takes real payments.

== Screenshots ==

1. One-click Connect in the plugin settings.
2. Payment methods and per-language method names.
3. The per-processor picker at checkout.
4. e-HDM fiscal receipt QR on the thank-you page.

== Changelog ==

= 1.7.0 =
* Safer order updates: each order is updated by one request at a time, so a payment is never applied twice, and a payment result is applied only to the order that started that payment.
* An order you have already moved on (processing, completed, shipped and so on) is never moved back by a late payment result.
* The paid amount check now also handles order totals with fractions of a dram.
* Checkout shows only the payment methods Paynet currently offers for your store. A method you switched off in Paynet is refused with a clear message instead of being paid through another bank. Only when Paynet cannot be reached does the store fall back to the methods saved in its settings, and it then waits a minute before asking again.
* The thank-you page asks for the fiscal receipt at most 6 times, waiting longer each time, and not at all when no receipt will be issued.
* Stores on plain permalinks: payment notifications and the receipt check now reach the store. Before, they landed on the home page and orders waited for the background check.
* Block-based (Gutenberg) checkout: when a payment cannot start, the customer now sees a short message instead of a silent failure. The reason is kept in the order notes and in WooCommerce > Status > Logs (source paynet).
* One-click Connect now lets Paynet confirm that the request really comes from your own site.

= 1.6.12 =
* The settings page now says why no payment methods are showing - whether the store still needs a payment provider or a verified domain - and gives you a one-click, already-signed-in link to the right screen. Previously it only said the list was empty.

= 1.6.11 =
* Security release. Hardens how the store's connect token is handled in the admin screen and tightens validation on the data the gateway accepts back from the payment page. Upgrading is recommended for every store.

= 1.6.10 =
* A payment that is confirmed after the checkout window closed now completes the order instead of leaving it cancelled. Previously a slow payment could be taken by the bank while the order stayed cancelled and unfulfilled.

= 1.6.9 =
* Refund orders straight from the WooCommerce order screen - full or partial. The refund is processed by Paynet and the result is noted on the order.
* Extra fees (for example a cash-on-delivery fee) now appear as their own line on the customer's fiscal receipt.
* Fixed the fiscal receipt QR appearing twice on the thank-you page with some themes.
* Additional security hardening of the payment method handling.
* Deleting the plugin now cleans up after itself. Your Paynet connection is kept, so reinstalling continues with the same account.

= 1.6.8 =
* Renamed the plugin to "DigitalBrains Payment Gateway for Paynet.am" per the WordPress.org plugin review guidelines. Existing installs keep all their settings.

= 1.6.7 =
* Updated the Idram method logo.

= 1.6.6 =
* Fixed the payment method on/off switches overlapping their labels in the settings.

= 1.6.5 =
* Fixed oversized payment method logos on the classic checkout and Pay-for-order pages.

= 1.6.4 =
* Abandoning payment on the Paynet page returns the customer to the "Pay for order" page - the order keeps its items and can be paid again.

= 1.6.3 =
* Abandoning payment on the Paynet page now returns the customer to the store instead of stranding them (via a dedicated cancel URL).

= 1.6.2 =
* The payment method is hidden at checkout until the store is connected to Paynet and priced in AMD (previously an unconnected store showed the method and failed at submit on the classic checkout).
* Added a Settings link on the Plugins screen for quick access to the gateway settings.
* The API base URL is now fixed to paynet.am (no longer an editable setting), so requests can never be redirected.
* Until the store is connected, the settings page shows only the Connect step; the full settings appear after connecting.
* Fixed "Manage in dashboard" reloading the settings page instead of opening the Paynet dashboard.
* Translation-ready: translation plugins such as Loco Translate can translate every text in the plugin.
* The checkout redirect notice is now disabled by default.
* The shopper's storefront language (hy/ru/en) is sent with each payment, so the Paynet checkout and the bank/wallet payment page open in the customer's language; the Connect popup follows the wp-admin user's language.
* Each connected processor now appears as its own payment method at checkout (classic and Blocks) - with your custom per-language name and the method's logo.
* Bundled logos for ArCa, Idram, Telcell, and all ARCA member banks (shipped inside the plugin, never loaded remotely), plus a "Method logos" switch to show or hide them at checkout.
* New "Payment page language" setting: Auto (customer's language) or a fixed hy/ru/en.
* Enable/Disable and the redirect notice are now on/off switches instead of checkboxes.
* Fixed the gateway showing as Inactive in the Payments list (with an Enable button) right after connecting, while the settings page showed it enabled.
* Method name and redirect message fields now match the store's actual languages (one field for a single-language shop; per-language fields only with Polylang/WPML).
* The settings page shows the installed plugin version and an update notice with a download link when a newer release exists (updates stay manual - nothing is ever pushed).

= 1.6.0 =
* Renamed to "Paynet.am Armenian Payments".
* All JavaScript is now enqueued via wp_enqueue_script/wp_add_inline_script (no inline script tags).
* Classes renamed to the Paynet_ prefix to avoid naming collisions.

= 1.5.0 =
* Block-based (Gutenberg) checkout support: the payment method picker now works on the Cart/Checkout Blocks too.
* Declared compatibility with Cart/Checkout Blocks and High-Performance Order Storage (HPOS).

= 1.4.0 =
* More secure payment verification: the order status is always fetched directly from your Paynet account, so a forged notification can never mark an order paid.
* The order also settles on the customer's thank-you page and via a background check, so a missed notification no longer leaves an order stuck pending.
* Per-processor checkout: each connected processor appears as its own choice at checkout, with your custom per-language name.
* Method names are stored only in your store; only the processor selection is synced to Paynet.
* One-click auto-connect (with the existing popup as the fallback for stores that already have a Paynet account).
* e-HDM fiscal receipt QR shown on the thank-you page.
* The gateway refuses non-AMD orders instead of risking a silently under-charged payment.

= 1.3.0 =
* Expanded settings: connection status (Connected + domain + token prefix) with Test connection and Manage-in-dashboard actions.
* Payment methods: choose which connected processors are offered on the Paynet checkout, fetched live from your account.
* Method names: per-processor, per-language (English / Հայերեն / Русский) display names.
* Sort Order field controls where Paynet appears among other checkout payment methods.
* Order-status mapping: Paynet completed/failed/refunded/expired outcomes map to WooCommerce order statuses.
* Redirect notice: show/hide toggle plus a per-language message shown at checkout before the customer is sent to Paynet.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.7.0 =
Safer order updates and checkout fixes, including plain-permalink stores and the block-based checkout. Recommended for all stores. No settings changes required.

= 1.6.12 =
Explains what is still missing when no payment methods appear. No settings changes required.

= 1.6.11 =
Security release - recommended for all stores. No settings changes required.

= 1.6.10 =
Fixes orders staying cancelled when the payment was confirmed after the checkout window closed. Recommended for all stores. No settings changes required.

= 1.6.9 =
Adds refunds from the order screen and fiscal receipt improvements. No settings changes required.

= 1.6.0 =
Plugin renamed; internal code cleanup. No settings changes required.

= 1.5.0 =
Adds the per-processor picker to the block-based (Gutenberg) checkout and declares HPOS/Blocks compatibility. No settings changes required.

= 1.4.0 =
Payment verification is now more secure; re-save the plugin settings once after upgrading so the processor list is refreshed.
