Skip to content

Commit f8a4f81

Browse files
authored
fix stripe customer.subscription.deleted-webhook (#811)
1 parent e684824 commit f8a4f81

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ee/pages/api/integrations/stripepayment/webhook.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ type WebhookHandler = (event: Stripe.Event) => Promise<void>;
102102
const webhookHandlers: Record<string, WebhookHandler | undefined> = {
103103
"payment_intent.succeeded": handlePaymentSuccess,
104104
"customer.subscription.deleted": async (event) => {
105-
const data = event.data as Stripe.Subscription;
105+
const object = event.data.object as Stripe.Subscription;
106106

107-
const customerId = typeof data.customer === "string" ? data.customer : data.customer.id;
107+
const customerId = typeof object.customer === "string" ? object.customer : object.customer.id;
108108

109109
const customer = (await stripe.customers.retrieve(customerId)) as Stripe.Customer;
110110
if (typeof customer.email !== "string") {
111-
throw new Error(`Couldn't find customer email for ${data.customer}`);
111+
throw new Error(`Couldn't find customer email for ${customerId}`);
112112
}
113113

114114
await prisma.user.update({

0 commit comments

Comments
 (0)