Spaces:
Running
Running
No planches, incrementa
Browse files- herramientas.py +4 -24
- main.py +2 -3
herramientas.py
CHANGED
@@ -29,30 +29,10 @@ def registrar_evento(cus: str, tokens: int):
|
|
29 |
|
30 |
Args:
|
31 |
cus (str): customer de stripe.
|
32 |
-
"""
|
33 |
-
# 1. Obtener la fecha y hora actual en el formato deseado
|
34 |
-
#fecha = imprimeTime() # Utiliza tu función existente
|
35 |
-
# 2. Definir el nombre del archivo de registro
|
36 |
-
#file_name = "registro.txt"
|
37 |
-
# 3. Obtener la ruta completa al archivo en la raíz del proyecto
|
38 |
-
# Esto asume que el script que llama a esta función está en la raíz.
|
39 |
-
# script_dir = os.path.dirname(os.path.abspath(__file__))
|
40 |
-
# registro_path = os.path.join(script_dir, file_name)
|
41 |
-
# 4. Formatear la línea que se guardará en el archivo
|
42 |
-
# Puedes elegir el formato que prefieras. Un buen formato sería CSV o algo legible.
|
43 |
-
# Por ejemplo: "FECHA_HORA,TIPO_DE_EVENTO\n"
|
44 |
-
#log_line = f"{fecha},{cus}\n"
|
45 |
-
# 5. Abrir el archivo en modo de añadir ('a') y escribir la línea
|
46 |
-
# try:
|
47 |
-
# with open(registro_path, 'a') as f:
|
48 |
-
# f.write(log_line)
|
49 |
-
# print(f"[{fecha}] Evento '{event_type}' registrado con éxito en '{registro_path}'")
|
50 |
-
# except Exception as e:
|
51 |
-
# print(f"Error al escribir en el archivo de registro '{registro_path}': {e}")
|
52 |
|
53 |
resultado = fireWhale.encontrar_documento_por_cus(cus)
|
54 |
-
|
55 |
-
|
56 |
-
fireWhale.editaDato('usuarios', resultado, 'tokens', tokens)
|
57 |
-
|
58 |
fireWhale.incrementar_campo_numerico('usuarios', resultado, 'tokens', amount=tokens)
|
|
|
29 |
|
30 |
Args:
|
31 |
cus (str): customer de stripe.
|
32 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
resultado = fireWhale.encontrar_documento_por_cus(cus)
|
35 |
+
print("Ésto es el resultado de buscar el cus:")
|
36 |
+
print(resultado)
|
37 |
+
#fireWhale.editaDato('usuarios', resultado, 'tokens', tokens)
|
|
|
38 |
fireWhale.incrementar_campo_numerico('usuarios', resultado, 'tokens', amount=tokens)
|
main.py
CHANGED
@@ -51,7 +51,7 @@ async def webhook_received(request: Request, stripe_signature: str = Header(None
|
|
51 |
|
52 |
if event_type == 'payment_intent.succeeded':
|
53 |
print('PAYMENT182')
|
54 |
-
print(event_data)
|
55 |
print("Ready")
|
56 |
print("Created:")
|
57 |
print(event_data['created'])
|
@@ -62,11 +62,10 @@ async def webhook_received(request: Request, stripe_signature: str = Header(None
|
|
62 |
print("Customer:")
|
63 |
cus = event_data['customer']
|
64 |
print(cus)
|
65 |
-
#herramientas.registrar_evento(cus, 999)
|
66 |
|
67 |
if event_type == 'checkout.session.completed':
|
68 |
print('CHECKOUT182')
|
69 |
-
print(event_data)
|
70 |
print("Ready")
|
71 |
print("Payment Status:")
|
72 |
print(event_data['payment_status'])
|
|
|
51 |
|
52 |
if event_type == 'payment_intent.succeeded':
|
53 |
print('PAYMENT182')
|
54 |
+
#print(event_data)
|
55 |
print("Ready")
|
56 |
print("Created:")
|
57 |
print(event_data['created'])
|
|
|
62 |
print("Customer:")
|
63 |
cus = event_data['customer']
|
64 |
print(cus)
|
|
|
65 |
|
66 |
if event_type == 'checkout.session.completed':
|
67 |
print('CHECKOUT182')
|
68 |
+
#print(event_data)
|
69 |
print("Ready")
|
70 |
print("Payment Status:")
|
71 |
print(event_data['payment_status'])
|