Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo, correct styling #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 6 additions & 5 deletions basic-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ app.get('/success', (c) => {
})

app.get('/cancel', (c) => {
return c.text('Hello Hono!')
return c.text('Cancelled!')
})


Expand All @@ -63,7 +63,7 @@ app.post('/checkout', async (c) => {
payment_method_types: ['card'],
line_items: [
{
price: 'price_1OqkU6BF7AptWZlcpIINrWBU',
price: 'price_XXXXXXXXXXXXXX',
quantity: 1,
},
],
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
})
}, (info) => {
console.log(`Server is running on port ${info.port}`)
})
4 changes: 2 additions & 2 deletions next-app/app/api/checkout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function POST(request: Request) {
},
{
// one-time setup fee
price: 'price_1OtHdOBF7AptWZlcPmLotZgW',
price: 'price_XXXXXXXXXXXXXXXXXXXX',
quantity: 1,
},
],
Expand All @@ -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 });
}
}
4 changes: 2 additions & 2 deletions next-app/app/api/embedded-checkout/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({ 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 });
}
}
Expand All @@ -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 });
}
}
6 changes: 4 additions & 2 deletions next-app/app/api/usage-meter/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions next-app/app/api/webhook/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })


}
Expand All @@ -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' });
Expand Down