Skip to content

Commit

Permalink
Merge pull request #5172 from FlowFuse/allow-suspend-on-expired-subsc…
Browse files Browse the repository at this point in the history
…ription

Allow team suspend when subscription has expired
  • Loading branch information
hardillb authored Feb 24, 2025
2 parents d4a29de + 74b3bc1 commit decd2d5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions forge/ee/lib/billing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,18 @@ module.exports.init = async function (app) {
closeSubscription: async (subscription) => {
if (subscription.subscription) {
app.log.info(`Canceling subscription ${subscription.subscription} for team ${subscription.Team.hashid}`)

await stripe.subscriptions.del(subscription.subscription, {
invoice_now: true,
prorate: true
})
try {
await stripe.subscriptions.del(subscription.subscription, {
invoice_now: true,
prorate: true
})
} catch (err) {
// resource_missing error is okay - that means the subscription cannot be found
// and we can ignore it
if (err.code !== 'resource_missing') {
throw err
}
}
}
subscription.status = app.db.models.Subscription.STATUS.CANCELED
await subscription.save()
Expand Down

0 comments on commit decd2d5

Please sign in to comment.