Initial Addons
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import btcpay_test
|
||||
@@ -0,0 +1,244 @@
|
||||
NEW ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
': {u'BTC': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz'},
|
||||
u'amountPaid': 0,
|
||||
u'bitcoinAddress': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'btcDue': u'0.00016569',
|
||||
u'btcPaid': u'0.00000000',
|
||||
u'btcPrice': u'0.00016569',
|
||||
u'buyer': {u'address1': u'Carretera Rubi\xf3',
|
||||
u'address2': None,
|
||||
u'country': None,
|
||||
u'email': u'cristina@solis.com',
|
||||
u'locality': None,
|
||||
u'name': u'Maria Cristina Sol\xeds',
|
||||
u'phone': None,
|
||||
u'postalCode': None,
|
||||
u'region': None},
|
||||
u'buyerPaidBtcMinerFee': None,
|
||||
u'buyerTotalBtcAmount': None,
|
||||
u'cryptoInfo': [{u'address': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'cryptoCode': u'BTC',
|
||||
u'cryptoPaid': u'0.00000000',
|
||||
u'due': u'0.00016569',
|
||||
u'exRates': {u'EUR': 0.0},
|
||||
u'networkFee': u'0.00000000',
|
||||
u'paid': u'0.00000000',
|
||||
u'paymentType': u'BTCLike',
|
||||
u'paymentUrls': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00016569',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None},
|
||||
u'payments': [],
|
||||
u'price': u'0.00016569',
|
||||
u'rate': 6035.635,
|
||||
u'totalDue': u'0.00016569',
|
||||
u'txCount': 0,
|
||||
u'url': u'https://testnet.demo.btcpayserver.org/i/BTC/8Ne9cafEfuJTX5qBMMVFVa'}],
|
||||
u'currency': u'EUR',
|
||||
u'currentTime': 1585230897038,
|
||||
u'exRates': {u'EUR': 0.0},
|
||||
u'exceptionStatus': False,
|
||||
u'exchangeRates': {u'BTC': {u'EUR': 0.0}},
|
||||
u'expirationTime': 1585231795000,
|
||||
u'flags': {u'refundable': False},
|
||||
u'guid': u'e1913afa-136c-415c-bf5d-bcd9bb817b0d',
|
||||
u'id': u'8Ne9cafEfuJTX5qBMMVFVa',
|
||||
u'invoiceTime': 1585230895000,
|
||||
u'itemCode': None,
|
||||
u'itemDesc': None,
|
||||
u'lowFeeDetected': False,
|
||||
u'minerFees': {u'BTC': {u'satoshisPerByte': 1.0, u'totalFee': 0.0}},
|
||||
u'orderId': u'SO3166',
|
||||
u'paymentCodes': {u'BTC': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00016569',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None}},
|
||||
u'paymentSubtotals': {u'BTC': 16569.0},
|
||||
u'paymentTotals': {u'BTC': 16569.0},
|
||||
u'paymentUrls': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00016569',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None},
|
||||
u'posData': None,
|
||||
u'price': 1.0,
|
||||
u'rate': 6035.635,
|
||||
u'refundAddressRequestPending': False,
|
||||
u'status': u'new',
|
||||
u'supportedTransactionCurrencies': {u'BTC': {u'enabled': True,
|
||||
u'reason': None}},
|
||||
u'token': u'Xf3ji4rhcZc7QoKNyzorFq',
|
||||
u'url': u'https://testnet.demo.btcpayserver.org/invoice?id=8Ne9cafEfuJTX5qBMMVFVa'}
|
||||
|
||||
|
||||
|
||||
|
||||
PAID +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
{u'addresses': {u'BTC': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz'},
|
||||
u'amountPaid': 0,
|
||||
u'bitcoinAddress': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'btcDue': u'0.00000000',
|
||||
u'btcPaid': u'0.00016569',
|
||||
u'btcPrice': u'0.00016569',
|
||||
u'buyer': {u'address1': u'Carretera Rubi\xf3',
|
||||
u'address2': None,
|
||||
u'country': None,
|
||||
u'email': u'cristina@solis.com',
|
||||
u'locality': None,
|
||||
u'name': u'Maria Cristina Sol\xeds',
|
||||
u'phone': None,
|
||||
u'postalCode': None,
|
||||
u'region': None},
|
||||
u'buyerPaidBtcMinerFee': None,
|
||||
u'buyerTotalBtcAmount': None,
|
||||
u'cryptoInfo': [{u'address': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'cryptoCode': u'BTC',
|
||||
u'cryptoPaid': u'0.00016569',
|
||||
u'due': u'0.00000000',
|
||||
u'exRates': {u'EUR': 0.0},
|
||||
u'networkFee': u'0.00000000',
|
||||
u'paid': u'0.00016569',
|
||||
u'paymentType': u'BTCLike',
|
||||
u'paymentUrls': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None},
|
||||
u'payments': [{u'completed': False,
|
||||
u'confirmed': False,
|
||||
u'destination': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'fee': 0.0,
|
||||
u'id': u'8e334ae16f57eca9ca6a1c2fe8de0aa3fe85a07f3fe64aab2a08657b7e185239-1',
|
||||
u'paymentType': u'BTCLike',
|
||||
u'receivedDate': u'2020-03-26T13:56:39',
|
||||
u'value': 0.00016569}],
|
||||
u'price': u'0.00016569',
|
||||
u'rate': 6035.635,
|
||||
u'totalDue': u'0.00016569',
|
||||
u'txCount': 1,
|
||||
u'url': u'https://testnet.demo.btcpayserver.org/i/BTC/8Ne9cafEfuJTX5qBMMVFVa'}],
|
||||
u'currency': u'EUR',
|
||||
u'currentTime': 1585231001490,
|
||||
u'exRates': {u'EUR': 0.0},
|
||||
u'exceptionStatus': False,
|
||||
u'exchangeRates': {u'BTC': {u'EUR': 0.0}},
|
||||
u'expirationTime': 1585231795000,
|
||||
u'flags': {u'refundable': False},
|
||||
u'guid': u'0247206a-d05b-4f00-b679-d7261aca0714',
|
||||
u'id': u'8Ne9cafEfuJTX5qBMMVFVa',
|
||||
u'invoiceTime': 1585230895000,
|
||||
u'itemCode': None,
|
||||
u'itemDesc': None,
|
||||
u'lowFeeDetected': False,
|
||||
u'minerFees': {u'BTC': {u'satoshisPerByte': 1.0, u'totalFee': 0.0}},
|
||||
u'orderId': u'SO3166',
|
||||
u'paymentCodes': {u'BTC': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None}},
|
||||
u'paymentSubtotals': {u'BTC': 16569.0},
|
||||
u'paymentTotals': {u'BTC': 16569.0},
|
||||
u'paymentUrls': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None},
|
||||
u'posData': None,
|
||||
u'price': 1.0,
|
||||
u'rate': 6035.635,
|
||||
u'refundAddressRequestPending': False,
|
||||
u'status': u'paid',
|
||||
u'supportedTransactionCurrencies': {u'BTC': {u'enabled': True,
|
||||
u'reason': None}},
|
||||
u'token': u'SV24W1puvz1ZqaHj9nb6vx',
|
||||
u'url': u'https://testnet.demo.btcpayserver.org/invoice?id=8Ne9cafEfuJTX5qBMMVFVa'}
|
||||
|
||||
|
||||
|
||||
CONFIRMED ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
{u'addresses': {u'BTC': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz'},
|
||||
u'amountPaid': 0,
|
||||
u'bitcoinAddress': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'btcDue': u'0.00000000',
|
||||
u'btcPaid': u'0.00016569',
|
||||
u'btcPrice': u'0.00016569',
|
||||
u'buyer': {u'address1': u'Carretera Rubi\xf3',
|
||||
u'address2': None,
|
||||
u'country': None,
|
||||
u'email': u'cristina@solis.com',
|
||||
u'locality': None,
|
||||
u'name': u'Maria Cristina Sol\xeds',
|
||||
u'phone': None,
|
||||
u'postalCode': None,
|
||||
u'region': None},
|
||||
u'buyerPaidBtcMinerFee': None,
|
||||
u'buyerTotalBtcAmount': None,
|
||||
u'cryptoInfo': [{u'address': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'cryptoCode': u'BTC',
|
||||
u'cryptoPaid': u'0.00016569',
|
||||
u'due': u'0.00000000',
|
||||
u'exRates': {u'EUR': 0.0},
|
||||
u'networkFee': u'0.00000000',
|
||||
u'paid': u'0.00016569',
|
||||
u'paymentType': u'BTCLike',
|
||||
u'paymentUrls': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None},
|
||||
u'payments': [{u'completed': False,
|
||||
u'confirmed': True,
|
||||
u'destination': u'tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz',
|
||||
u'fee': 0.0,
|
||||
u'id': u'8e334ae16f57eca9ca6a1c2fe8de0aa3fe85a07f3fe64aab2a08657b7e185239-1',
|
||||
u'paymentType': u'BTCLike',
|
||||
u'receivedDate': u'2020-03-26T13:56:39',
|
||||
u'value': 0.00016569}],
|
||||
u'price': u'0.00016569',
|
||||
u'rate': 6035.635,
|
||||
u'totalDue': u'0.00016569',
|
||||
u'txCount': 1,
|
||||
u'url': u'https://testnet.demo.btcpayserver.org/i/BTC/8Ne9cafEfuJTX5qBMMVFVa'}],
|
||||
u'currency': u'EUR',
|
||||
u'currentTime': 1585231286866,
|
||||
u'exRates': {u'EUR': 0.0},
|
||||
u'exceptionStatus': False,
|
||||
u'exchangeRates': {u'BTC': {u'EUR': 0.0}},
|
||||
u'expirationTime': 1585231795000,
|
||||
u'flags': {u'refundable': False},
|
||||
u'guid': u'3e236c9a-290b-45ee-ad2f-529c2b9ef392',
|
||||
u'id': u'8Ne9cafEfuJTX5qBMMVFVa',
|
||||
u'invoiceTime': 1585230895000,
|
||||
u'itemCode': None,
|
||||
u'itemDesc': None,
|
||||
u'lowFeeDetected': False,
|
||||
u'minerFees': {u'BTC': {u'satoshisPerByte': 1.0, u'totalFee': 0.0}},
|
||||
u'orderId': u'SO3166',
|
||||
u'paymentCodes': {u'BTC': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None}},
|
||||
u'paymentSubtotals': {u'BTC': 16569.0},
|
||||
u'paymentTotals': {u'BTC': 16569.0},
|
||||
u'paymentUrls': {u'BIP21': u'bitcoin:tb1q6xglf49usp7hvz57hcn5s3ela0z7784xzxc6zz?amount=0.00',
|
||||
u'BIP72': None,
|
||||
u'BIP72b': None,
|
||||
u'BIP73': None,
|
||||
u'BOLT11': None},
|
||||
u'posData': None,
|
||||
u'price': 1.0,
|
||||
u'rate': 6035.635,
|
||||
u'refundAddressRequestPending': False,
|
||||
u'status': u'confirmed',
|
||||
u'supportedTransactionCurrencies': {u'BTC': {u'enabled': True,
|
||||
u'reason': None}},
|
||||
u'token': u'S8QfFkkTLY6GmrrauWMmHL',
|
||||
u'url': u'https://testnet.demo.btcpayserver.org/invoice?id=8Ne9cafEfuJTX5qBMMVFVa'}
|
||||
@@ -0,0 +1,61 @@
|
||||
import pprint
|
||||
import logging
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
import os.path
|
||||
#import bitpay_key_utils as bku
|
||||
#from bitpay_client import *
|
||||
|
||||
import btcpay.crypto
|
||||
from btcpay import BTCPayClient
|
||||
|
||||
API_HOST = "https://testnet.demo.btcpayserver.org" #Testnet BTCPAY
|
||||
KEY_FILE = "/tmp/key.priv"
|
||||
TOKEN_FILE = "/tmp/btctoken.priv"
|
||||
|
||||
if os.path.isfile(KEY_FILE):
|
||||
f = open(KEY_FILE, 'r')
|
||||
key = f.read()
|
||||
f.close()
|
||||
print("Creating a bitpay client using existing private key from disk.")
|
||||
else:
|
||||
key = btcpay.crypto.generate_privkey()
|
||||
f = open(KEY_FILE, 'w')
|
||||
f.write(key)
|
||||
f.close()
|
||||
|
||||
client = BTCPayClient(host=API_HOST, pem=key)
|
||||
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user