Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe Tax: Update customer address when needed #19882

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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