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
|
||||
import eth_account
|
||||
from eth_hash.auto import keccak
|
||||
from base64 import b85decode
|
||||
from urllib3 import disable_warnings
|
||||
from eth_utils import to_wei
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
@ -109,20 +111,20 @@ class Release(BBPay):
|
||||
verify=self.verify_ssl)
|
||||
data = response.json()
|
||||
numeroParticipante = data['repasse']['recebedores'][0]['identificadorRecebedor']
|
||||
valorSolicitacao = data['valorSolicitacao']
|
||||
pixTimestamp = data['timestampCriacaoSolicitacao']
|
||||
pixTimestamp = b85decode(data['informacoesPix']['txId'])
|
||||
valorSolicitacao = to_wei(data['valorSolicitacao'], 'ether')
|
||||
codigoEstadoSolicitacao = data['codigoEstadoSolicitacao']
|
||||
if codigoEstadoSolicitacao != 0:
|
||||
return 'Pix not paid', 204
|
||||
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))
|
||||
signature = eth_account.account.Account.sign_message(signable, private_key=getenv('PRIVATE_KEY')).signature.hex()
|
||||
return {
|
||||
'pixTarget': numeroParticipante,
|
||||
'amount': valorSolicitacao,
|
||||
'pixTimestamp': pixTimestamp,
|
||||
'pixTimestamp': pixTimestamp.hex(),
|
||||
'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