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']]} πŸ“‹")