Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,41 +44,26 @@ st.title("Stripe Payment Integration")
|
|
44 |
if 'session_id' not in st.session_state:
|
45 |
st.session_state.session_id = None
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
# Example usage
|
56 |
-
product_id = stripe_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 |
-
#
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
# st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
77 |
|
78 |
-
# if check_payment_status(st.session_state.session_id):
|
79 |
-
# st.success("Payment successful!")
|
80 |
-
# st.write("Here's the paid content.")
|
81 |
-
# else:
|
82 |
-
# st.error("Payment not completed yet. Please try again.")
|
83 |
-
# else:
|
84 |
-
# st.info("Create a checkout session to get the session ID.")
|
|
|
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()
|
50 |
+
if session_id and checkout_url:
|
51 |
+
st.session_state.session_id = session_id
|
52 |
+
st.write(f"Checkout URL: {checkout_url}")
|
53 |
+
st.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
# Input for session ID to check payment status
|
56 |
+
if st.session_state.session_id:
|
57 |
+
st.write(f"Your session ID: {st.session_state.session_id}")
|
58 |
+
if st.button("Check Payment Status"):
|
59 |
+
st.write("Checking payment status, please wait...")
|
60 |
+
time.sleep(2) # Simulating delay for payment processing
|
|
|
61 |
|
62 |
+
if check_payment_status(st.session_state.session_id):
|
63 |
+
st.success("Payment successful!")
|
64 |
+
st.write("Here's the paid content.")
|
65 |
+
else:
|
66 |
+
st.error("Payment not completed yet. Please try again.")
|
67 |
+
else:
|
68 |
+
st.info("Create a checkout session to get the session ID.")
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|