From 72e557346c935973a426efc9930de5f1e86e6fd7 Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Mon, 16 Feb 2026 20:21:31 -0600 Subject: [PATCH] fix: attach payment method to customer before creating subscription Stripe requires payment methods to be attached to a customer before they can be set as default_payment_method on a subscription. The createSubscription() method was skipping this step, causing 500 errors on checkout with: "The customer does not have a payment method with the ID pm_xxx". Co-Authored-By: Claude Opus 4.6 --- .../subscriptions/external/stripe/stripe.client.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/features/subscriptions/external/stripe/stripe.client.ts b/backend/src/features/subscriptions/external/stripe/stripe.client.ts index cf1050f..1105f1b 100644 --- a/backend/src/features/subscriptions/external/stripe/stripe.client.ts +++ b/backend/src/features/subscriptions/external/stripe/stripe.client.ts @@ -75,6 +75,14 @@ export class StripeClient { try { logger.info('Creating Stripe subscription', { customerId, priceId, paymentMethodId }); + // Attach payment method to customer before creating subscription + if (paymentMethodId) { + await this.stripe.paymentMethods.attach(paymentMethodId, { + customer: customerId, + }); + logger.info('Payment method attached to customer', { customerId, paymentMethodId }); + } + const subscriptionParams: Stripe.SubscriptionCreateParams = { customer: customerId, items: [{ price: priceId }],