From b4329614c13c6cc4bbcc0e32d5192658154c7e98 Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Wed, 25 Sep 2024 18:30:36 +0200 Subject: [PATCH] [+] Finances pre-0.9-alpha --- finances.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/finances.py b/finances.py index 6ab7d5f..d214994 100644 --- a/finances.py +++ b/finances.py @@ -1,6 +1,5 @@ -from flask import Flask, request, jsonify import stripe -import os +from flask import Flask, request, jsonify app = Flask(__name__) @@ -25,31 +24,18 @@ def webhook(): return jsonify({'error': 'Invalid signature'}), 400 - print(event) # Handle the event based on its type match event['type']: - case 'payment_intent.created': - payment_intent = event['data']['object'] - print(f"PaymentIntent created: {payment_intent['id']}") - case 'customer.created': - customer = event['data']['object'] - print(f"Customer created: {customer['id']}") - case 'payment_intent.succeeded': - payment_intent = event['data']['object'] - print(f"PaymentIntent succeeded: {payment_intent['id']}") - case 'charge.succeeded': - charge = event['data']['object'] - print(f"Charge succeeded: {charge['id']}") - case 'checkout.session.completed': - session = event['data']['object'] - print(f"Checkout session completed: {session['id']}") - case 'charge.failed': - charge = event['data']['object'] - print(f"Charge failed: {charge['id']}") case 'customer.subscription.deleted': customer = event['data']['object'] + print(event) print(f"Customer stopped subscription: {customer['id']}") case 'customer.subscription.created': + print(event) + customer = event['data']['object'] + print(f"Customer started subscription: {customer['id']}") + case 'customer.subscription.updated': + print(event) customer = event['data']['object'] print(f"Customer started subscription: {customer['id']}")