Compare commits
1 Commits
main
...
4da1d1233c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4da1d1233c |
16
.env.example
16
.env.example
@@ -1,16 +0,0 @@
|
||||
PRIVATE_KEY=0x....
|
||||
CLIENT_ID=
|
||||
CLIENT_SECRET=
|
||||
DEV_APP_KEY=
|
||||
DEBUG=false
|
||||
ITP_TOKEN_URL = https://oauth.hm.bb.com.br/oauth/token
|
||||
# Url de produção com autenticação mTLS.
|
||||
#ITP_API_URL="https://api-bbpay.bb.com.br/checkout/v2"
|
||||
# Url de homologação com autenticação mTLS.
|
||||
ITP_API_URL = "https://api-bbpay.hm.bb.com.br/checkout/v2"
|
||||
# Url de homologação sem autenticação mTLS.
|
||||
#ITP_API_URL = "https://api.extranet.hm.bb.com.br/checkout/v2"
|
||||
|
||||
# 05/08/2025
|
||||
#ITP_API_URL=https://checkout.mtls.api.bb.com.br
|
||||
#ITP_API_URL=https://checkout.mtls.api.hm.bb.com.br
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
.env
|
||||
*.pem
|
||||
venv
|
||||
29
bbpay.py
29
bbpay.py
@@ -27,8 +27,15 @@ class BBPay(Resource):
|
||||
|
||||
self.cert = 'key.pem'
|
||||
self.verify_ssl = 'bb.pem'
|
||||
self.baseUrl = getenv("ITP_API_URL")
|
||||
self.token_url = getenv("ITP_TOKEN_URL")
|
||||
|
||||
# Url de homologação com autenticação mTLS.
|
||||
self.baseUrl = "https://api-bbpay.hm.bb.com.br/checkout/v2"
|
||||
|
||||
# Url de homologação sem autenticação mTLS.
|
||||
#self.baseUrl = "https://api.extranet.hm.bb.com.br/checkout/v2"
|
||||
|
||||
# Url de produção com autenticação mTLS.
|
||||
#self.baseUrl = "https://api-bbpay.bb.com.br/checkout/v2"
|
||||
|
||||
self.params = {
|
||||
'numeroConvenio': 701,
|
||||
@@ -41,7 +48,7 @@ class BBPay(Resource):
|
||||
'checkout.participantes-info']
|
||||
|
||||
self.oauth.fetch_token(
|
||||
token_url=self.token_url,
|
||||
token_url='https://oauth.hm.bb.com.br/oauth/token',
|
||||
client_id=getenv("CLIENT_ID"),
|
||||
client_secret=getenv("CLIENT_SECRET"), scope=self.scope)
|
||||
|
||||
@@ -68,8 +75,6 @@ class Register(BBPay):
|
||||
json=body,
|
||||
verify=self.verify_ssl,
|
||||
cert=self.cert)
|
||||
if response.status_code != 201:
|
||||
return 'Upstream error', response.status_code
|
||||
return response.json()
|
||||
|
||||
class Request(BBPay):
|
||||
@@ -80,8 +85,7 @@ class Request(BBPay):
|
||||
"numeroConvenio": 701,
|
||||
"pagamentoUnico": True,
|
||||
"descricaoSolicitacao": "P2Pix",
|
||||
"valorSolicitacao": data['amount'],
|
||||
"codigoConciliacaoSolicitacao": data['lockid']
|
||||
"valorSolicitacao": data['amount']
|
||||
},
|
||||
# "devedor": {
|
||||
# "tipoDocumento": 1,
|
||||
@@ -102,8 +106,6 @@ class Request(BBPay):
|
||||
json=body,
|
||||
verify=self.verify_ssl,
|
||||
cert=self.cert)
|
||||
if response.status_code != 201:
|
||||
return 'Upstream error', response.status_code
|
||||
return response.json()
|
||||
|
||||
class Release(BBPay):
|
||||
@@ -137,9 +139,9 @@ class Release(BBPay):
|
||||
return {
|
||||
'pixTarget': f"{chainID}-{numeroParticipante}",
|
||||
'amount': str(valorSolicitacao),
|
||||
'pixTimestamp': f"0x{pixTimestamp.hex()}",
|
||||
'signature': f"0x{signature}"
|
||||
}
|
||||
'pixTimestamp': pixTimestamp.hex(),
|
||||
'signature': signature }
|
||||
|
||||
|
||||
# (CPF, nome, conta) -> participantID
|
||||
# should be called before deposit
|
||||
@@ -153,6 +155,7 @@ api.add_resource(Request, '/request')
|
||||
# should be called before release
|
||||
api.add_resource(Release, '/release/<int:numeroSolicitacao>')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if getenv("DEBUG"):
|
||||
disable_warnings()
|
||||
@@ -160,3 +163,5 @@ if __name__ == '__main__':
|
||||
else:
|
||||
from waitress import serve
|
||||
serve(app, host=getenv("HOST","0.0.0.0"), port=getenv("PORT",5000))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user