Moibe commited on
Commit
7f9c0e7
1 Parent(s): 001330e

HF define por si solo si es sandbox o prod

Browse files
Files changed (3) hide show
  1. autenticacion.py +1 -1
  2. globales.py +2 -1
  3. paga_oxxo.py +32 -0
autenticacion.py CHANGED
@@ -12,7 +12,7 @@ def defineAmbiente(env):
12
 
13
  else:
14
  print("Entorno remoto listo...")
15
- if env == 'prod':
16
  llave = os.getenv("llave_prod")
17
  else:
18
  llave = os.getenv("llave_sandbox")
 
12
 
13
  else:
14
  print("Entorno remoto listo...")
15
+ if os.getenv("ambiente_stripe") == 'prod':
16
  llave = os.getenv("llave_prod")
17
  else:
18
  llave = os.getenv("llave_sandbox")
globales.py CHANGED
@@ -1,4 +1,5 @@
1
  import autenticacion
2
 
3
- env = "dev" #o dev (Define si es sandbox o producci贸n en Stripe.)
 
4
  llave = autenticacion.defineAmbiente(env)
 
1
  import autenticacion
2
 
3
+ env = "dev" #o dev (Define si es sandbox o producci贸n en Stripe.)
4
+ #Importante: Solo sirve en local, si est谩s en el server de HF, ah铆 tiene su propia variable.
5
  llave = autenticacion.defineAmbiente(env)
paga_oxxo.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import stripe
2
+ import globales
3
+
4
+ #stripe.api_key = globales.llave
5
+
6
+ # Despu茅s de crear un Checkout Session
7
+ #session = stripe.checkout.Session.create(**session_params)
8
+
9
+ # Si necesitas recuperar el PaymentIntent asociado a la sesi贸n
10
+ payment_intent = stripe.PaymentIntent.retrieve('pi_3RtecaROVpWRmEfB08gAe9CP')
11
+ print("payment_intent obtenido...")
12
+
13
+ # Comprobar si hay alguna acci贸n necesaria
14
+ if hasattr(payment_intent, 'next_action') and payment_intent.next_action:
15
+ # Aqu铆 hay una acci贸n pendiente que requiere atenci贸n
16
+ action_type = payment_intent.next_action.type
17
+
18
+ if action_type == 'oxxo_display_details':
19
+ # Para pagos OXXO, obt茅n los detalles del voucher
20
+ voucher_url = payment_intent.next_action.oxxo_display_details.hosted_voucher_url
21
+ voucher_number = payment_intent.next_action.oxxo_display_details.number
22
+ # Guardar o mostrar esta informaci贸n al cliente
23
+ print(f"OXXO Voucher URL: {voucher_url}")
24
+ print(f"OXXO Number: {voucher_number}")
25
+
26
+ elif action_type == 'redirect_to_url':
27
+ # Para 3D Secure u otros m茅todos que requieren redirecci贸n
28
+ redirect_url = payment_intent.next_action.redirect_to_url.url
29
+ # Redirigir al cliente a esta URL
30
+ print(f"Redirect URL: {redirect_url}")
31
+
32
+ # Otros tipos de acciones...