Compare commits
7 Commits
95c65836c5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2ee0fe37f | ||
|
|
b16b9d4fb2 | ||
|
|
925002c572 | ||
|
|
e05f46a987 | ||
|
|
be5a097739 | ||
|
|
44cadbff92 | ||
|
|
4c3616ffbc |
29
bbpay.py
29
bbpay.py
@@ -15,6 +15,9 @@ from eth_utils import to_wei
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
ENVIRONMENT = getenv('ENVIRONMENT', 'dev')
|
||||
dotenv_path = f'.env.{ENVIRONMENT}'
|
||||
load_dotenv(dotenv_path)
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app, origins=['https://p2pix.co'])
|
||||
@@ -31,7 +34,7 @@ class BBPay(Resource):
|
||||
self.token_url = getenv("ITP_TOKEN_URL")
|
||||
|
||||
self.params = {
|
||||
'numeroConvenio': 701,
|
||||
'numeroConvenio': getenv("BBPAY_CONVENIO"),
|
||||
'gw-dev-app-key': getenv("DEV_APP_KEY")
|
||||
}
|
||||
|
||||
@@ -52,8 +55,9 @@ class BBPay(Resource):
|
||||
class Register(BBPay):
|
||||
def post(self):
|
||||
data = request.get_json()
|
||||
app.logger.debug(data)
|
||||
body = {
|
||||
'numeroConvenio': 701,
|
||||
'numeroConvenio': getenv("BBPAY_CONVENIO"),
|
||||
'nomeParticipante': data['chainID'],
|
||||
'tipoDocumento': data['tipoDocumento'],
|
||||
'numeroDocumento': data['numeroDocumento'],
|
||||
@@ -62,6 +66,7 @@ class Register(BBPay):
|
||||
'tipoConta': data['tipoConta'],
|
||||
'codigoIspb': data['codigoIspb'] # Código identificador do Sistema de Pagamentos Brasileiro. Atualmente aceitamos apenas Banco do Brasil, codigoIspb igual a 0
|
||||
}
|
||||
app.logger.debug(body)
|
||||
response = self.oauth.post(
|
||||
self.baseUrl+"/participantes",
|
||||
params=self.params,
|
||||
@@ -69,19 +74,21 @@ class Register(BBPay):
|
||||
verify=self.verify_ssl,
|
||||
cert=self.cert)
|
||||
if response.status_code != 201:
|
||||
return 'Upstream error', response.status_code
|
||||
app.logger.debug(response._content)
|
||||
return response.reason, response.status_code
|
||||
return response.json()
|
||||
|
||||
class Request(BBPay):
|
||||
def post(self):
|
||||
data = request.get_json()
|
||||
app.logger.debug(data)
|
||||
body = {
|
||||
"geral": {
|
||||
"numeroConvenio": 701,
|
||||
"numeroConvenio": getenv("BBPAY_CONVENIO"),
|
||||
"pagamentoUnico": True,
|
||||
"descricaoSolicitacao": "P2Pix",
|
||||
"valorSolicitacao": data['amount'],
|
||||
"codigoConciliacaoSolicitacao": data['lockid']
|
||||
#"codigoConciliacaoSolicitacao": data['lockid']
|
||||
},
|
||||
# "devedor": {
|
||||
# "tipoDocumento": 1,
|
||||
@@ -96,25 +103,29 @@ class Request(BBPay):
|
||||
"valorRepasse": 100 }]
|
||||
}
|
||||
}
|
||||
app.logger.debug(body)
|
||||
response = self.oauth.post(
|
||||
self.baseUrl+"/solicitacoes",
|
||||
params=self.params,
|
||||
json=body,
|
||||
verify=self.verify_ssl,
|
||||
cert=self.cert)
|
||||
app.logger.debug(response._content)
|
||||
if response.status_code != 201:
|
||||
return 'Upstream error', response.status_code
|
||||
return response.reason, response.status_code
|
||||
return response.json()
|
||||
|
||||
class Release(BBPay):
|
||||
def get(self, numeroSolicitacao):
|
||||
app.logger.debug(request.get_json())
|
||||
response = self.oauth.get(
|
||||
self.baseUrl+f"/solicitacoes/{numeroSolicitacao}",
|
||||
params=self.params,
|
||||
verify=self.verify_ssl,
|
||||
cert=self.cert)
|
||||
app.logger.debug(response._content)
|
||||
if response.status_code != 200:
|
||||
return 'Upstream error', response.status_code
|
||||
return response.reason, response.status_code
|
||||
data = response.json()
|
||||
numeroParticipante = data['repasse']['recebedores'][0]['identificadorRecebedor']
|
||||
pixTimestamp = encode_packed(['bytes32'],[b85decode(data['informacoesPix']['txId'])])
|
||||
@@ -156,7 +167,7 @@ api.add_resource(Release, '/release/<int:numeroSolicitacao>')
|
||||
if __name__ == '__main__':
|
||||
if getenv("DEBUG"):
|
||||
disable_warnings()
|
||||
app.run(host='::',debug=True)
|
||||
app.run(host='::1', debug=True, port=getenv("PORT",5000))
|
||||
else:
|
||||
from waitress import serve
|
||||
serve(app, host=getenv("HOST","::"), port=getenv("PORT",5000))
|
||||
serve(app, host=getenv("HOST","::1"), port=getenv("PORT",5000))
|
||||
|
||||
Reference in New Issue
Block a user