Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,6 +44,22 @@ st.title("Stripe Payment Integration")
|
|
44 |
if 'session_id' not in st.session_state:
|
45 |
st.session_state.session_id = None
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# Button to redirect to Stripe Checkout
|
48 |
if st.button("Create Checkout Session"):
|
49 |
session_id, checkout_url = create_checkout_session()
|
|
|
44 |
if 'session_id' not in st.session_state:
|
45 |
st.session_state.session_id = None
|
46 |
|
47 |
+
def list_prices_for_product(product_id):
|
48 |
+
try:
|
49 |
+
prices = stripe.Price.list(product=product_id)
|
50 |
+
return prices
|
51 |
+
except Exception as e:
|
52 |
+
print(f"Error listing prices: {e}")
|
53 |
+
return None
|
54 |
+
|
55 |
+
# Example usage
|
56 |
+
product_id = 'your-product-id' # Replace with your actual Product ID
|
57 |
+
prices = list_prices_for_product(product_id)
|
58 |
+
|
59 |
+
if prices:
|
60 |
+
for price in prices.data:
|
61 |
+
print(f"Price ID: {price.id}, Amount: {price.unit_amount}, Currency: {price.currency}")
|
62 |
+
|
63 |
# Button to redirect to Stripe Checkout
|
64 |
if st.button("Create Checkout Session"):
|
65 |
session_id, checkout_url = create_checkout_session()
|