Skip to content

Commit 3a980ed

Browse files
GeneAIGeneAI
authored andcommitted
fix: Add hardcoded fallbacks for Stripe price IDs and site URL
1 parent 9de7138 commit 3a980ed

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

website/app/api/stripe/checkout/route.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function getStripe(): Stripe {
1414
return stripe;
1515
}
1616

17+
// Fallback site URL in case env var is not set
18+
const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://smartaimemory.com';
19+
1720
export async function POST(req: NextRequest) {
1821
try {
1922
const { priceId, mode, customerEmail, successUrl, cancelUrl } = await req.json();
@@ -22,6 +25,11 @@ export async function POST(req: NextRequest) {
2225
return NextResponse.json({ error: 'Price ID is required' }, { status: 400 });
2326
}
2427

28+
// Validate priceId is not a placeholder
29+
if (priceId.includes('placeholder')) {
30+
return NextResponse.json({ error: 'Product not configured. Please contact support.' }, { status: 400 });
31+
}
32+
2533
const session = await getStripe().checkout.sessions.create({
2634
mode: mode || 'payment', // 'payment' for one-time, 'subscription' for recurring
2735
payment_method_types: ['card'],
@@ -31,8 +39,8 @@ export async function POST(req: NextRequest) {
3139
quantity: 1,
3240
},
3341
],
34-
success_url: successUrl || `${process.env.NEXT_PUBLIC_SITE_URL}/success?session_id={CHECKOUT_SESSION_ID}`,
35-
cancel_url: cancelUrl || `${process.env.NEXT_PUBLIC_SITE_URL}/pricing`,
42+
success_url: successUrl || `${SITE_URL}/success?session_id={CHECKOUT_SESSION_ID}`,
43+
cancel_url: cancelUrl || `${SITE_URL}/pricing`,
3644
customer_email: customerEmail || undefined,
3745
allow_promotion_codes: true,
3846
billing_address_collection: 'required',

website/app/book/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Link from 'next/link';
22
import CheckoutButton from '@/components/CheckoutButton';
33

4-
// Price ID from Stripe Dashboard - update after creating product
5-
const BOOK_PRICE_ID = process.env.NEXT_PUBLIC_STRIPE_PRICE_BOOK || 'price_book_placeholder';
4+
// Price ID from Stripe Dashboard - hardcoded fallback for build-time reliability
5+
const BOOK_PRICE_ID = process.env.NEXT_PUBLIC_STRIPE_PRICE_BOOK || 'price_1Sbf3xAbABKRT84gGn7yaivw';
66

77
export default function BookPage() {
88
return (

website/app/pricing/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import Footer from '@/components/Footer';
55
import { generateMetadata } from '@/lib/metadata';
66
import CheckoutButton from '@/components/CheckoutButton';
77

8-
// Price ID from Stripe Dashboard - update after creating product
9-
const LICENSE_PRICE_ID = process.env.NEXT_PUBLIC_STRIPE_PRICE_LICENSE || 'price_license_placeholder';
8+
// Price ID from Stripe Dashboard - hardcoded fallback for build-time reliability
9+
const LICENSE_PRICE_ID = process.env.NEXT_PUBLIC_STRIPE_PRICE_LICENSE || 'price_1SbfCjAbABKRT84gSh7BoLAl';
1010

1111
export const metadata: Metadata = generateMetadata({
1212
title: 'Pricing',

0 commit comments

Comments
 (0)