The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(billing) - enable upgrade if invoice already paid (#21450)
Etiennea6fcbf58e418
diff --git a/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-invoice.service.ts b/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-invoice.service.tsindex f91b4807acb..76c29d43083 100644--- a/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-invoice.service.ts+++ b/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-invoice.service.ts@@ -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;+ }+ }}}