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']}")