import os import stripe import streamlit as st # Set your secret key. Remember to switch to your live secret key in production! stripe.api_key = os.environ["STRIPE_API_KEY"] # Set the product id. stripe_price_id = os.environ["STRIPE_PRICE_ID"] # Function to create a Stripe Checkout Session def create_checkout_session(): try: session = stripe.checkout.Session.create( payment_method_types=['card'], line_items=[{ 'price': stripe_price_id, # Replace with your actual Stripe price ID 'quantity': 1, }], mode='payment', success_url="https://39701j614g.execute-api.us-east-1.amazonaws.com/dev/?sessionID={CHECKOUT_SESSION_ID}&key=123", cancel_url="https://wyn-education.streamlit.app/", ) return session.id, session.url except Exception as e: st.error(f"Error creating checkout session: {e}") return None, None # Function to check payment status def check_payment_status(session_id): try: session = stripe.checkout.Session.retrieve(session_id) return session.payment_status == 'paid' except Exception as e: st.error(f"Error checking payment status: {e}") return False