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' redirectTo: '/account'
} }
}); });
console.log(data, error); console.log(data);
if (error) { if (error) {
throw error; throw error;
@@ -50,17 +50,19 @@
email email
}) })
.then(async (customer) => { .then(async (customer) => {
console.log(customer); // Create a new customer in the database customers table with id data.user.id and stripe_customer_id customer.id
const response = await supabase const { dataFromUpsert, error } = await supabase.from('customers').upsert([
.from('customers') {
.update({ id: data.user.id,
customer_id: customer.id stripe_customer_id: customer.id
}) }
.match({ ]);
id: data.user.id
});
console.log(response); console.log(dataFromUpsert);
if (error) {
throw error;
}
}); });
} }
</script> </script>
+8 -8
View File
@@ -55,14 +55,14 @@ export const POST: RequestHandler = async ({ request }) => {
case 'product.deleted': case 'product.deleted':
await deleteProductRecord(event.data.object as stripe.Product); await deleteProductRecord(event.data.object as stripe.Product);
break; break;
case 'customer.created': // case 'customer.created':
case 'customer.updated': // case 'customer.updated':
// TODO - this should be passing the supabase customer uuid not the stripe customer id // // TODO - this should be passing the supabase customer uuid not the stripe customer id
await createOrRetrieveCustomer({ // await createOrRetrieveCustomer({
email: (event.data.object as stripe.Customer).email!, // email: (event.data.object as stripe.Customer).email!,
uuid: event.data.object.id // uuid: event.data.object.id
}); // });
break; // break;
case 'customer.subscription.created': case 'customer.subscription.created':
case 'customer.subscription.updated': case 'customer.subscription.updated':
case 'customer.subscription.deleted': { case 'customer.subscription.deleted': {