Skip to content
ArionPay

Python library

Accept crypto payments in your Python app

Create crypto invoices from Flask, Django, FastAPI or a plain script, and check the signed webhook when the customer pays. The money goes straight to your own wallet.

Install

pip install arionpay
Source on GitHub
Example

What it does

ArionPay for Python developers

arionpay is the official ArionPay client for Python 3.8 or newer, written with the standard library only. It creates and reads invoices, checks webhook signatures on the raw body, and moves test invoices through payment scenarios.
Read moreInvoices come back as dicts with the same field names as the webhook, so one function can handle a webhook and a read. ArionPay never holds the money: it goes straight to your own wallet.
  • No dependencies (standard library only). Python 3.8 or newer.
  • README examples for Flask, Django and FastAPI. Plain scripts work too.
  • Every invoice request carries an idempotency key, so a network error can never create two invoices.
  • Signs each invoice request with HMAC-SHA256 and your API secret. The secret itself is never sent.
  • verify_webhook checks the ArionPay-Signature header on the raw body and raises SignatureError when it does not match or is more than 5 minutes old.
  • simulate_payment moves a test invoice through scenarios such as exact, partial_half, overpaid or late. send_test_webhook sends a signed sample event.
  • Ships type hints (py.typed).

Requirements and licence

Works with
Python 3.8 or newer · Flask, Django, FastAPI or plain scripts · standard library only
Cost
The library is free. ArionPay charges 0.5% per payment, with no monthly fee.
Source
Open source (MIT) on GitHub.

Setup

Set it up in 5 steps

  1. Step 1

    Install the package

    Run pip install arionpay. It uses only the standard library.

  2. Step 2

    Copy your keys

    In your ArionPay dashboard, open your store and copy the API key (pk_) and the API secret (sk_, it asks for your authenticator code). The webhook signing secret (whsec_) is on the Webhooks page. Keep them on your server, for example in environment variables.

  3. Step 3

    Create an invoice

    Call create_invoice with the amount, currency and your order_id, then send the customer to invoice["invoiceUrl"].

  4. Step 4

    Check the webhook

    Set your webhook address on the Webhooks page, or per invoice with callback_url. Pass the raw body and the ArionPay-Signature header to verify_webhook, and deliver the order on invoice.paid.

  5. Step 5

    Test without real money

    Create an invoice with test=True and an asset such as USDT_TRC20, then call simulate_payment(invoice["id"], "exact"). Your webhook gets invoice.paid, like a real payment.

After the setup

How a payment reaches your code

  • invoice.pending: a payment was seen on the network and waits for confirmations. Do not deliver yet.
  • invoice.paid: fully paid and confirmed, or accepted by you by hand in the dashboard. Deliver only on this event (or when get_invoice says paid). Coming back to success_url does not prove payment.
  • Before you deliver, match the invoice to your order: your order_id or metadata, and the same amount and currency as the order's current total.
  • invoice.partial, invoice.expired and invoice.needs_review never mean deliver. A late payment can still make an expired invoice paid.
  • ArionPay sends again for about 3 days when your server does not answer 2xx. Handle each event["id"] once.

16 coins and tokens on 9 networks

All coins
  • BTCBitcoin
  • ETHEthereum
  • USDTEthereum
  • USDCEthereum
  • BNBBNB Smart Chain
  • USDTBNB Smart Chain
  • USDCBNB Smart Chain
  • POLPolygon
  • USDTPolygon
  • USDCPolygon
  • TRXTRON
  • USDTTRON
  • LTCLitecoin
  • DOGEDogecoin
  • BCHBitcoin Cash
  • DASHDash

Questions about the ArionPay Python library

Short answers before you add it to your code.

Yes. Mark the view @csrf_exempt and @require_POST, then pass request.body and the ArionPay-Signature header to verify_webhook.

Developer libraries