btcpay

Accept bitcoin with BTCPay


Keywords
bitcoin, payments, crypto
License
MIT
Install
pip install btcpay==1.0.3

Documentation

btcpay-python

Install

pip3 install btcpay

Pairing

  • Generate and save private key:
import btcpay.crypto
privkey = btcpay.crypto.generate_privkey()
  • Create client:
from btcpay import BTCPayClient
client = BTCPayClient(host='http://hostname', pem=privkey)
  • On BTCPay server > shop > access tokens > create new token, copy pairing code:
  • Pair client to server and save returned token:
client.pair_client(<pairing-code>)
>>> {'merchant': "xdr9vw3v5wc0w90859v45"}
  • Recreate client:
client = BTCPayClient(
    host='http://hostname',
    pem=privkey,
    tokens={'merchant': "xdr9vw3v5wc0w90859v45"}
)

Creating a client

client = BTCPayClient(
    host='http://hostname',
    pem=privkey,
    tokens={'merchant': "xdr9vw3v5wc0w90859v45"}
)

Get rates

client.get_rates()

Create specific rate

client.get_rate('USD')

Create invoice

See bitpay api documentation: https://bitpay.com/api#resource-Invoices

client.create_invoice({"price": 20, "currency": "USD"})

Get invoice

client.get_invoice(<invoice-id>)