Metadata-Version: 2.4
Name: mercanpay
Version: 1.0.0
Summary: Official Python client for the MercanPay crypto payment gateway (TRX & USDT-TRC20)
Author-email: MercanPay <support@mercanpay.com>
License: MIT
Project-URL: Homepage, https://mercanpay.com
Project-URL: Documentation, https://mercanpay.com/documentation
Keywords: mercanpay,crypto,payment,gateway,usdt,trc20,tron,trx
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25
Dynamic: license-file

# MercanPay Python client

Official Python client for [MercanPay](https://mercanpay.com) — accept TRX and USDT (TRC20) payments.
Full API reference: https://mercanpay.com/documentation

```bash
pip install mercanpay
```

```python
from mercanpay import MercanPay, MercanPayError, verify_webhook

zp = MercanPay("https://mercanpay.com", "mp_...")  # API key from your merchant panel

# Invoice priced in USD — the customer picks the coin on the payment page
inv = zp.create_invoice(price_usd="25", order_id="order-1001", callback_url="https://shop.example/hook")

# Invoice in a fixed coin
inv = zp.create_invoice("USDT", "25", order_id="order-1002")
print(inv["address"], inv["payment_url"])

# Payout from your merchant balance (needs the 'withdrawals' scope; safe to retry with the same idempotency_key)
w = zp.create_withdrawal("USDT", "10", "T...", idempotency_key="wd-123")
print(w["status"])  # queued -> processing -> completed

# Webhook receiver (Flask example)
@app.post("/hook")
def hook():
    if not verify_webhook(SECRET, request.get_data(), request.headers.get("X-MercanPay-Signature", "")):
        abort(401)
    event = request.get_json()
    if event["type"] == "invoice.paid":
        ...
    return "ok"
```

Errors raise `MercanPayError` with `.status`, `.code` (e.g. `insufficient_funds`) and `.message`.
