AIEcosystem commited on
Commit
b4c8431
Β·
verified Β·
1 Parent(s): 4e5dcb6

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +85 -0
src/streamlit_app.py CHANGED
@@ -28,7 +28,92 @@ from streamlit_extras.stylable_container import stylable_container
28
 
29
 
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
 
 
32
 
33
 
34
 
 
28
 
29
 
30
 
31
+ # --- 1. Email Input Form (NEW) ---
32
+ # Use a form to capture the email and store it in session state
33
+ with st.form(key='upgrade_form'):
34
+ # This is where the user writes their email address
35
+ user_email_input = st.text_input(
36
+ "Enter your email address to confirm your subscription and access the premium app:",
37
+ placeholder="your.email@example.com"
38
+ )
39
+
40
+ # We use a submit button to generate the final link dynamically
41
+ submit_button = st.form_submit_button(label='Generate PayPal Link')
42
+
43
+ # Store the email in session state after submission
44
+ if submit_button and user_email_input:
45
+ st.session_state['user_email'] = user_email_input
46
+ elif submit_button and not user_email_input:
47
+ st.error("Please enter your email address to continue.")
48
+ st.session_state['user_email'] = None
49
+
50
+
51
+ # --- 2. Payment Variables & Link Generation ---
52
+
53
+ # Retrieve the captured email, defaulting to a placeholder if not set
54
+ USER_EMAIL = st.session_state.get('user_email', 'placeholder@example.com')
55
+
56
+ # !!! CRITICAL 1: Replace this placeholder with your actual PayPal email or Merchant ID. !!!
57
+ PAYPAL_BUSINESS_EMAIL = "maria.tsilimos@proton.me"
58
+ CURRENCY_CODE = "USD"
59
+
60
+ # !!! CRITICAL 2: Base URL for the premium app.
61
+ BASE_SUCCESS_URL = "https://premium-6msh.onrender.com"
62
+
63
+ FIXED_AMOUNT = 29.90
64
+ FIXED_ITEM_NAME = "Premium Annual Subscription"
65
+ ITEM_NAME = FIXED_ITEM_NAME
66
+ AMOUNT = FIXED_AMOUNT
67
+
68
+ # πŸ”‘ Generate the success URL with the captured email as a query parameter
69
+ # The email is URL-encoded automatically by f-string, but we must use the captured variable
70
+ SUCCESS_URL_WITH_EMAIL = f"{BASE_SUCCESS_URL}?user_email={USER_EMAIL}"
71
+
72
+ PAYMENT_LINK = (
73
+ f"https://www.paypal.com/cgi-bin/webscr?"
74
+ f"cmd=_xclick&"
75
+ f"business={PAYPAL_BUSINESS_EMAIL}&"
76
+ f"item_name={ITEM_NAME}&"
77
+ f"amount={AMOUNT:.2f}&"
78
+ f"currency_code={CURRENCY_CODE}&"
79
+ f"return={SUCCESS_URL_WITH_EMAIL}" # πŸ”‘ Now passes the dynamic email
80
+ )
81
+
82
+ # --- 3. HTML for the Button (Only displayed if email is ready) ---
83
+
84
+ if USER_EMAIL and USER_EMAIL != 'placeholder@example.com':
85
+
86
+ paypal_html = f"""
87
+ <div style="margin-top: 10px; text-align: center;">
88
+ <a href="{PAYMENT_LINK}" target="_blank"
89
+ style="
90
+ display: inline-block;
91
+ padding: 12px 24px;
92
+ font-size: 18px;
93
+ font-weight: bold;
94
+ color: black !important;
95
+ background-color: #FFC439; /* Yellow color */
96
+ border-radius: 8px;
97
+ text-align: center;
98
+ text-decoration: none;
99
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
100
+ transition: background-color 0.1s;
101
+ " onmouseover="this.style.backgroundColor='#FFAA00'"
102
+ onmouseout="this.style.backgroundColor='#FFC439'">
103
+ PAY NOW: Upgrade to Premium (${AMOUNT:.2f}/a year)
104
+ </a>
105
+ </div>
106
+ """
107
+
108
+ st.markdown("---")
109
+ st.markdown(paypal_html, unsafe_allow_html=True)
110
+ st.info(f"Click the button above to pay. You will be redirected to PayPal using the email: **{USER_EMAIL}**")
111
+
112
+ else:
113
+ st.info("Please enter your email above and click 'Generate PayPal Link' to proceed with payment.")
114
 
115
+ st.markdown("---")
116
+ st.write("Thank you for using our free features!")
117
 
118
 
119