feat(#22): Hi Olly

This commit is contained in:
Josh Creek
2024-07-16 20:23:22 +01:00
parent 18772364f7
commit 4d80534244
2 changed files with 21 additions and 19 deletions
+13 -11
View File
@@ -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>
+8 -8
View File
@@ -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': {