mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-13 02:53:50 +00:00
feat(#22): Hi Olly
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
redirectTo: '/account'
|
||||
}
|
||||
});
|
||||
console.log(data, error);
|
||||
console.log(data);
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
@@ -50,17 +50,19 @@
|
||||
email
|
||||
})
|
||||
.then(async (customer) => {
|
||||
console.log(customer);
|
||||
const response = await supabase
|
||||
.from('customers')
|
||||
.update({
|
||||
customer_id: customer.id
|
||||
})
|
||||
.match({
|
||||
id: data.user.id
|
||||
});
|
||||
// Create a new customer in the database customers table with id data.user.id and stripe_customer_id customer.id
|
||||
const { dataFromUpsert, error } = await supabase.from('customers').upsert([
|
||||
{
|
||||
id: data.user.id,
|
||||
stripe_customer_id: customer.id
|
||||
}
|
||||
]);
|
||||
|
||||
console.log(response);
|
||||
console.log(dataFromUpsert);
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -55,14 +55,14 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||
case 'product.deleted':
|
||||
await deleteProductRecord(event.data.object as stripe.Product);
|
||||
break;
|
||||
case 'customer.created':
|
||||
case 'customer.updated':
|
||||
// TODO - this should be passing the supabase customer uuid not the stripe customer id
|
||||
await createOrRetrieveCustomer({
|
||||
email: (event.data.object as stripe.Customer).email!,
|
||||
uuid: event.data.object.id
|
||||
});
|
||||
break;
|
||||
// case 'customer.created':
|
||||
// case 'customer.updated':
|
||||
// // TODO - this should be passing the supabase customer uuid not the stripe customer id
|
||||
// await createOrRetrieveCustomer({
|
||||
// email: (event.data.object as stripe.Customer).email!,
|
||||
// uuid: event.data.object.id
|
||||
// });
|
||||
// break;
|
||||
case 'customer.subscription.created':
|
||||
case 'customer.subscription.updated':
|
||||
case 'customer.subscription.deleted': {
|
||||
|
||||
Reference in New Issue
Block a user