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:
+15
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user