=== MercanPay – Crypto Payments (USDT, TRX) ===
Contributors: mercanpay
Tags: crypto, usdt, trx, tron, payment gateway
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept USDT (TRC-20) and TRX in WooCommerce. Customers pay on the secure MercanPay page; orders are confirmed automatically.

== Description ==

**English**

MercanPay lets your WooCommerce store accept **USDT (TRC-20)** and **TRX** on the TRON network.

* At checkout the customer is sent to the secure MercanPay payment page (QR code, address and exact amount, live payment tracking).
* The order total is sent as a USD price; the customer picks USDT or TRX (or you fix the coin).
* Orders are confirmed automatically by **signed webhooks** (HMAC-SHA256, 5-minute replay window). Each notification is re-checked against the MercanPay API before the order is completed.
* If a webhook is ever missed, a background check every 10 minutes and a **Check payment status** button on the order screen catch up.
* Partial payments put the order on hold; the customer can pay the rest on the same page. Expired invoices mark the order as failed; a late payment still completes it.
* Retrying the checkout reuses the open invoice, so a customer never gets two invoices for the same order by accident.
* Works with the classic checkout and the **Cart/Checkout blocks**, and with **HPOS** (High-Performance Order Storage).
* Turkish translation included.

You need a MercanPay merchant account: [mercanpay.com](https://mercanpay.com).

**Türkçe**

MercanPay ile WooCommerce mağazanızda TRON ağı üzerinden **USDT (TRC-20)** ve **TRX** ödemesi alabilirsiniz.

* Ödeme adımında müşteri güvenli MercanPay ödeme sayfasına yönlendirilir (QR kod, adres ve tam tutar, canlı ödeme takibi).
* Sipariş tutarı USD fiyatı olarak gönderilir; müşteri USDT veya TRX seçer (isterseniz coini siz sabitlersiniz).
* Siparişler **imzalı webhook** bildirimleriyle otomatik onaylanır (HMAC-SHA256, 5 dakikalık tekrar penceresi). Sipariş onaylanmadan önce her bildirim MercanPay API'sinden yeniden doğrulanır.
* Bir bildirim kaçsa bile 10 dakikada bir çalışan arka plan kontrolü ve sipariş ekranındaki **Ödeme durumunu kontrol et** düğmesi durumu yakalar.
* Kısmi ödemede sipariş beklemeye alınır; müşteri kalanını aynı sayfadan öder. Süresi dolan faturada sipariş başarısız olur; geç gelen ödeme yine de siparişi tamamlar.
* Müşteri ödemeyi yeniden denediğinde açık fatura tekrar kullanılır; aynı sipariş için yanlışlıkla iki fatura oluşmaz.
* Klasik ödeme sayfası ve **Sepet/Ödeme blokları** ile, ayrıca **HPOS** (yüksek performanslı sipariş depolama) ile uyumludur.
* Türkçe çeviri dahildir.

Bir MercanPay satıcı hesabı gerekir: [mercanpay.com](https://mercanpay.com).

== Installation ==

1. Upload the plugin (Plugins → Add New → Upload Plugin → `mercanpay-for-woocommerce-1.0.0.zip`) and activate it. WooCommerce must be active.
2. In the MercanPay merchant panel create an **API key** with the `invoices` permission, and copy the **webhook signing secret** (`whsec_…`) from Settings.
3. In WooCommerce → Settings → Payments → **MercanPay**, paste the API key and webhook secret, choose the coin selection and invoice lifetime, then save.
4. Click **Test API connection**.
5. If your store currency is not USD, enter the "1 <currency> = ? USD" exchange rate (or provide it with the `mercanpay_usd_rate` filter). Without a rate the payment method stays hidden.

**Kurulum (TR)**

1. Eklentiyi yükleyip etkinleştirin (Eklentiler → Yeni ekle → Eklenti yükle). WooCommerce etkin olmalıdır.
2. MercanPay satıcı panelinde `invoices` yetkili bir **API anahtarı** oluşturun ve Ayarlar'daki **webhook imza sırrını** (`whsec_…`) kopyalayın.
3. WooCommerce → Ayarlar → Ödemeler → **MercanPay** sayfasında API anahtarını ve webhook sırrını girin, coin seçimini ve fatura süresini ayarlayıp kaydedin.
4. **API bağlantısını test et** düğmesine tıklayın.
5. Mağaza para biriminiz USD değilse "1 <para birimi> = ? USD" kurunu girin (veya `mercanpay_usd_rate` filtresiyle sağlayın). Kur yoksa ödeme yöntemi gizli kalır.

== Frequently Asked Questions ==

= Where is the webhook URL? / Webhook adresi nedir? =

`https://your-store.com/?wc-api=mercanpay` (shown on the settings page). The plugin sends it with every invoice as `callback_url`, so you do not have to enter it in the MercanPay panel. / Adres ayarlar sayfasında gösterilir ve her faturayla `callback_url` olarak gönderilir; panele ayrıca girmeniz gerekmez.

= My store currency is TRY/EUR. / Mağazam TL/EUR kullanıyor. =

MercanPay invoices are priced in USD. Enter a manual "1 TRY = X USD" rate in the settings, or hook `mercanpay_usd_rate` (return USD per one unit of the store currency) to use a live rate. / Faturalar USD ile fiyatlanır. Ayarlara elle kur girin ya da canlı kur için `mercanpay_usd_rate` filtresini kullanın.

= The amount the customer paid is higher than my order total. / Müşterinin ödediği tutar sipariş tutarından yüksek. =

Depending on your MercanPay settings the invoice can include the commission and a small network fee. The plugin trusts MercanPay's invoice status (paid / overpaid), never an amount comparison. / MercanPay ayarlarınıza göre fatura tutarı komisyon ve küçük bir ağ ücreti içerebilir. Eklenti tutar karşılaştırmasına değil, MercanPay'in fatura durumuna güvenir.

= What happens if the customer pays too little? / Müşteri eksik öderse? =

The order goes on hold with a note; the payment page shows the remainder and the customer can send it to the same address. / Sipariş not düşülerek beklemeye alınır; müşteri kalanı aynı adrese gönderebilir.

= A webhook did not arrive. / Bildirim gelmedi. =

Unpaid MercanPay orders from the last 24 hours are re-checked every 10 minutes (WP-Cron), and you can press **Check payment status** on the order. If your site gets little traffic, set up a real cron job for `wp-cron.php`. / Son 24 saatteki ödenmemiş siparişler 10 dakikada bir yeniden kontrol edilir; sipariş ekranındaki düğmeyle de kontrol edebilirsiniz.

= Is my store on localhost supported? / Yerel (localhost) mağaza çalışır mı? =

Invoices can be created, but MercanPay only calls public URLs, so the webhook and redirect URLs are left out and orders are confirmed by the status check. / Fatura oluşturulur ama MercanPay yalnızca herkese açık adreslere bildirim gönderir; siparişler durum kontrolüyle onaylanır.

= Developer hooks =

* `mercanpay_usd_rate` ( float|null $rate, string $currency, WC_Order|null $order )
* `mercanpay_price_usd` ( float $usd, WC_Order $order, float $rate )
* `mercanpay_invoice_request` ( array $payload, WC_Order $order, int $attempt )
* `mercanpay_order_reference` ( string $ref, WC_Order $order, int $attempt )
* `mercanpay_webhook_url`, `mercanpay_api_base_url`, `mercanpay_icon`

== Changelog ==

= 1.0.0 =
* First release: USDT (TRC-20) and TRX payments, signed webhooks with API re-verification, partial / overpaid / expired handling, 10-minute fallback status check, order meta box, block checkout, HPOS, Turkish translation.
* İlk sürüm: USDT (TRC-20) ve TRX ödemeleri, API ile yeniden doğrulanan imzalı webhooklar, kısmi / fazla / süresi dolmuş ödeme yönetimi, 10 dakikalık yedek durum kontrolü, sipariş kutusu, blok ödeme sayfası, HPOS, Türkçe çeviri.

== Upgrade Notice ==

= 1.0.0 =
First release.
