Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,38 +17,48 @@ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnl
|
|
| 17 |
treasury_usdc = 0.0
|
| 18 |
treasury_btc = 0.0
|
| 19 |
|
| 20 |
-
def check_bill(url, premium=False
|
| 21 |
global treasury_usdc, treasury_btc
|
| 22 |
|
| 23 |
if premium:
|
| 24 |
-
if not api_key:
|
| 25 |
-
main_out = "
|
| 26 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 27 |
return main_out, treasury_out
|
|
|
|
| 28 |
try:
|
| 29 |
-
session = stripe.checkout.sessions.create
|
| 30 |
payment_method_types=['card'],
|
| 31 |
line_items=[{
|
| 32 |
'price_data': {
|
| 33 |
'currency': 'usd',
|
| 34 |
'product_data': {'name': 'BillionDollarOracle Premium'},
|
| 35 |
-
'unit_amount': 100,
|
| 36 |
'recurring': {'interval': 'month'},
|
| 37 |
},
|
| 38 |
'quantity': 1,
|
| 39 |
}],
|
| 40 |
mode='subscription',
|
| 41 |
-
success_url=f"{SITE_URL}/success",
|
| 42 |
cancel_url=f"{SITE_URL}/cancel",
|
| 43 |
metadata={'dao_vote': 'true'}
|
| 44 |
)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
-
main_out = f"
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
try:
|
| 54 |
text = requests.get(url, timeout=10).text.lower()
|
|
|
|
| 17 |
treasury_usdc = 0.0
|
| 18 |
treasury_btc = 0.0
|
| 19 |
|
| 20 |
+
def check_bill(url, premium=False):
|
| 21 |
global treasury_usdc, treasury_btc
|
| 22 |
|
| 23 |
if premium:
|
| 24 |
+
if not stripe.api_key:
|
| 25 |
+
main_out = "**Error: Stripe key missing.** Add `STRIPE_SECRET_KEY` in HF Secrets."
|
| 26 |
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 27 |
return main_out, treasury_out
|
| 28 |
+
|
| 29 |
try:
|
| 30 |
+
session = stripe.checkout.Session.create( # Note: 'create' not 'checkout.sessions.create'
|
| 31 |
payment_method_types=['card'],
|
| 32 |
line_items=[{
|
| 33 |
'price_data': {
|
| 34 |
'currency': 'usd',
|
| 35 |
'product_data': {'name': 'BillionDollarOracle Premium'},
|
| 36 |
+
'unit_amount': 100, # $1.00
|
| 37 |
'recurring': {'interval': 'month'},
|
| 38 |
},
|
| 39 |
'quantity': 1,
|
| 40 |
}],
|
| 41 |
mode='subscription',
|
| 42 |
+
success_url=f"{SITE_URL}/success?session_id={{CHECKOUT_SESSION_ID}}",
|
| 43 |
cancel_url=f"{SITE_URL}/cancel",
|
| 44 |
metadata={'dao_vote': 'true'}
|
| 45 |
)
|
| 46 |
+
# Force redirect in Gradio (popup/redirect)
|
| 47 |
+
main_out = f"""
|
| 48 |
+
**Premium Unlock:**
|
| 49 |
+
Redirecting to Stripe... (if no popup, click below)
|
| 50 |
+
[Pay $1/month β Unlimited + Vote]({session.url})
|
| 51 |
+
90% β BTC treasury | 10% β `{CREATOR_WALLET}`
|
| 52 |
+
"""
|
| 53 |
+
except stripe.error.InvalidRequestError as e:
|
| 54 |
+
main_out = f"**Stripe Error:** {str(e)} (Check key/mode in dashboard)."
|
| 55 |
except Exception as e:
|
| 56 |
+
main_out = f"**Unexpected Error:** {str(e)}. Use free mode."
|
| 57 |
+
else:
|
| 58 |
+
main_out = main_out # From try block
|
| 59 |
+
|
| 60 |
+
treasury_out = f"**Treasury:** ${treasury_usdc:,.0f} USDC | {treasury_btc:.4f} BTC"
|
| 61 |
+
return main_out, treasury_out
|
| 62 |
|
| 63 |
try:
|
| 64 |
text = requests.get(url, timeout=10).text.lower()
|