diff --git a/ghost/core/core/server/services/stripe/config.js b/ghost/core/core/server/services/stripe/config.js index 68082227d1..33c21c245a 100644 --- a/ghost/core/core/server/services/stripe/config.js +++ b/ghost/core/core/server/services/stripe/config.js @@ -1,5 +1,6 @@ const logging = require('@tryghost/logging'); const tpl = require('@tryghost/tpl'); +const labs = require('../../../shared/labs'); const messages = { remoteWebhooksInDevelopment: 'Cannot use remote webhooks in development. See https://ghost.org/docs/webhooks/#stripe-webhooks for developing with Stripe.' @@ -64,6 +65,9 @@ module.exports = { ...keys, ...urls, enablePromoCodes: config.get('enableStripePromoCodes'), + get enableAutomaticTax() { + return labs.isSet('stripeAutomaticTax'); + }, webhookSecret: webhookSecret, webhookHandlerUrl: webhookHandlerUrl.href }; diff --git a/ghost/stripe/lib/StripeAPI.js b/ghost/stripe/lib/StripeAPI.js index 3a0b31f64f..5f9d53c0f4 100644 --- a/ghost/stripe/lib/StripeAPI.js +++ b/ghost/stripe/lib/StripeAPI.js @@ -20,6 +20,7 @@ const STRIPE_API_VERSION = '2020-08-27'; * @prop {string} secretKey * @prop {string} publicKey * @prop {boolean} enablePromoCodes + * @prop {boolean} enableAutomaticTax * @prop {string} checkoutSessionSuccessUrl * @prop {string} checkoutSessionCancelUrl * @prop {string} checkoutSetupSessionSuccessUrl @@ -395,6 +396,9 @@ module.exports = class StripeAPI { cancel_url: options.cancelUrl || this._config.checkoutSessionCancelUrl, // @ts-ignore - we need to update to latest stripe library to correctly use newer features allow_promotion_codes: discounts ? undefined : this._config.enablePromoCodes, + automatic_tax: { + enabled: this._config.enableAutomaticTax + }, metadata, discounts, /* diff --git a/ghost/stripe/lib/StripeService.js b/ghost/stripe/lib/StripeService.js index 0b0e52b49b..7781ae5a75 100644 --- a/ghost/stripe/lib/StripeService.js +++ b/ghost/stripe/lib/StripeService.js @@ -73,6 +73,9 @@ module.exports = class StripeService { secretKey: config.secretKey, publicKey: config.publicKey, enablePromoCodes: config.enablePromoCodes, + get enableAutomaticTax() { + return config.enableAutomaticTax; + }, checkoutSessionSuccessUrl: config.checkoutSessionSuccessUrl, checkoutSessionCancelUrl: config.checkoutSessionCancelUrl, checkoutSetupSessionSuccessUrl: config.checkoutSetupSessionSuccessUrl,