Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +68 -2
src/streamlit_app.py
CHANGED
|
@@ -1,2 +1,68 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Set a centered layout for a cleaner, minimal look
|
| 4 |
+
st.set_page_config(layout="centered")
|
| 5 |
+
|
| 6 |
+
# --- Start of User-Requested Content ---
|
| 7 |
+
st.write("Hello")
|
| 8 |
+
# --- End of User-Requested Content ---
|
| 9 |
+
|
| 10 |
+
# --- Payment Variables (MUST UPDATE) ---
|
| 11 |
+
# !!! CRITICAL 1: Replace this placeholder with your actual PayPal email or Merchant ID. !!!
|
| 12 |
+
PAYPAL_BUSINESS_EMAIL = "YOUR_PAYPAL_EMAIL@example.com"
|
| 13 |
+
CURRENCY_CODE = "USD"
|
| 14 |
+
|
| 15 |
+
# !!! CRITICAL 2: URL to redirect the user to after they successfully complete payment on PayPal.
|
| 16 |
+
SUCCESS_URL = "https://www.yourdomain.com/payment-thank-you"
|
| 17 |
+
|
| 18 |
+
# --- Fixed Price Configuration ---
|
| 19 |
+
FIXED_AMOUNT = 25.00
|
| 20 |
+
FIXED_ITEM_NAME = "Basic Service Payment"
|
| 21 |
+
ITEM_NAME = FIXED_ITEM_NAME
|
| 22 |
+
AMOUNT = FIXED_AMOUNT
|
| 23 |
+
# --- End of Variables ---
|
| 24 |
+
|
| 25 |
+
st.markdown("---")
|
| 26 |
+
st.subheader(f"Secure Payment for {FIXED_ITEM_NAME}")
|
| 27 |
+
st.write(f"Click below to pay the fixed amount of **${AMOUNT:.2f}**.")
|
| 28 |
+
|
| 29 |
+
# Generate the payment link with success redirection (key is '&return={SUCCESS_URL}')
|
| 30 |
+
PAYMENT_LINK = (
|
| 31 |
+
f"https://www.paypal.com/cgi-bin/webscr?"
|
| 32 |
+
f"cmd=_xclick&"
|
| 33 |
+
f"business={PAYPAL_BUSINESS_EMAIL}&"
|
| 34 |
+
f"item_name={ITEM_NAME}&"
|
| 35 |
+
f"amount={AMOUNT:.2f}&"
|
| 36 |
+
f"currency_code={CURRENCY_CODE}&"
|
| 37 |
+
f"return={SUCCESS_URL}"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
# HTML for a clean, functional PayPal Button
|
| 41 |
+
paypal_html = f"""
|
| 42 |
+
<div style="margin-top: 20px;">
|
| 43 |
+
<a href="{PAYMENT_LINK}" target="_blank" style="
|
| 44 |
+
display: inline-block;
|
| 45 |
+
padding: 10px 20px;
|
| 46 |
+
font-size: 16px;
|
| 47 |
+
font-weight: bold;
|
| 48 |
+
color: white !important;
|
| 49 |
+
background-color: #0070BA;
|
| 50 |
+
border-radius: 5px;
|
| 51 |
+
text-align: center;
|
| 52 |
+
text-decoration: none;
|
| 53 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
| 54 |
+
transition: background-color 0.1s;
|
| 55 |
+
" onmouseover="this.style.backgroundColor='#008CDB'" onmouseout="this.style.backgroundColor='#0070BA'">
|
| 56 |
+
Pay Now (${AMOUNT:.2f})
|
| 57 |
+
</a>
|
| 58 |
+
</div>
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
# Inject the HTML into the Streamlit app
|
| 62 |
+
st.markdown(paypal_html, unsafe_allow_html=True)
|
| 63 |
+
|
| 64 |
+
st.markdown("---")
|
| 65 |
+
st.info(
|
| 66 |
+
"The payment link is fully configured to redirect the user to the URL specified in the `SUCCESS_URL` variable after payment completion."
|
| 67 |
+
)
|
| 68 |
+
|