From 60a22e1b0b9b65eb29fc4cf9eb8969c11cbe6d34 Mon Sep 17 00:00:00 2001 From: hueso Date: Fri, 31 Oct 2025 14:28:35 -0300 Subject: [PATCH] dynamic deploy environments --- .env.example | 16 ++++++++++++++++ bbpay.py | 23 ++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cc6b554 --- /dev/null +++ b/.env.example @@ -0,0 +1,16 @@ +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 diff --git a/bbpay.py b/bbpay.py index 741c49b..94d2f86 100755 --- a/bbpay.py +++ b/bbpay.py @@ -20,35 +20,28 @@ app = Flask(__name__) CORS(app) api = Api(app) -class BBPay(Resource): +class BBPay(Resource): def setup_oauth(self): client = BackendApplicationClient(client_id=getenv("CLIENT_ID")) self.oauth = OAuth2Session(client=client) self.cert = 'key.pem' self.verify_ssl = 'bb.pem' - - # 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.baseUrl = getenv("ITP_API_URL") + self.token_url = getenv("ITP_TOKEN_URL") self.params = { 'numeroConvenio': 701, 'gw-dev-app-key': getenv("DEV_APP_KEY") } - self.scope = ['checkout.solicitacoes-requisicao', - 'checkout.participantes-requisicao', - 'checkout.solicitacoes-info', + self.scope = ['checkout.solicitacoes-requisicao', + 'checkout.participantes-requisicao', + 'checkout.solicitacoes-info', 'checkout.participantes-info'] self.oauth.fetch_token( - token_url='https://oauth.hm.bb.com.br/oauth/token', + token_url=self.token_url, client_id=getenv("CLIENT_ID"), client_secret=getenv("CLIENT_SECRET"), scope=self.scope) @@ -59,7 +52,7 @@ class BBPay(Resource): class Register(BBPay): def post(self): data = request.get_json() - body = { + body = { 'numeroConvenio': 701, 'nomeParticipante': data['chainID'], 'tipoDocumento': data['tipoDocumento'],