File tree Expand file tree Collapse file tree
apps/web/app/(ee)/api/stripe/webhook Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ export async function customerSubscriptionUpdated(
1616 return `Invalid price ID in customer.subscription.updated event: ${ priceId } ` ;
1717 }
1818
19+ if ( ! [ "active" , "trialing" ] . includes ( updatedSubscription . status ) ) {
20+ return `Invalid updated subscription status "${ updatedSubscription . status } " for subscription ${ updatedSubscription . id } , skipping...` ;
21+ }
22+
1923 const stripeId = updatedSubscription . customer . toString ( ) ;
2024
2125 const workspace = await prisma . project . findUnique ( {
@@ -57,12 +61,7 @@ export async function customerSubscriptionUpdated(
5761 subscription : updatedSubscription ,
5862 } ) ;
5963
60- const subscriptionCanceled =
61- ( updatedSubscription . status === "active" ||
62- updatedSubscription . status === "trialing" ) &&
63- updatedSubscription . cancel_at_period_end ;
64-
65- if ( subscriptionCanceled ) {
64+ if ( updatedSubscription . cancel_at_period_end ) {
6665 const owners = workspace . users . map ( ( { user } ) => user ) ;
6766 const cancelReason = updatedSubscription . cancellation_details ?. feedback ;
6867
You can’t perform that action at this time.
0 commit comments