Merge pull request #23203 from overleaf/ii-flexible-group-licensing-no-billing-details

[web] FL handle subscriptions with missing billing info

GitOrigin-RevId: 34209299c039992a80da5739e086beb5d0ede7b0
This commit is contained in:
ilkin-overleaf
2025-02-04 13:53:14 +02:00
committed by Copybot
parent 72be034435
commit 16130b79db
14 changed files with 242 additions and 2 deletions
@@ -16,6 +16,7 @@ const {
RecurlyPlan,
RecurlyImmediateCharge,
} = require('./RecurlyEntities')
const { MissingBillingInfoError } = require('./Errors')
/**
* @import { RecurlySubscriptionChangeRequest } from './RecurlyEntities'
@@ -193,7 +194,19 @@ async function resumeSubscriptionByUuid(subscriptionUuid) {
* @return {Promise<PaymentMethod>}
*/
async function getPaymentMethod(userId) {
const billingInfo = await client.getBillingInfo(`code-${userId}`)
let billingInfo
try {
billingInfo = await client.getBillingInfo(`code-${userId}`)
} catch (error) {
if (error instanceof recurly.errors.NotFoundError) {
throw new MissingBillingInfoError('This account has no billing info', {
userId,
})
}
throw error
}
return paymentMethodFromApi(billingInfo)
}