[+] Finances pre-0.9-alpha

This commit is contained in:
Charles Le Maux 2024-09-25 18:30:36 +02:00
parent 1901711d97
commit b4329614c1

View File

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