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

Update pages/1_english_.py

Browse files
Files changed (1) hide show
  1. pages/1_english_.py +62 -6
pages/1_english_.py CHANGED
@@ -36,36 +36,92 @@
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")
47
 
 
 
 
 
 
 
 
 
 
 
 
 
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.")
 
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")
47
+
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()
81
+
82
  import streamlit as st
83
  import time
84
  from utils.helper import *
85
  from utils.ui_helper import *
86
 
87
+ # Streamlit app configuration
88
  st.set_page_config(layout="wide")
89
  st.title("Stripe Payment Integration")
90
 
91
+ # Sidebar for session ID input
92
+ with st.sidebar:
93
+ st.header("Enter your Session ID")
94
+ session_id_input = st.text_input("Session ID", "")
95
+ if st.button("Check Payment Status", key="sidebar_check"):
96
+ if session_id_input:
97
+ st.session_state.session_id = session_id_input
98
+ st.session_state.payment_checked = False
99
+ else:
100
+ st.warning("Please enter a valid session ID.")
101
+
102
+ # Initializing session states
103
  if 'session_id' not in st.session_state:
104
  st.session_state.session_id = None
 
105
  if 'payment_checked' not in st.session_state:
106
  st.session_state.payment_checked = False
107
 
108
+ # Button to create a new checkout session
109
  if st.button("Create Checkout Session"):
110
  session_id, checkout_url = create_checkout_session()
111
  if session_id and checkout_url:
112
  st.session_state.session_id = session_id
113
  st.session_state.payment_checked = False
114
+ st.sidebar.write(f"Your session ID: {st.session_state.session_id}")
115
+ st.sidebar.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
116
 
117
+ # Display session ID if available
118
  if st.session_state.session_id:
119
  st.write(f"Your session ID: {st.session_state.session_id}")
120
+
121
+ # Button to check payment status
122
  if st.button("Check Payment Status"):
123
  st.write("Checking payment status, please wait...")
124
  time.sleep(2) # Simulating delay for payment processing
 
125
  if check_payment_status(st.session_state.session_id):
126
  st.success("Payment successful!")
127
  st.write("Here's the paid content.")