=== Bezanbecard for Easy Digital Downloads ===
Contributors: bezanbecard
Tags: easy digital downloads, card to card, bank transfer, receipt, iran
Requires at least: 6.2
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

Offline payments with receipt (card-to-card or bank transfer) for Easy Digital Downloads. Customers upload the receipt and your team approves it.

== Description ==

Bezanbecard (بزن به کارت) is reconciliation and evidence software for offline payments. It is non-custodial: the customer pays from their banking app, card-to-card or by bank transfer (Pol, Paya, Satna), straight to your own card or account, then uploads the bank receipt. Your team reviews the receipt in the Bezanbecard dashboard and approves or rejects it, and every step is kept as evidence. The Bezanbecard SMS watcher app is optional: it only corroborates receipts from your bank SMS.

This plugin adds Bezanbecard as a payment method to Easy Digital Downloads:

* At checkout the customer is sent to the Bezanbecard payment page, which shows the exact amount and where to pay, and takes the receipt.
* While a receipt waits for review the order is "Processing" with the note "Receipt submitted, waiting for review". If the receipt is rejected and nothing was received, the order is pending again.
* The order completes once the payment is approved, through a signed webhook and a check on the customer's return.
* A wrong amount is not a dead end. A partial payment is recorded on the order and the customer is asked for the rest; an overpayment is recorded so you can refund, credit or keep it from the Bezanbecard dashboard. Each step is written to the order notes.
* Test mode follows the Easy Digital Downloads test mode and uses your test keys, so you can try the whole flow with receipts and simulated deposits.
* One-click "Connect with Bezanbecard" fills in the keys, the webhook secret and the redirect signing secret. Manual key entry works too.
* Works with Easy Digital Downloads 3.x orders and falls back to the 2.x payments API.
* Persian (fa_IR) translation included.

= External services =

This plugin connects to the Bezanbecard service, which processes the payments. It is required for the plugin to work.

* When a customer places an order with Bezanbecard, the plugin sends the order amount (in rial), the order id, the customer's name and email, the store's return URLs and site address to `https://a.bezanbecard.com/v1/payments`, and the customer is redirected to `https://bezanbecard.com/pay/...`.
* When the customer returns and whenever a webhook arrives, the plugin reads the payment status from `https://a.bezanbecard.com/v1/payments/<id>`.
* When you use "Connect with Bezanbecard", your site address, site name and the plugin's return and webhook URLs are sent to `https://bezanbecard.com/dashboard/connect`, and the one-time code is exchanged at `https://a.bezanbecard.com/v1/connect/exchange`.

Terms of service: https://bezanbecard.com/legal/terms
Privacy policy: https://bezanbecard.com/legal/privacy

== Installation ==

1. Install and activate Easy Digital Downloads.
2. Upload the `bezanbecard-for-edd` folder to `/wp-content/plugins/` (or install the zip from Plugins > Add New), then activate it.
3. Set the store currency to Iranian rial or toman in Downloads > Settings > General > Currency.
4. Go to Downloads > Settings > Payments, enable "Bezanbecard (offline payment with receipt)", then open the Bezanbecard section.
5. Click "Connect with Bezanbecard" and approve the connection in your Bezanbecard dashboard. Do this once with EDD test mode on and once for live mode, or paste the keys yourself (see below).

= Manual setup =

1. In the Bezanbecard dashboard, open Developers and create a secret key (sk_test_… for test mode, sk_live_… for live mode). A restricted key (rk_…) with write access to payments also works.
2. Add a webhook endpoint with the URL shown in the plugin settings (`https://your-site/wp-json/bezanbecard-edd/v1/webhook`) and subscribe it to the payment events.
3. Paste the secret key and the endpoint's signing secret (whsec_…) into the matching test or live fields.
4. Optionally paste the redirect signing secret (rds_…) of the same mode, revealed under Developers > API keys. With it the store refuses a forged return link before it asks Bezanbecard; without it every return is still confirmed with the API.

== Frequently Asked Questions ==

= Which currencies are supported? =

Iranian rial and toman. The plugin recognises the currency codes RIAL (Easy Digital Downloads' own), IRR, IRT, TOMAN, IRHR (thousand rial) and IRHT (thousand toman), and converts the order total to rial for Bezanbecard. A developer can map another code with the `bezanbecard_edd_rial_multiplier` filter.

= Why does the customer transfer a slightly different amount? =

With unique amounts on (the default), Bezanbecard gives each payment a unique amount so that a transfer can be matched to exactly one order. The order itself is charged its normal total.

= What happens when the customer pays the wrong amount? =

If they pay less, the order stays pending, the amount received is noted on the order and the Bezanbecard payment page asks for the rest. When the total arrives the order completes. If they pay more, the order completes and the overpayment is noted; resolve it from the Bezanbecard dashboard.

= The customer came back but the order is not complete yet. =

The order completes once your team approves the customer's receipt in the Bezanbecard dashboard (or, if you use the optional SMS watcher with automatic approval, once the bank SMS matches). Make sure the webhook is set up so the order is updated even when the customer has closed the page.

= Can I use a staging Bezanbecard server? =

Define `BEZANBECARD_EDD_API_URL` and `BEZANBECARD_EDD_WEB_URL` in `wp-config.php`.

= What is removed when I delete the plugin? =

The Bezanbecard settings, the connected account details and temporary data. Orders, order notes and transaction ids are kept because they are part of your store's records.

== Changelog ==

= 1.0.0 =
* First release: hosted checkout for offline payments with receipt (card-to-card or bank transfer), orders in Processing while a receipt waits for review, signed webhooks, return confirmation, partial and overpayment notes, Connect with Bezanbecard, EDD 3.x and 2.x support, Persian translation.
