Spaces:
Running on Zero
Running on Zero
Part 200: fix Paddle mode detection (sandbox vs live vs simulated)
Browse files- src/sunnyware/billing.py +10 -1
- static/admin-v2.html +8 -1
- static/admin.html +6 -1
src/sunnyware/billing.py
CHANGED
|
@@ -16,8 +16,17 @@ async def create_checkout_url(org_id: str, plan_id: str,
|
|
| 16 |
|
| 17 |
|
| 18 |
def status() -> dict:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
return {
|
| 20 |
"enabled": enabled(),
|
| 21 |
"provider": "paddle",
|
| 22 |
-
"mode":
|
| 23 |
}
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
def status() -> dict:
|
| 19 |
+
# Part 200: return real environment (sandbox/live/simulated)
|
| 20 |
+
if not enabled():
|
| 21 |
+
mode = "simulated"
|
| 22 |
+
else:
|
| 23 |
+
try:
|
| 24 |
+
from . import paddle_client
|
| 25 |
+
mode = paddle_client._environment() # "live" or "sandbox"
|
| 26 |
+
except Exception:
|
| 27 |
+
mode = "live"
|
| 28 |
return {
|
| 29 |
"enabled": enabled(),
|
| 30 |
"provider": "paddle",
|
| 31 |
+
"mode": mode,
|
| 32 |
}
|
static/admin-v2.html
CHANGED
|
@@ -335,7 +335,14 @@ async function renderDashboard() {
|
|
| 335 |
|
| 336 |
<h2>Paddle Billing</h2>
|
| 337 |
<div class="card">
|
| 338 |
-
<p style="margin:0;">${
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
</div>
|
| 340 |
`;
|
| 341 |
}
|
|
|
|
| 335 |
|
| 336 |
<h2>Paddle Billing</h2>
|
| 337 |
<div class="card">
|
| 338 |
+
<p style="margin:0;">${
|
| 339 |
+
billing.mode === 'live'
|
| 340 |
+
? '<strong style="color:var(--success);">Live Mode</strong> — Paddle Connected (Real Payments)'
|
| 341 |
+
: billing.mode === 'sandbox'
|
| 342 |
+
? '<strong style="color:var(--warn);">Sandbox Mode</strong> — Paddle Sandbox (Test Payments Only)'
|
| 343 |
+
: '<strong style="color:var(--danger);">Simulated</strong> — Add PADDLE_API_KEY to enable billing'
|
| 344 |
+
}</p>
|
| 345 |
+
<p style="margin:8px 0 0 0;font-size:12px;color:var(--muted);">Current mode: <code>${billing.mode || 'unknown'}</code> · Provider: <code>${billing.provider || '?'}</code></p>
|
| 346 |
</div>
|
| 347 |
`;
|
| 348 |
}
|
static/admin.html
CHANGED
|
@@ -232,7 +232,12 @@ async function loadDashboard() {
|
|
| 232 |
<div class="card"><div class="title">Invoices</div><div class="value">${d.total_invoices}</div></div>
|
| 233 |
`;
|
| 234 |
const b = await apiCall('/api/saas/billing/status');
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
} catch(e) {}
|
| 237 |
}
|
| 238 |
|
|
|
|
| 232 |
<div class="card"><div class="title">Invoices</div><div class="value">${d.total_invoices}</div></div>
|
| 233 |
`;
|
| 234 |
const b = await apiCall('/api/saas/billing/status');
|
| 235 |
+
const _modeHtml = b.mode === 'live'
|
| 236 |
+
? '<strong style="color:#2ecc71;">Live Mode</strong> (Paddle Connected — Real Payments)'
|
| 237 |
+
: b.mode === 'sandbox'
|
| 238 |
+
? '<strong style="color:#f39c12;">Sandbox Mode</strong> (Paddle Sandbox — Test Payments Only)'
|
| 239 |
+
: '<strong style="color:#e74c3c;">Simulated</strong> (Add PADDLE_API_KEY to enable billing)';
|
| 240 |
+
document.getElementById('stripe-status').innerHTML = _modeHtml + ' <small style="opacity:0.7;">mode: ' + (b.mode || '?') + '</small>';
|
| 241 |
} catch(e) {}
|
| 242 |
}
|
| 243 |
|