diff --git a/basic-app/src/index.ts b/basic-app/src/index.ts index 65f79e2..354eeac 100644 --- a/basic-app/src/index.ts +++ b/basic-app/src/index.ts @@ -51,7 +51,7 @@ app.get('/success', (c) => { }) app.get('/cancel', (c) => { - return c.text('Hello Hono!') + return c.text('Cancelled!') }) @@ -63,7 +63,7 @@ app.post('/checkout', async (c) => { payment_method_types: ['card'], line_items: [ { - price: 'price_1OqkU6BF7AptWZlcpIINrWBU', + price: 'price_XXXXXXXXXXXXXX', quantity: 1, }, ], @@ -94,7 +94,7 @@ app.post('/subscribe', async (c) => { ], mode: 'subscription', success_url: 'http://localhost:3000/success', - cancel_url: 'http://localhost:3000//cancel', + cancel_url: 'http://localhost:3000/cancel', }); return c.json(session); @@ -150,9 +150,10 @@ app.post('/webhook', async (c) => { const port = 3000 -console.log(`Server is running on port ${port}`) serve({ fetch: app.fetch, port -}) \ No newline at end of file +}, (info) => { + console.log(`Server is running on port ${info.port}`) +}) diff --git a/next-app/app/api/checkout/route.ts b/next-app/app/api/checkout/route.ts index 238cff0..2eac648 100644 --- a/next-app/app/api/checkout/route.ts +++ b/next-app/app/api/checkout/route.ts @@ -18,7 +18,7 @@ export async function POST(request: Request) { }, { // one-time setup fee - price: 'price_1OtHdOBF7AptWZlcPmLotZgW', + price: 'price_XXXXXXXXXXXXXXXXXXXX', quantity: 1, }, ], @@ -29,7 +29,7 @@ export async function POST(request: Request) { return NextResponse.json({ id: session.id, client_secret: session.client_secret }); } catch (error: any) { - console.error(error); + console.error(error); return NextResponse.json({ message: error.message }, { status: 500 }); } } diff --git a/next-app/app/api/embedded-checkout/route.ts b/next-app/app/api/embedded-checkout/route.ts index 5ff8a1f..c65af46 100644 --- a/next-app/app/api/embedded-checkout/route.ts +++ b/next-app/app/api/embedded-checkout/route.ts @@ -28,7 +28,7 @@ export async function POST(request: Request) { return NextResponse.json({ id: session.id, client_secret: session.client_secret }); } catch (error: any) { - console.error(error); + console.error(error); return NextResponse.json({ message: error.message }, { status: 500 }); } } @@ -47,7 +47,7 @@ export async function GET(request: Request) { return NextResponse.json({ session }); } catch (error: any) { - console.error(error); + console.error(error); return NextResponse.json({ message: error.message }, { status: 500 }); } } \ No newline at end of file diff --git a/next-app/app/api/usage-meter/route.ts b/next-app/app/api/usage-meter/route.ts index 9718095..38ad744 100644 --- a/next-app/app/api/usage-meter/route.ts +++ b/next-app/app/api/usage-meter/route.ts @@ -52,8 +52,10 @@ export async function POST(request: Request) { console.log(usageRecord); - - return NextResponse.json({ message: 'Usage record created successfully!', total_downloads: customer.total_downloads + 1 }, { status: 200 }); + return NextResponse.json({ + message: 'Usage record created successfully!', + total_downloads: customer.total_downloads + 1 + }, { status: 200 }); } catch (error: any) { diff --git a/next-app/app/api/webhook/route.ts b/next-app/app/api/webhook/route.ts index cf73bf0..dc57450 100644 --- a/next-app/app/api/webhook/route.ts +++ b/next-app/app/api/webhook/route.ts @@ -24,8 +24,8 @@ export async function POST(request: NextRequest) { // Create or update the stripe_customer_id in the stripe_customers table const { error } = await supabaseAdmin - .from('stripe_customers') - .upsert({ user_id: userId, stripe_customer_id: session.customer, subscription_id: session.subscription, plan_active: true, plan_expires: null }) + .from('stripe_customers') + .upsert({ user_id: userId, stripe_customer_id: session.customer, subscription_id: session.subscription, plan_active: true, plan_expires: null }) } @@ -45,9 +45,9 @@ export async function POST(request: NextRequest) { console.log(subscription); const { error } = await supabaseAdmin - .from('stripe_customers') - .update({ plan_active: false, subscription_id: null }) - .eq('subscription_id', subscription.id); + .from('stripe_customers') + .update({ plan_active: false, subscription_id: null }) + .eq('subscription_id', subscription.id); } return NextResponse.json({ statusCode: 200, message: 'success' });