Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(billing): hide invalid payment method error for invoice/wire-transfer customers (#12659)

Steffen Schmitz19145198e9b7
diff --git a/web/src/ee/features/billing/server/stripeBillingService.ts b/web/src/ee/features/billing/server/stripeBillingService.ts
index 6fe82646d8..2f823ace0a 100644
--- a/web/src/ee/features/billing/server/stripeBillingService.ts
+++ b/web/src/ee/features/billing/server/stripeBillingService.ts
@@ -500,38 +500,44 @@ class BillingService {
.filter((d) => d !== null);
// Check if customer has a valid payment method
+ // Invoice/wire-transfer customers don't need a card on file —
+ // only check payment methods for auto-charge subscriptions
let hasValidPaymentMethod = false;
- try {
- const customerId =
- typeof subscription.customer === "string"
- ? subscription.customer
- : subscription.customer.id;
-
- const paymentMethods = await client.customers.listPaymentMethods(
- customerId,
- { limit: 1 },
- );
+ if (subscription.collection_method === "send_invoice") {
+ hasValidPaymentMethod = true;
+ } else {
+ try {
+ const customerId =
+ typeof subscription.customer === "string"
+ ? subscription.customer
+ : subscription.customer.id;
+
+ const paymentMethods = await client.customers.listPaymentMethods(
+ customerId,
+ { limit: 1 },
+ );
- hasValidPaymentMethod = paymentMethods.data.length > 0;
- } catch (error) {
- logger.error(
- "StripeBillingService.getSubscriptionInfo:failed to check payment method",
- {
- userId: this.ctx.session.user?.id,
- userEmail: this.ctx.session.user?.email,
- customerId:
- typeof subscription.customer === "string"
- ? subscription.customer
- : subscription.customer.id,
- subscriptionId:
- parsedOrg.cloudConfig?.stripe?.activeSubscriptionId,
- orgId: parsedOrg.id,
- error,
- },
- );
- traceException(error);
- // Default to false if there's an error checking
- hasValidPaymentMethod = false;
+ hasValidPaymentMethod = paymentMethods.data.length > 0;
+ } catch (error) {
+ logger.error(
+ "StripeBillingService.getSubscriptionInfo:failed to check payment method",
+ {
+ userId: this.ctx.session.user?.id,
+ userEmail: this.ctx.session.user?.email,
+ customerId:
+ typeof subscription.customer === "string"
+ ? subscription.customer
+ : subscription.customer.id,
+ subscriptionId:
+ parsedOrg.cloudConfig?.stripe?.activeSubscriptionId,
+ orgId: parsedOrg.id,
+ error,
+ },
+ );
+ traceException(error);
+ // Default to false if there's an error checking
+ hasValidPaymentMethod = false;
+ }
}
return {