From a8ea9e6d384178724b2a0c4fb31d10b4c74cb96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrew=20Beveridge=20=E2=98=84=EF=B8=8F?= Date: Mon, 2 Mar 2026 00:04:22 -0500 Subject: [PATCH] feat: in-app Buy Credits dialog and pricing updates (#434) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Fix broken "Buy More Credits" flow for logged-in users — replaces redirect (which bounced back to `/app`) with an in-app dialog - Add `BuyCreditsDialog` component following the existing `FeedbackDialog` pattern - Make credits count in header clickable to open the buy dialog - Update "Made For You" pricing from $15 to $50 (frontend labels + Stripe backend) - Update hero section: "Create It Yourself ($5)", green "2 free credits" message, remove redundant line, tighten spacing ## Test plan - [ ] Log in, click "Buy More Credits" in dropdown — dialog opens with package grid - [ ] Click credits count in header — same dialog opens - [ ] Select package, click "Continue to Payment" — redirects to Stripe checkout - [ ] Landing page pricing still works for unauthenticated users - [ ] Made For You order form shows $50 pricing - [ ] Hero section shows updated copy and tighter spacing 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 --- backend/services/stripe_service.py | 2 +- frontend/app/page.tsx | 17 +-- frontend/components/auth/AuthStatus.tsx | 22 ++- .../components/credits/BuyCreditsDialog.tsx | 144 ++++++++++++++++++ pyproject.toml | 2 +- scripts/test_stripe_checkout.py | 2 +- 6 files changed, 169 insertions(+), 20 deletions(-) create mode 100644 frontend/components/credits/BuyCreditsDialog.tsx diff --git a/backend/services/stripe_service.py b/backend/services/stripe_service.py index 566bf131..49ac022c 100644 --- a/backend/services/stripe_service.py +++ b/backend/services/stripe_service.py @@ -48,7 +48,7 @@ CREDIT_PACKAGES = { # Made-for-you service package (not a credit package - creates a job directly) MADE_FOR_YOU_PACKAGE = { - "price_cents": 1500, # $15.00 + "price_cents": 5000, # $50.00 "name": "Made For You Karaoke Video", "description": "Professional 4K karaoke video with perfectly synced lyrics, delivered to your email within 24 hours", "images": ["https://gen.nomadkaraoke.com/nomad-logo.png"], diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 8864aa77..b4b9660e 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -212,7 +212,7 @@ export default function LandingPage() { {/* Hero Section */} -
+

Create a Karaoke Video for Any Song @@ -231,9 +231,9 @@ export default function LandingPage() { >

We'll Make It For You - $15 + $50 We handle everything, delivered in 24h
-

- Every account includes 2 free credits — no payment required -

@@ -529,7 +526,7 @@ export default function LandingPage() {

We'll Make It For You

Don't want to use the Generator and review the lyrics yourself? No problem. - Tell us the song, pay $15, and we'll deliver your karaoke video within 24 hours. + Tell us the song, pay $50, and we'll deliver your karaoke video within 24 hours.

Don't want to spend 10 minutes reviewing lyrics? For just $10 more than DIY, we handle everything. @@ -624,7 +621,7 @@ export default function LandingPage() {

Order a Video

-
$15
+
$50
@@ -774,7 +771,7 @@ export default function LandingPage() { ) : ( <> - Pay $15 & Order + Pay $50 & Order )} diff --git a/frontend/components/auth/AuthStatus.tsx b/frontend/components/auth/AuthStatus.tsx index 8d7bd31f..4c87e89d 100644 --- a/frontend/components/auth/AuthStatus.tsx +++ b/frontend/components/auth/AuthStatus.tsx @@ -17,6 +17,7 @@ import { useAuth } from "@/lib/auth" import { useAdminSettings } from "@/lib/admin-settings" import { AuthDialog } from "./AuthDialog" import { FeedbackDialog } from "@/components/feedback/FeedbackDialog" +import { BuyCreditsDialog } from "@/components/credits/BuyCreditsDialog" interface AuthStatusProps { onAuthChange?: () => void @@ -27,6 +28,7 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) { const { showTestData, setShowTestData } = useAdminSettings() const [showAuthDialog, setShowAuthDialog] = useState(false) const [showFeedbackDialog, setShowFeedbackDialog] = useState(false) + const [showBuyCreditsDialog, setShowBuyCreditsDialog] = useState(false) const [mounted, setMounted] = useState(false) // Avoid hydration mismatch @@ -47,12 +49,7 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) { } const handleBuyCredits = () => { - // Navigate to landing page pricing section with email prefilled if available - const buyUrl = new URL('/#pricing', window.location.origin) - if (user?.email) { - buyUrl.searchParams.set("email", user.email) - } - window.location.href = buyUrl.toString() + setShowBuyCreditsDialog(true) } // Don't render until mounted (avoids hydration issues) @@ -74,7 +71,14 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) { {user.display_name || user.email} - + { + e.stopPropagation() + handleBuyCredits() + }} + className="flex items-center gap-1 text-warning font-medium hover:text-warning/80 transition-colors cursor-pointer" + title="Buy more credits" + > {user.credits} {user.credits === 1 ? 'credit' : 'credits'} @@ -150,6 +154,10 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) { open={showFeedbackDialog} onClose={() => setShowFeedbackDialog(false)} /> + setShowBuyCreditsDialog(false)} + /> ) } diff --git a/frontend/components/credits/BuyCreditsDialog.tsx b/frontend/components/credits/BuyCreditsDialog.tsx new file mode 100644 index 00000000..1b4a3d77 --- /dev/null +++ b/frontend/components/credits/BuyCreditsDialog.tsx @@ -0,0 +1,144 @@ +'use client' + +import { useState, useEffect } from 'react' +import { CreditCard, Loader2 } from 'lucide-react' +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog' +import { Button } from '@/components/ui/button' +import { api, CreditPackage } from '@/lib/api' +import { useAuth } from '@/lib/auth' + +interface BuyCreditsDialogProps { + open: boolean + onClose: () => void +} + +const formatPrice = (cents: number) => `$${(cents / 100).toFixed(0)}` +const pricePerVideo = (pkg: CreditPackage) => + `$${(pkg.price_cents / 100 / pkg.credits).toFixed(2)}` + +export function BuyCreditsDialog({ open, onClose }: BuyCreditsDialogProps) { + const { user } = useAuth() + const [packages, setPackages] = useState([]) + const [selectedPackage, setSelectedPackage] = useState(null) + const [loading, setLoading] = useState(false) + const [checkoutLoading, setCheckoutLoading] = useState(false) + const [error, setError] = useState('') + + useEffect(() => { + if (!open) return + setError('') + setLoading(true) + api.getCreditPackages() + .then((pkgs) => { + setPackages(pkgs) + // Pre-select best value package (5 credits) or first + const bestValue = pkgs.find((p) => p.credits === 5) || pkgs[0] + setSelectedPackage(bestValue) + }) + .catch((err) => { + setError(err instanceof Error ? err.message : 'Failed to load packages') + }) + .finally(() => setLoading(false)) + }, [open]) + + const handleCheckout = async () => { + if (!selectedPackage || !user?.email) return + setCheckoutLoading(true) + setError('') + try { + const checkoutUrl = await api.createCheckout(selectedPackage.id, user.email) + window.location.href = checkoutUrl + } catch (err) { + setError(err instanceof Error ? err.message : 'Failed to create checkout session') + setCheckoutLoading(false) + } + } + + return ( + !isOpen && onClose()}> + + + + + Buy More Credits + + + Each credit creates one karaoke video. Pick a package below. + + + +
+ {loading && ( +
+ +
+ )} + + {error && ( +
{error}
+ )} + + {!loading && !error && packages.length > 0 && ( + <> +
+ {packages.map((pkg) => { + const isSelected = selectedPackage?.id === pkg.id + const isBestValue = pkg.credits === 5 + const savings = pkg.credits > 1 + ? Math.round((1 - pkg.price_cents / (pkg.credits * 500)) * 100) + : 0 + + return ( + + ) + })} +
+ + + + )} +
+
+
+ ) +} diff --git a/pyproject.toml b/pyproject.toml index 4c0fc927..eea0669b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "karaoke-gen" -version = "0.121.0" +version = "0.122.0" description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens." authors = ["Andrew Beveridge "] license = "MIT" diff --git a/scripts/test_stripe_checkout.py b/scripts/test_stripe_checkout.py index bfd3c005..f94ff180 100755 --- a/scripts/test_stripe_checkout.py +++ b/scripts/test_stripe_checkout.py @@ -130,7 +130,7 @@ def create_made_for_you_checkout( 'description': "Professional 4K karaoke video with perfectly synced lyrics", 'images': ['https://gen.nomadkaraoke.com/nomad-logo.png'], }, - 'unit_amount': 1500, # $15.00 + 'unit_amount': 5000, # $50.00 }, 'quantity': 1, }],