Skip to content

Commit

Permalink
Added customer_update param to StripeAPI (#20105)
Browse files Browse the repository at this point in the history
ref https://linear.app/tryghost/issue/ENG-881/stripe-tax-checkout-instantiation-fails-for-free-members-when-choosing

- For existing customers to be able to upgrade their account with automatic tax enabled, we need to pass in `customer_update[address]:auto` as per Stripe documentation.
- Automatic tax calculation in Checkout requires a valid address on the Customer. Add a valid address to the Customer or set either 'customer_update[address]' to 'auto' or 'customer_update[shipping]' to 'auto' to save the address entered in Checkout to the Customer.
- We update the existing customer details by passing in address `auto` when they upgrade their accounts.
- Stripe captures the billing address information by default when new accounts are created and then that is used to calculate the tax rate.
  • Loading branch information
ronaldlangeveld committed May 1, 2024
1 parent cf9ba60 commit a738f5a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ghost/stripe/lib/StripeAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ module.exports = class StripeAPI {
automatic_tax: {
enabled: this._config.enableAutomaticTax
},
customer_update: this._config.enableAutomaticTax ? {address: 'auto'} : {},
metadata,
discounts,
/*
Expand Down Expand Up @@ -526,6 +527,7 @@ module.exports = class StripeAPI {
automatic_tax: {
enabled: this._config.enableAutomaticTax
},
customer_update: this._config.enableAutomaticTax ? {address: 'auto'} : {},
metadata,
customer: customer ? customer.id : undefined,
customer_email: !customer && customerEmail ? customerEmail : undefined,
Expand Down

0 comments on commit a738f5a

Please sign in to comment.