Update pages/1_english_.py
Browse files- 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("
|
94 |
-
|
95 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
if session_id_input:
|
97 |
st.session_state.session_id = session_id_input
|
98 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
else:
|
100 |
st.warning("Please enter a valid session ID.")
|
101 |
|
102 |
-
#
|
103 |
-
if
|
104 |
-
|
105 |
-
if
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
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 |
-
#
|
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.")
|