eagle0504 commited on
Commit
9600a90
·
1 Parent(s): efb54dc

stripe api integration with state

Browse files
Files changed (1) hide show
  1. pages/1_english_.py +55 -15
pages/1_english_.py CHANGED
@@ -1,8 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
 
2
  from utils.helper import *
3
  from utils.ui_helper import *
4
 
5
-
6
  # Streamlit app
7
  st.set_page_config(layout="wide")
8
  st.title("Stripe Payment Integration")
@@ -10,31 +48,33 @@ st.title("Stripe Payment Integration")
10
  if 'session_id' not in st.session_state:
11
  st.session_state.session_id = None
12
 
 
 
 
13
  # Button to redirect to Stripe Checkout
14
  if st.button("Create Checkout Session"):
15
  session_id, checkout_url = create_checkout_session()
16
  if session_id and checkout_url:
17
  st.session_state.session_id = session_id
 
18
  st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
19
 
20
  # Input for session ID to check payment status
21
  if st.session_state.session_id:
22
- # Status
23
  st.write(f"Your session ID: {st.session_state.session_id}")
 
 
 
24
 
25
- # Checking
26
- st.write("Checking payment status, please wait...")
27
- time.sleep(2) # Simulating delay for payment processing
28
-
29
- # Main content
30
- if check_payment_status(st.session_state.session_id):
31
- st.success("Payment successful!")
32
- st.write("Here's the paid content.")
33
-
34
- # run ui
35
- main_algo_trader()
36
- else:
37
- st.error("Payment not completed yet. Please try again.")
38
  else:
39
  st.info("Create a checkout session to get the session ID.")
40
 
 
 
 
 
1
+ # import streamlit as st
2
+ # from utils.helper import *
3
+ # from utils.ui_helper import *
4
+
5
+
6
+ # # Streamlit app
7
+ # st.set_page_config(layout="wide")
8
+ # st.title("Stripe Payment Integration")
9
+
10
+ # if 'session_id' not in st.session_state:
11
+ # st.session_state.session_id = None
12
+
13
+ # # Button to redirect to Stripe Checkout
14
+ # if st.button("Create Checkout Session"):
15
+ # session_id, checkout_url = create_checkout_session()
16
+ # if session_id and checkout_url:
17
+ # st.session_state.session_id = session_id
18
+ # st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
19
+
20
+ # # Input for session ID to check payment status
21
+ # if st.session_state.session_id:
22
+ # st.write(f"Your session ID: {st.session_state.session_id}")
23
+ # if st.button("Check Payment Status"):
24
+ # st.write("Checking payment status, please wait...")
25
+ # time.sleep(2) # Simulating delay for payment processing
26
+
27
+ # if check_payment_status(st.session_state.session_id):
28
+ # st.success("Payment successful!")
29
+ # st.write("Here's the paid content.")
30
+
31
+ # # run ui
32
+ # main_algo_trader()
33
+ # else:
34
+ # st.error("Payment not completed yet. Please try again.")
35
+ # else:
36
+ # st.info("Create a checkout session to get the session ID.")
37
+
38
+
39
  import streamlit as st
40
+ import time
41
  from utils.helper import *
42
  from utils.ui_helper import *
43
 
 
44
  # Streamlit app
45
  st.set_page_config(layout="wide")
46
  st.title("Stripe Payment Integration")
 
48
  if 'session_id' not in st.session_state:
49
  st.session_state.session_id = None
50
 
51
+ if 'payment_checked' not in st.session_state:
52
+ st.session_state.payment_checked = False
53
+
54
  # Button to redirect to Stripe Checkout
55
  if st.button("Create Checkout Session"):
56
  session_id, checkout_url = create_checkout_session()
57
  if session_id and checkout_url:
58
  st.session_state.session_id = session_id
59
+ st.session_state.payment_checked = False
60
  st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
61
 
62
  # Input for session ID to check payment status
63
  if st.session_state.session_id:
 
64
  st.write(f"Your session ID: {st.session_state.session_id}")
65
+ if st.button("Check Payment Status"):
66
+ st.write("Checking payment status, please wait...")
67
+ time.sleep(2) # Simulating delay for payment processing
68
 
69
+ if check_payment_status(st.session_state.session_id):
70
+ st.success("Payment successful!")
71
+ st.write("Here's the paid content.")
72
+ st.session_state.payment_checked = True
73
+ else:
74
+ st.error("Payment not completed yet. Please try again.")
 
 
 
 
 
 
 
75
  else:
76
  st.info("Create a checkout session to get the session ID.")
77
 
78
+ # Run the main_algo_trader only if the payment has been checked and is successful
79
+ if st.session_state.payment_checked:
80
+ main_algo_trader()