fix(billing) - enable upgrade if invoice already paid (#21450)

Had an issue concerning a user with credits, then invoice automatically
paid. Upgrade failed
This commit is contained in:
Etienne
2026-06-11 14:45:01 +02:00
committed by GitHub
parent 7da6f25aaf
commit a6fcbf58e4
@@ -68,9 +68,22 @@ export class StripeInvoiceService {
});
await this.stripe.invoices.finalizeInvoice(invoice.id, {
auto_advance: false,
auto_advance: true,
});
await this.stripe.invoices.pay(invoice.id);
try {
await this.stripe.invoices.pay(invoice.id);
} catch (error) {
// With auto_advance Stripe may already have collected payment by the time
// we explicitly request it. Only swallow that case, rethrow real failures.
if (
!(
error instanceof this.stripe.errors.StripeInvalidRequestError &&
error.code === 'invoice_already_paid'
)
) {
throw error;
}
}
}
}