eagle0504 commited on
Commit
09acc7d
1 Parent(s): e0c9ff5

Update pages/1_english_.py

Browse files
Files changed (1) hide show
  1. pages/1_english_.py +32 -37
pages/1_english_.py CHANGED
@@ -88,49 +88,44 @@ from utils.ui_helper import *
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.")
128
- st.session_state.payment_checked = True
129
- else:
130
- st.error("Payment not completed yet. Please try again.")
131
- else:
132
- st.info("Create a checkout session to get the session ID.")
133
 
134
- # Run the main_algo_trader only if the payment has been checked and is successful
135
  if st.session_state.payment_checked:
136
  main_algo_trader()
 
 
 
88
  st.set_page_config(layout="wide")
89
  st.title("Stripe Payment Integration")
90
 
91
+ # Sidebar for session ID input and payment actions
92
  with st.sidebar:
93
+ st.header("Payment and Session ID")
94
+
95
+ # Initialize session states if not already set
96
+ if 'session_id' not in st.session_state:
97
+ st.session_state.session_id = None
98
+ if 'payment_checked' not in st.session_state:
99
+ st.session_state.payment_checked = False
100
+
101
+ # Session ID input field
102
+ session_id_input = st.text_input("Enter your Session ID", st.session_state.session_id or "")
103
+
104
+ # Button to check payment status
105
+ if st.button("Check Payment Status"):
106
  if session_id_input:
107
  st.session_state.session_id = session_id_input
108
+ st.write("Checking payment status, please wait...")
109
+ time.sleep(2) # Simulating delay for payment processing
110
+ if check_payment_status(st.session_state.session_id):
111
+ st.success("Payment successful!")
112
+ st.session_state.payment_checked = True
113
+ else:
114
+ st.error("Payment not completed yet. Please try again.")
115
  else:
116
  st.warning("Please enter a valid session ID.")
117
 
118
+ # Button to create a new checkout session
119
+ if st.button("Create Checkout Session"):
120
+ session_id, checkout_url = create_checkout_session()
121
+ if session_id and checkout_url:
122
+ st.session_state.session_id = session_id
123
+ st.session_state.payment_checked = False
124
+ st.write(f"Your session ID: {st.session_state.session_id}")
125
+ st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
+ # Main panel: Only show main_algo_trader() if payment is successful
128
  if st.session_state.payment_checked:
129
  main_algo_trader()
130
+ else:
131
+ st.write("Please complete the payment to access the content.")