def start_payment(transaction_id, amount): client = BTCPayClient( host=settings.ZENAIDA_BTCPAY_HOST, pem=settings.ZENAIDA_BTCPAY_CLIENT_PRIVATE_KEY, tokens={"merchant": settings.ZENAIDA_BTCPAY_MERCHANT}) btcpay_invoice = client.create_invoice({"price": 1, "currency": "USD"}) BTCPayInvoice.invoices.create(transaction_id=transaction_id, invoice_id=btcpay_invoice.get('id'), status=btcpay_invoice.get('status'), amount=amount) return HttpResponseRedirect(btcpay_invoice.get("url"))
from btcpay import BTCPayClient from os import environ pem = open('btcpayserver.pem', 'r') privkey = pem.read() host_store = "http://raspberrypi.local" tok = open('merchant_token', 'r') token = tok.read() client = BTCPayClient( host = host_store, pem = privkey, tokens = {'merchant': token} ) new_invoice = client.create_invoice({"price": 20, "currency": "USD"}) print(new_invoice)
def fetch_token(facade, pairingCode): if os.path.isfile(TOKEN_FILE + facade): f = open(TOKEN_FILE + facade, 'r') token = f.read() f.close() client.tokens[facade] = token else: token = client.pair_client(pairingCode) client.tokens[facade] = token f = open(TOKEN_FILE + facade, 'w') print(token[facade]) f.write(token[facade]) f.close() pairingCode = "otMSapf" facade = "merchant" fetch_token(facade, pairingCode) print(client.tokens[facade]) client = BTCPayClient(host=API_HOST, pem=key, tokens=client.tokens) print(client) #fetch_token(facade, pairingCode) #print("Token: ", client.tokens[facade]) new_invoice = client.create_invoice({"price": 20, "currency": "EUR", "token": client.tokens[facade],"extendedNotifications": True}) print("NEW INVOICE: ", new_invoice) fetched_invoice = client.get_invoice(new_invoice['id']) print("FETCHED INVOICE: ", new_invoice['id']) curl --no-keepalive --raw --show-error --verbose --connect-timeout 10 --insecure --max-redirs 1 -H "Content-Type: application/json" -d '{"data": "{"id":"P38S4ewSvvLoRrBSoEiMTz"}"}" http://odoo-dev.zynthian.org/payment/btcpay/ipn