#

python

(26 articles)

How to Build a Monero Payment Gateway — Technical Guide

# How to Build a Monero Payment Gateway (Technical Guide) I built a Monero payment gateway with 0.5% fees and open-sourced the approach. Here's how it works. ## Architecture Three components: 1. monero-wallet-rpc — generates subaddresses, monitors payments 2. Flask REST API — serves invoice creation and status endpoints 3. SQLite — stores invoices, zero-config ## Wallet Setup ```bash monero-wallet-rpc \ --wallet-file /data/wallet \ --daemon-host xmr-node.cakewallet.com \ --rpc-bind-port 18083 \ --password "" --disable-rpc-login ``` ## Creating Invoices Each invoice gets a unique subaddress via RPC: POST /api/invoice {amount: 0.05, webhook_url: "..."} → Wallet generates fresh subaddress (create_address RPC) → Store {id, subaddress_index, amount, webhook_url} in SQLite → Return address to customer ## Payment Detection Background thread polls get_transfers every 30 seconds: ```python transfers = wallet_rpc("get_transfers", {"in": True}) for tx in transfers: idx = tx["subaddr_index"]["minor"] invoice = lookup_invoice(idx) if tx["confirmations"] >= needed: mark_paid(invoice, tx["amount"]) fire_webhook(invoice, tx["txid"]) ``` ## Why 0.5%? NowPayments/CoinPayments charge 1%. Running your own wallet-rpc costs nothing except server time. The 0.5% fee covers maintenance and keeps it sustainable. Full source + running instance: https://brief-propecia-accent-constantly.trycloudflare.com/pay Built for the Monero community. Feedback and contributions welcome. #Monero #dev #python #selfhosted #privacy