Spaces:
Runtime error
Runtime error
File size: 1,870 Bytes
ecffc04 |
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 |
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="[email protected]",
)
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']]} π")
|