File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -633,8 +633,17 @@ export async function handleStripeEvent({
633633 return ;
634634 }
635635 case "customer.updated" : {
636- const customer = data . object as Stripe . Customer ;
637- await updateSubscriptionsFromCustomer ( customer . id ) ;
636+ // Only update from customer if the "default_payment_method" changes,
637+ // for everything else we will get a "customer.subscription.updated".
638+ if (
639+ data . previous_attributes &&
640+ "invoice_settings" in data . previous_attributes &&
641+ data . previous_attributes . invoice_settings &&
642+ "default_payment_method" in data . previous_attributes . invoice_settings
643+ ) {
644+ const customer = data . object as Stripe . Customer ;
645+ await updateSubscriptionsFromCustomer ( customer . id ) ;
646+ }
638647 return ;
639648 }
640649
You can’t perform that action at this time.
0 commit comments