import os import streamlit as st import time from utils.helper import create_checkout_session, check_payment_status # Streamlit app st.set_page_config(layout="wide") st.title("Stripe Payment Integration 💳") # Sidebar for payment processing st.sidebar.title("Payment Section 🛒") 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.sidebar.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.sidebar.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.sidebar.write(f"Your session ID: {st.session_state.session_id}") if st.sidebar.button("Check Payment Status"): st.sidebar.write("Checking payment status, please wait... ⏳") time.sleep(2) # Simulating delay for payment processing if check_payment_status(st.session_state.session_id): st.session_state.payment_checked = True st.success("Payment successful! 🎉") st.sidebar.write("Payment successful! 🎉") else: st.sidebar.error("Payment not completed yet. Please try again. ❌") # Display the paid content on the main page if payment is successful if st.session_state.payment_checked: with st.sidebar: # Embed Airtable after the download button st.markdown("### Any questions or feedback?") st.markdown(""" """, unsafe_allow_html=True) st.markdown("## Here's the paid content. 🏆") if st.button("Click for More Info"): st.write("Here is the additional information for paid users! 📄") else: st.info("Create a checkout session to get the session ID. 📋")