File size: 1,076 Bytes
4afbf70 156893b 4fd9f19 156893b 4fd9f19 156893b 4fd9f19 156893b 4fd9f19 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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
|