Add payment launch mode flag
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
VITE_PAYMENTS_ENABLED=false
|
||||
VITE_STRIPE_YEARLY_URL=
|
||||
VITE_STRIPE_LIFETIME_URL=
|
||||
VITE_STRIPE_WEEKLY_URL=
|
||||
|
||||
@@ -41,6 +41,20 @@ To wipe progress: open browser devtools → Application → Local Storage → de
|
||||
|
||||
Beug uses public Stripe Checkout or Payment Link URLs, supplied through environment variables. Do not put Stripe secret keys in this Vite app.
|
||||
|
||||
Payments are behind a launch-mode flag:
|
||||
|
||||
```bash
|
||||
VITE_PAYMENTS_ENABLED=false
|
||||
```
|
||||
|
||||
When `VITE_PAYMENTS_ENABLED` is absent or `false`, the app runs in Reddit/free mode: all lessons are usable, paid rows are not blurred, and the paywall/pricing screen is hidden. The Stripe URLs can stay configured in the environment so billing can be switched back on later with one env change.
|
||||
|
||||
To turn payments back on, set:
|
||||
|
||||
```bash
|
||||
VITE_PAYMENTS_ENABLED=true
|
||||
```
|
||||
|
||||
Create one product in Stripe, for example `Beug Premium`, with three prices:
|
||||
|
||||
- Weekly subscription: `$2.99` every week
|
||||
@@ -68,3 +82,9 @@ VITE_STRIPE_WEEKLY_URL=https://buy.stripe.com/...
|
||||
```
|
||||
|
||||
The current v1 unlock is intentionally simple: after Stripe redirects back with `?checkout=success`, Beug stores the unlock in this browser's localStorage. This avoids accounts for the tiny-app version, but it is a soft paywall. A stricter version needs a small backend, Stripe webhooks, and account or email-based entitlement lookup.
|
||||
|
||||
## Future prompt to re-enable payments
|
||||
|
||||
```text
|
||||
Turn payments back on for Beug. Set VITE_PAYMENTS_ENABLED=true in Coolify, keep the three existing Stripe Payment Link env vars, redeploy the app, and verify that unpaid users see the soft paid lesson blur, that charts remain visible, and that tapping a paid lesson opens the pricing screen with Weekly, Yearly, and Lifetime plans.
|
||||
```
|
||||
|
||||
+6
-4
@@ -233,6 +233,7 @@ const TABS = [
|
||||
|
||||
const FREE_LEVEL_IDS = new Set([1, 2, 3, 4, 8, 9, 10, 18]);
|
||||
const CORE_ARTICLE_CASES = ['nominative', 'accusative', 'dative'];
|
||||
const PAYMENTS_ENABLED = String(import.meta.env.VITE_PAYMENTS_ENABLED || 'false').toLowerCase() === 'true';
|
||||
const STRIPE_PLANS = [
|
||||
{
|
||||
id:'weekly',
|
||||
@@ -662,8 +663,9 @@ export default function App() {
|
||||
await Storage.set(s);
|
||||
},[]);
|
||||
|
||||
const hasAccess = !!access?.paid;
|
||||
const gated = id => !hasAccess && !FREE_LEVEL_IDS.has(id);
|
||||
const hasPaidAccess = !!access?.paid;
|
||||
const hasAccess = !PAYMENTS_ENABLED || hasPaidAccess;
|
||||
const gated = id => PAYMENTS_ENABLED && !hasPaidAccess && !FREE_LEVEL_IDS.has(id);
|
||||
|
||||
const unlocked = (id) => {
|
||||
return !gated(id);
|
||||
@@ -769,7 +771,7 @@ export default function App() {
|
||||
: <div style={S.logo}>Beug</div>}
|
||||
<div style={{display:'flex',gap:14,alignItems:'center'}}>
|
||||
{scr === 'practice' && <button style={S.linkBtn} onClick={()=>setChart(true)}>charts</button>}
|
||||
{hasAccess && <span style={S.stat}>Unlocked</span>}
|
||||
{PAYMENTS_ENABLED && hasPaidAccess && <span style={S.stat}>Unlocked</span>}
|
||||
<span style={S.stat}>🔥 {st.streak||0}</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -831,7 +833,7 @@ export default function App() {
|
||||
)}
|
||||
|
||||
{/* PAYWALL */}
|
||||
{scr === 'paywall' && (
|
||||
{PAYMENTS_ENABLED && scr === 'paywall' && (
|
||||
<PaywallScreen
|
||||
message={payMsg}
|
||||
onCheckout={openCheckout}
|
||||
|
||||
Reference in New Issue
Block a user