# import streamlit as st | |
# from utils.helper import * | |
# from utils.ui_helper import * | |
# # Streamlit app | |
# st.set_page_config(layout="wide") | |
# st.title("Stripe Payment Integration") | |
# if 'session_id' not in st.session_state: | |
# st.session_state.session_id = None | |
# # Button to redirect to Stripe Checkout | |
# if st.button("Create Checkout Session"): | |
# session_id, checkout_url = create_checkout_session() | |
# if session_id and checkout_url: | |
# st.session_state.session_id = session_id | |
# st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True) | |
# # Input for session ID to check payment status | |
# if st.session_state.session_id: | |
# st.write(f"Your session ID: {st.session_state.session_id}") | |
# if st.button("Check Payment Status"): | |
# st.write("Checking payment status, please wait...") | |
# time.sleep(2) # Simulating delay for payment processing | |
# if check_payment_status(st.session_state.session_id): | |
# st.success("Payment successful!") | |
# st.write("Here's the paid content.") | |
# # run ui | |
# main_algo_trader() | |
# else: | |
# st.error("Payment not completed yet. Please try again.") | |
# else: | |
# st.info("Create a checkout session to get the session ID.") | |
# import streamlit as st | |
# import time | |
# from utils.helper import * | |
# from utils.ui_helper import * | |
# # Streamlit app | |
# st.set_page_config(layout="wide") | |
# st.title("Stripe Payment Integration") | |
# if 'session_id' not in st.session_state: | |
# st.session_state.session_id = None | |
# if 'payment_checked' not in st.session_state: | |
# st.session_state.payment_checked = False | |
# # Button to redirect to Stripe Checkout | |
# if st.button("Create Checkout Session"): | |
# session_id, checkout_url = create_checkout_session() | |
# if session_id and checkout_url: | |
# st.session_state.session_id = session_id | |
# st.session_state.payment_checked = False | |
# st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True) | |
# # Input for session ID to check payment status | |
# if st.session_state.session_id: | |
# st.write(f"Your session ID: {st.session_state.session_id}") | |
# if st.button("Check Payment Status"): | |
# st.write("Checking payment status, please wait...") | |
# time.sleep(2) # Simulating delay for payment processing | |
# if check_payment_status(st.session_state.session_id): | |
# st.success("Payment successful!") | |
# st.write("Here's the paid content.") | |
# st.session_state.payment_checked = True | |
# else: | |
# st.error("Payment not completed yet. Please try again.") | |
# else: | |
# st.info("Create a checkout session to get the session ID.") | |
# # Run the main_algo_trader only if the payment has been checked and is successful | |
# if st.session_state.payment_checked: | |
# main_algo_trader() | |
import streamlit as st | |
import time | |
from utils.helper import * | |
from utils.ui_helper import * | |
# Streamlit app configuration | |
st.set_page_config(layout="wide") | |
# st.title("Stripe Payment Integration") | |
# Sidebar for session ID input and payment actions | |
with st.sidebar: | |
st.header("Payment and Session ID") | |
# Initialize session states if not already set | |
if 'session_id' not in st.session_state: | |
st.session_state.session_id = None | |
if 'payment_checked' not in st.session_state: | |
st.session_state.payment_checked = False | |
# Session ID input field | |
session_id_input = st.text_input("Enter your Session ID", st.session_state.session_id or "") | |
# Button to check payment status | |
if st.button("Check Payment Status"): | |
if session_id_input: | |
st.session_state.session_id = session_id_input | |
st.write("Checking payment status, please wait...") | |
time.sleep(2) # Simulating delay for payment processing | |
if check_payment_status(st.session_state.session_id): | |
st.success("Payment successful!") | |
st.session_state.payment_checked = True | |
else: | |
st.error("Payment not completed yet. Please try again.") | |
else: | |
st.warning("Please enter a valid session ID.") | |
# Button to create a new checkout session | |
if st.button("Create Checkout Session"): | |
session_id, checkout_url = create_checkout_session() | |
if session_id and checkout_url: | |
st.session_state.session_id = session_id | |
st.session_state.payment_checked = False | |
st.write(f"Your session ID: {st.session_state.session_id}") | |
st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True) | |
# Main panel: Only show main_algo_trader() if payment is successful | |
if st.session_state.payment_checked: | |
main_algo_trader() | |
else: | |
st.write("Please complete the payment to access the content.") | |