From ceec0e4cdd5e025f1604a2f976e53cc524cc6bbb Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 18 Mar 2025 13:09:21 -0500 Subject: [PATCH] Website: Update stripe webhook (#27241) Changes: - updated the stripe webhook to support `invoice.paid` events when a subscription's host count is not increased. --- website/api/controllers/webhooks/receive-from-stripe.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/api/controllers/webhooks/receive-from-stripe.js b/website/api/controllers/webhooks/receive-from-stripe.js index e423516e0e..5f4f1d41d8 100644 --- a/website/api/controllers/webhooks/receive-from-stripe.js +++ b/website/api/controllers/webhooks/receive-from-stripe.js @@ -177,6 +177,10 @@ module.exports = { // e.g., 'Remaining time on 9 × Fleet premium hosts after 17 Feb 2024' return _.startsWith(item.description, 'Remaining'); }); + // If this no line item that starts with "Remaining" was found, select the first line item on the invoice. + if(!updatedSubscriptionInfo){ + updatedSubscriptionInfo = itemsOnThisInvoice[0]; + } // Convert the subscription cycle's period end timestamp from Stripe into a JS timestamp. // Note: with most subscription changes, this value will be indentical to the existing license key's expiration // timestamp. We do this here to handle situations where the subscription period has been adjusted in the Stripe UI.