Compare commits
3 Commits
94cee1fa5e
...
6092541f5d
Author | SHA1 | Date | |
---|---|---|---|
|
6092541f5d | ||
|
b47f7906c4 | ||
|
f6042cfe03 |
10
bbpay.py
10
bbpay.py
@ -8,7 +8,9 @@ from flask_restful import Resource, Api
|
|||||||
from eth_abi.packed import encode_packed
|
from eth_abi.packed import encode_packed
|
||||||
import eth_account
|
import eth_account
|
||||||
from eth_hash.auto import keccak
|
from eth_hash.auto import keccak
|
||||||
|
from base64 import b85decode
|
||||||
from urllib3 import disable_warnings
|
from urllib3 import disable_warnings
|
||||||
|
from eth_utils import to_wei
|
||||||
|
|
||||||
# Load environment variables from .env file
|
# Load environment variables from .env file
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
@ -109,20 +111,20 @@ class Release(BBPay):
|
|||||||
verify=self.verify_ssl)
|
verify=self.verify_ssl)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
numeroParticipante = data['repasse']['recebedores'][0]['identificadorRecebedor']
|
numeroParticipante = data['repasse']['recebedores'][0]['identificadorRecebedor']
|
||||||
valorSolicitacao = data['valorSolicitacao']
|
pixTimestamp = b85decode(data['informacoesPix']['txId'])
|
||||||
pixTimestamp = data['timestampCriacaoSolicitacao']
|
valorSolicitacao = to_wei(data['valorSolicitacao'], 'ether')
|
||||||
codigoEstadoSolicitacao = data['codigoEstadoSolicitacao']
|
codigoEstadoSolicitacao = data['codigoEstadoSolicitacao']
|
||||||
if codigoEstadoSolicitacao != 0:
|
if codigoEstadoSolicitacao != 0:
|
||||||
return 'Pix not paid', 204
|
return 'Pix not paid', 204
|
||||||
packed = encode_packed(['bytes32','uint80','bytes32'],
|
packed = encode_packed(['bytes32','uint80','bytes32'],
|
||||||
(str(numeroParticipante).encode(), int(valorSolicitacao), pixTimestamp.encode()) )
|
(str(numeroParticipante).encode(), int(valorSolicitacao), pixTimestamp) )
|
||||||
|
|
||||||
signable = eth_account.messages.encode_defunct(keccak(packed))
|
signable = eth_account.messages.encode_defunct(keccak(packed))
|
||||||
signature = eth_account.account.Account.sign_message(signable, private_key=getenv('PRIVATE_KEY')).signature.hex()
|
signature = eth_account.account.Account.sign_message(signable, private_key=getenv('PRIVATE_KEY')).signature.hex()
|
||||||
return {
|
return {
|
||||||
'pixTarget': numeroParticipante,
|
'pixTarget': numeroParticipante,
|
||||||
'amount': valorSolicitacao,
|
'amount': valorSolicitacao,
|
||||||
'pixTimestamp': pixTimestamp,
|
'pixTimestamp': pixTimestamp.hex(),
|
||||||
'signature': signature }
|
'signature': signature }
|
||||||
|
|
||||||
|
|
||||||
|
12
requirements.txt
Normal file
12
requirements.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
python-dotenv
|
||||||
|
oauthlib
|
||||||
|
requests-oauthlib
|
||||||
|
flask
|
||||||
|
flask-restful
|
||||||
|
eth-abi
|
||||||
|
eth-account
|
||||||
|
eth-hash[pycryptodome]
|
||||||
|
eth-utils
|
||||||
|
base64
|
||||||
|
urllib3
|
||||||
|
waitress
|
Loading…
x
Reference in New Issue
Block a user