Skip to content

Commit

Permalink
Stripe Tax: Update customer address when needed
Browse files Browse the repository at this point in the history
Use the billing address entered during checkout to assess the customer's
location for Stripe Tax. This is also needed to avoid an error if an
existing customer lacks an address.
  • Loading branch information
verement committed Mar 18, 2024
1 parent 6849aa9 commit be3b921
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ghost/stripe/lib/StripeAPI.js
Expand Up @@ -488,6 +488,14 @@ module.exports = class StripeAPI {
stripeSessionOptions.customer_email = customerEmail;
}

// Use the billing address entered during checkout to assess the
// customer's location for Stripe Tax. This is also needed to avoid an
// error if an existing customer lacks an address. It must not be used
// when Stripe does not already have a customer record.
if (customer && this._config.enableAutomaticTax) {
stripeSessionOptions.customer_update = {address: 'auto'};
}

// @ts-ignore
const session = await this._stripe.checkout.sessions.create(stripeSessionOptions);

Expand Down Expand Up @@ -537,6 +545,14 @@ module.exports = class StripeAPI {
}]
};

// Use the billing address entered during checkout to assess the
// customer's location for Stripe Tax. This is also needed to avoid an
// error if an existing customer lacks an address. It must not be used
// when Stripe does not already have a customer record.
if (customer && this._config.enableAutomaticTax) {
stripeSessionOptions.customer_update = {address: 'auto'};
}

// @ts-ignore
const session = await this._stripe.checkout.sessions.create(stripeSessionOptions);
return session;
Expand Down

0 comments on commit be3b921

Please sign in to comment.