File size: 4,884 Bytes
9600a90 e0c9ff5 82ca5ae 9600a90 82ca5ae e0c9ff5 a139008 0f5d546 9fa9073 09acc7d e0c9ff5 09acc7d e0c9ff5 09acc7d e0c9ff5 09acc7d 9fa9073 09acc7d 9600a90 09acc7d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# 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.")
|