Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/checkout/payment/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function POST(request: Request) {
return NextResponse.json({ error: 'Sorry, tickets are sold out.', code: 'SOLD_OUT' }, { status: 409 });
}

if (isMockKey(process.env.Stripe_CHANEL_SECRET)) {
if (isMockKey(process.env.Stripe_CHANNEL_SECRET)) {
const orderId = `NV2026-${Date.now().toString(36).toUpperCase()}`;
return NextResponse.json({
success: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let _stripe: Stripe | null = null;

export function getStripe(): Stripe {
if (!_stripe) {
const stripeSecretKey = process.env.Stripe_CHANEL_SECRET;
const stripeSecretKey = process.env.Stripe_CHANNEL_SECRET;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The environment variable Stripe_CHANNEL_SECRET might be undefined at runtime. Using a non-null assertion (!) on the next line without a guard check can lead to runtime errors that are difficult to debug. It is safer to explicitly check for its existence and throw a descriptive error if it is missing.

Suggested change
const stripeSecretKey = process.env.Stripe_CHANNEL_SECRET;
const stripeSecretKey = process.env.Stripe_CHANNEL_SECRET;
if (!stripeSecretKey) {
throw new Error('Stripe_CHANNEL_SECRET environment variable is missing');
}

_stripe = new Stripe(stripeSecretKey!, {
apiVersion: '2026-03-25.dahlia',
});
Expand Down