Moibe commited on
Commit
28dcd97
Β·
1 Parent(s): 22dad4e
app.py CHANGED
@@ -9,17 +9,15 @@ import time
9
 
10
  app = FastAPI()
11
 
12
- templates = Jinja2Templates(directory="templates")
13
- app.mount("/static", StaticFiles(directory="static"), name="static")
14
-
15
  stripe.api_key = os.environ["STRIPE_KEY"]
16
  # This is a terrible idea, only used for demo purposes!
17
  app.state.stripe_customer_id = None
18
 
19
 
20
  @app.get("/")
21
- def index(request: Request):
22
- return templates.TemplateResponse("index.html", {"request": request, "hasCustomer": app.state.stripe_customer_id is not None})
 
23
 
24
 
25
  @app.get("/success")
 
9
 
10
  app = FastAPI()
11
 
 
 
 
12
  stripe.api_key = os.environ["STRIPE_KEY"]
13
  # This is a terrible idea, only used for demo purposes!
14
  app.state.stripe_customer_id = None
15
 
16
 
17
  @app.get("/")
18
+ def start():
19
+
20
+ return {"Status":"Deployed"}
21
 
22
 
23
  @app.get("/success")
ostest.py DELETED
@@ -1,5 +0,0 @@
1
- import os
2
-
3
- api_key = os.environ["STRIPE_WEBHOOK_SECRET"]
4
-
5
- print(api_key)
 
 
 
 
 
 
static/script.js DELETED
@@ -1,56 +0,0 @@
1
- var createCheckoutSession = function(priceId) {
2
- return fetch("/create-checkout-session", {
3
- method: "POST",
4
- headers: {
5
- "Content-Type": "application/json"
6
- },
7
- body: JSON.stringify({
8
- priceId: priceId
9
- })
10
- }).then(function(result) {
11
- return result.json();
12
- });
13
- };
14
-
15
- const PREMIUM_PRICE_ID = '';
16
- const BASIC_PRICE_ID = '';
17
- const stripe = Stripe("");
18
-
19
- document.addEventListener("DOMContentLoaded", function(event) {
20
- document
21
- .getElementById("checkout-premium")
22
- .addEventListener("click", function(evt) {
23
- createCheckoutSession(PREMIUM_PRICE_ID).then(function(data) {
24
- stripe
25
- .redirectToCheckout({
26
- sessionId: data.sessionId
27
- });
28
- });
29
- });
30
-
31
- document
32
- .getElementById("checkout-basic")
33
- .addEventListener("click", function(evt) {
34
- createCheckoutSession(BASIC_PRICE_ID).then(function(data) {
35
- stripe
36
- .redirectToCheckout({
37
- sessionId: data.sessionId
38
- });
39
- });
40
- });
41
-
42
- const billingButton = document.getElementById("manage-billing");
43
- if (billingButton) {
44
- billingButton.addEventListener("click", function(evt) {
45
- fetch("/create-portal-session", {
46
- method: "POST"
47
- })
48
- .then(function(response) {
49
- return response.json()
50
- })
51
- .then(function(data) {
52
- window.location.href = data.url;
53
- });
54
- })
55
- }
56
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/cancel.html DELETED
@@ -1,7 +0,0 @@
1
- <head>
2
- <title>Cancelled Checkout</title>
3
- </head>
4
- <body>
5
- <h1>Payment was cancelled</h1>
6
- <a href="/">Go home</a>
7
- </body>
 
 
 
 
 
 
 
 
templates/index.html DELETED
@@ -1,13 +0,0 @@
1
- <html>
2
- <head>
3
- <script src="https://js.stripe.com/v3/"></script>
4
- <script src="{{ url_for('static', path='script.js') }}"></script>
5
- </head>
6
- <body>
7
- <button id="checkout-premium">Subscribe Premium</button>
8
- <button id="checkout-basic">Subscribe Basic</button>
9
- {% if hasCustomer %}
10
- <button id="manage-billing">Manage Billing</button>
11
- {% endif %}
12
- </body>
13
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/success.html DELETED
@@ -1,7 +0,0 @@
1
- <head>
2
- <title>Checkout Successful</title>
3
- </head>
4
- <body>
5
- <h1>Payment was successful</h1>
6
- <a href="/">Go home</a>
7
- </body>