From 009142c788fe64d091dbb2a3560f6fb398a0276d Mon Sep 17 00:00:00 2001 From: Alex Paul Date: Wed, 1 Jul 2026 13:57:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20checkout=20failures=20wh?= =?UTF-8?q?en=20collecting=20tax=20IDs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no ref Stripe requires Checkout sessions for existing customers to allow name updates when tax ID collection is enabled. This keeps the existing automatic tax customer update and lets Stripe save the legal business name. --- .../core/server/services/stripe/stripe-api.js | 6 ++--- .../server/services/stripe/stripe-api.test.js | 25 +++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ghost/core/core/server/services/stripe/stripe-api.js b/ghost/core/core/server/services/stripe/stripe-api.js index 092588a245f..9af5b7acd56 100644 --- a/ghost/core/core/server/services/stripe/stripe-api.js +++ b/ghost/core/core/server/services/stripe/stripe-api.js @@ -599,7 +599,7 @@ module.exports = class StripeAPI { } if (customerId && this._config.enableAutomaticTax) { - stripeSessionOptions.customer_update = {address: 'auto'}; + stripeSessionOptions.customer_update = {address: 'auto', name: 'auto'}; } // @ts-ignore @@ -670,7 +670,7 @@ module.exports = class StripeAPI { }; if (customer && this._config.enableAutomaticTax) { - stripeSessionOptions.customer_update = {address: 'auto'}; + stripeSessionOptions.customer_update = {address: 'auto', name: 'auto'}; } // @ts-ignore @@ -729,7 +729,7 @@ module.exports = class StripeAPI { }; if (customer && this._config.enableAutomaticTax) { - stripeSessionOptions.customer_update = {address: 'auto'}; + stripeSessionOptions.customer_update = {address: 'auto', name: 'auto'}; } // @ts-ignore diff --git a/ghost/core/test/unit/server/services/stripe/stripe-api.test.js b/ghost/core/test/unit/server/services/stripe/stripe-api.test.js index 02d01b727d7..97807af2964 100644 --- a/ghost/core/test/unit/server/services/stripe/stripe-api.test.js +++ b/ghost/core/test/unit/server/services/stripe/stripe-api.test.js @@ -458,7 +458,7 @@ describe('StripeAPI', function () { await api.createCheckoutSession('priceId', mockCustomer, { trialDays: null }); - assertExists(mockStripe.checkout.sessions.create.firstCall.firstArg.customer_update); + assert.deepEqual(mockStripe.checkout.sessions.create.firstCall.firstArg.customer_update, {address: 'auto', name: 'auto'}); }); it('createCheckoutSession does not add customer_update if automatic tax flag is enabled and customer is undefined', async function () { @@ -648,6 +648,27 @@ describe('StripeAPI', function () { assert(mockStripe.checkout.sessions.create.firstCall.firstArg.custom_fields.length <= 3); }); + + it('sets customer_update when customer and automatic tax are enabled', async function () { + api.configure({ + checkoutSessionSuccessUrl: '/success', + checkoutSessionCancelUrl: '/cancel', + checkoutSetupSessionSuccessUrl: '/setup-success', + checkoutSetupSessionCancelUrl: '/setup-cancel', + secretKey: '', + enableAutomaticTax: true + }); + + await api.createDonationCheckoutSession({ + priceId: 'priceId', + successUrl: '/success', + cancelUrl: '/cancel', + metadata: {}, + customer: {id: mockCustomerId} + }); + + assert.deepEqual(mockStripe.checkout.sessions.create.firstCall.firstArg.customer_update, {address: 'auto', name: 'auto'}); + }); }); describe('createGiftCheckoutSession', function () { @@ -886,7 +907,7 @@ describe('StripeAPI', function () { const args = mockStripe.checkout.sessions.create.firstCall.firstArg; - assert.deepEqual(args.customer_update, {address: 'auto'}); + assert.deepEqual(args.customer_update, {address: 'auto', name: 'auto'}); }); it('does not set customer_update without customer', async function () {