Create stripe_checkout.py
Browse files- stripe_checkout.py +21 -0
stripe_checkout.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import stripe
|
2 |
+
import os
|
3 |
+
|
4 |
+
stripe.api_key = os.getenv("STRIPE_API_KEY")
|
5 |
+
|
6 |
+
def create_stripe_session():
|
7 |
+
session = stripe.checkout.Session.create(
|
8 |
+
payment_method_types=["card"],
|
9 |
+
line_items=[{
|
10 |
+
"price_data": {
|
11 |
+
"currency": "usd",
|
12 |
+
"product_data": {"name": "AutoExec AI Pro Subscription"},
|
13 |
+
"unit_amount": 4900,
|
14 |
+
},
|
15 |
+
"quantity": 1,
|
16 |
+
}],
|
17 |
+
mode="subscription",
|
18 |
+
success_url=os.getenv("SUCCESS_URL", "https://example.com/success"),
|
19 |
+
cancel_url=os.getenv("CANCEL_URL", "https://example.com/cancel"),
|
20 |
+
)
|
21 |
+
return session.url
|