import streamlit as st import stripe # Initialize Stripe API stripe.api_key = "sk_test_your_secret_key_here" # Streamlit UI st.title("Stripe API Demo with Streamlit 😃") # Create Customer 😇 if st.button("Create Customer"): customer = stripe.Customer.create( name="John Doe", email="john.doe@example.com", ) st.write(f"Customer Created: {customer['id']} 🎉") # Retrieve Customer 🕵️ if st.button("Retrieve Customer"): customer = stripe.Customer.retrieve(customer['id']) st.write(f"Customer Retrieved: {customer['id']} 🕵️") # Update Customer 🔄 if st.button("Update Customer"): customer = stripe.Customer.modify( customer['id'], name="Jane Doe", ) st.write(f"Customer Updated: {customer['name']} 🔄") # Delete Customer 🗑️ if st.button("Delete Customer"): deleted_customer = stripe.Customer.delete(customer['id']) st.write(f"Customer Deleted: {deleted_customer['id']} 🗑️") # Create Payment Intent 💰 if st.button("Create Payment Intent"): payment_intent = stripe.PaymentIntent.create( amount=1000, currency="usd", ) st.write(f"Payment Intent Created: {payment_intent['id']} 💰") # Confirm Payment Intent ✅ if st.button("Confirm Payment Intent"): confirmed_payment = stripe.PaymentIntent.confirm(payment_intent['id']) st.write(f"Payment Intent Confirmed: {confirmed_payment['status']} ✅") # Cancel Payment Intent ❌ if st.button("Cancel Payment Intent"): canceled_payment = stripe.PaymentIntent.cancel(payment_intent['id']) st.write(f"Payment Intent Canceled: {canceled_payment['status']} ❌") # List Payment Intents 📋 if st.button("List Payment Intents"): payment_intents = stripe.PaymentIntent.list(limit=3) st.write(f"Payment Intents Listed: {[p['id'] for p in payment_intents['data']]} 📋")