mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-13 19:13:48 +00:00
Merge branch 'master' into 11-add-the-description-and-fetching-the-images-from-stripe-on-checkout-success-page
This commit is contained in:
@@ -2,7 +2,7 @@ import { redirect } from '@sveltejs/kit';
|
||||
import Stripe from 'stripe';
|
||||
import { getProductById } from '$lib/utils/supabase/admin';
|
||||
|
||||
export const load = async ({ fetch }) => {
|
||||
export const load: PageLoad = async ({ fetch }) => {
|
||||
const response = await fetch('/api/checkout/status');
|
||||
if (!response.ok) {
|
||||
console.error('Failed to fetch checkout status');
|
||||
@@ -24,6 +24,15 @@ export const load = async ({ fetch }) => {
|
||||
lineItem.productDescription = product.description ?? '';
|
||||
}
|
||||
|
||||
// Save the stripe customer id in the customers table
|
||||
const stripeCustomerId = checkoutSession.customer as string;
|
||||
const createCustomerResponse = await fetch(
|
||||
'/api/checkout/create-customer?stripeCustomerId=' + stripeCustomerId
|
||||
);
|
||||
if (!createCustomerResponse.ok) {
|
||||
console.error('Failed to create customer');
|
||||
}
|
||||
|
||||
return {
|
||||
checkoutSession,
|
||||
lineItems
|
||||
|
||||
Reference in New Issue
Block a user