eagle0504 commited on
Commit
7e9a3a0
Β·
verified Β·
1 Parent(s): dbec258

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -12
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
-
3
  import streamlit as st
4
  import stripe
5
  import requests
@@ -39,30 +38,43 @@ def check_payment_status(session_id):
39
  return False
40
 
41
  # Streamlit app
42
- st.title("Stripe Payment Integration")
 
43
 
 
 
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.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
 
53
 
54
  # Input for session ID to check payment status
55
  if st.session_state.session_id:
56
- st.write(f"Your session ID: {st.session_state.session_id}")
57
- if st.button("Check Payment Status"):
58
- st.write("Checking payment status, please wait...")
59
  time.sleep(2) # Simulating delay for payment processing
60
 
61
  if check_payment_status(st.session_state.session_id):
62
- st.success("Payment successful!")
63
- st.write("Here's the paid content.")
 
64
  else:
65
- st.error("Payment not completed yet. Please try again.")
66
- else:
67
- st.info("Create a checkout session to get the session ID.")
68
 
 
 
 
 
 
 
 
 
1
  import os
 
2
  import streamlit as st
3
  import stripe
4
  import requests
 
38
  return False
39
 
40
  # Streamlit app
41
+ st.set_page_config(layout="wide")
42
+ st.title("Stripe Payment Integration πŸ’³")
43
 
44
+ # Sidebar for payment processing
45
+ st.sidebar.title("Payment Section πŸ›’")
46
  if 'session_id' not in st.session_state:
47
  st.session_state.session_id = None
48
 
49
+ if 'payment_checked' not in st.session_state:
50
+ st.session_state.payment_checked = False
51
+
52
  # Button to redirect to Stripe Checkout
53
+ if st.sidebar.button("Create Checkout Session"):
54
  session_id, checkout_url = create_checkout_session()
55
  if session_id and checkout_url:
56
  st.session_state.session_id = session_id
57
+ st.session_state.payment_checked = False
58
+ st.sidebar.markdown(f"[Proceed to Checkout]({checkout_url})", unsafe_allow_html=True)
59
 
60
  # Input for session ID to check payment status
61
  if st.session_state.session_id:
62
+ st.sidebar.write(f"Your session ID: {st.session_state.session_id}")
63
+ if st.sidebar.button("Check Payment Status"):
64
+ st.sidebar.write("Checking payment status, please wait... ⏳")
65
  time.sleep(2) # Simulating delay for payment processing
66
 
67
  if check_payment_status(st.session_state.session_id):
68
+ st.session_state.payment_checked = True
69
+ st.success("Payment successful! πŸŽ‰")
70
+ st.sidebar.write("Payment successful! πŸŽ‰")
71
  else:
72
+ st.sidebar.error("Payment not completed yet. Please try again. ❌")
 
 
73
 
74
+ # Display the paid content on the main page if payment is successful
75
+ if st.session_state.payment_checked:
76
+ st.write("Here's the paid content. πŸ†")
77
+ if st.button("Click for More Info"):
78
+ st.write("Here is the additional information for paid users! πŸ“„")
79
+ else:
80
+ st.info("Create a checkout session to get the session ID. πŸ“‹")