# stripe_checkout.py | |
import stripe | |
import os | |
stripe.api_key = os.getenv("STRIPE_API_KEY") | |
def create_stripe_session(): | |
""" | |
Creates a Stripe Checkout Session using dynamic price_data. | |
No pre‑configured Price object required. | |
""" | |
session = stripe.checkout.Session.create( | |
payment_method_types=["card"], | |
line_items=[{ | |
# Dynamically define the price here: | |
"price_data": { | |
"currency": "usd", | |
"product_data": { | |
"name": "AutoExec AI Pro Subscription", | |
"description": "Unlimited AI business launches & analytics" | |
}, | |
"unit_amount": 4900, # $49.00 in cents | |
"recurring": { | |
"interval": "month" | |
} | |
}, | |
"quantity": 1 | |
}], | |
mode="subscription", | |
success_url=os.getenv("SUCCESS_URL", "https://your-domain.com/success"), | |
cancel_url=os.getenv("CANCEL_URL", "https://your-domain.com/cancel"), | |
) | |
return session.url | |