Update app.py
Browse files
app.py
CHANGED
|
@@ -22,13 +22,13 @@ STYLE_PRESETS = {
|
|
| 22 |
}
|
| 23 |
|
| 24 |
def check_paywall(user_id: str):
|
| 25 |
-
"""Check user payment status and generate
|
| 26 |
headers = {
|
| 27 |
"Authorization": f"Bearer {PAYWALLS_API_KEY}",
|
| 28 |
"Content-Type": "application/json"
|
| 29 |
}
|
| 30 |
|
| 31 |
-
# Check if user has
|
| 32 |
try:
|
| 33 |
check_response = requests.get(
|
| 34 |
f"{PAYWALLS_API_URL}/payments/check",
|
|
@@ -40,24 +40,8 @@ def check_paywall(user_id: str):
|
|
| 40 |
except:
|
| 41 |
is_paid = False
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
link_response = requests.post(
|
| 46 |
-
f"{PAYWALLS_API_URL}/payments/link",
|
| 47 |
-
headers=headers,
|
| 48 |
-
json={
|
| 49 |
-
"user_id": user_id,
|
| 50 |
-
"amount": 999, # $9.99 in cents
|
| 51 |
-
"currency": "usd",
|
| 52 |
-
"description": "Creative Writing Premium - Unlimited tokens + styles + export"
|
| 53 |
-
},
|
| 54 |
-
timeout=10
|
| 55 |
-
)
|
| 56 |
-
link_response.raise_for_status()
|
| 57 |
-
paywall_url = link_response.json().get("url", "https://paywalls.ai")
|
| 58 |
-
except Exception as e:
|
| 59 |
-
print(f"[Paywall Link] Error: {e}")
|
| 60 |
-
paywall_url = "https://paywalls.ai"
|
| 61 |
|
| 62 |
return is_paid, paywall_url
|
| 63 |
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
def check_paywall(user_id: str):
|
| 25 |
+
"""Check user payment status and generate wallet topup link"""
|
| 26 |
headers = {
|
| 27 |
"Authorization": f"Bearer {PAYWALLS_API_KEY}",
|
| 28 |
"Content-Type": "application/json"
|
| 29 |
}
|
| 30 |
|
| 31 |
+
# Check if user has active balance/subscription
|
| 32 |
try:
|
| 33 |
check_response = requests.get(
|
| 34 |
f"{PAYWALLS_API_URL}/payments/check",
|
|
|
|
| 40 |
except:
|
| 41 |
is_paid = False
|
| 42 |
|
| 43 |
+
# Direct users to AI Wallet topup page
|
| 44 |
+
paywall_url = f"https://wallet.paywalls.ai/topup?user={user_id}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
return is_paid, paywall_url
|
| 47 |
|