Skip to content

[Stripe] Enable automatic tax on transactions #13002

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 23, 2022
Merged

[Stripe] Enable automatic tax on transactions #13002

merged 7 commits into from
Sep 23, 2022

Conversation

jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Sep 15, 2022

Description

Enable automatic tax on Stripe transactions:

  • Since we're already asking users for a country when they provide a payment method, we might as set their customer's country by default
  • Refactor StripeService methods to utilize attributionId more and pass around IDs instead of (possibly outdated) Stripe objects
  • When creating new subscriptions in supported Stripe Tax regions, pass along automatic_tax: { enabled: true } to enable automatic tax collection for these subscriptions

Related Issue(s)

Fixes #13000

How to test

  1. Create a team called "Gitpod [Something]"
  2. Add a payment method from a tax-supported country (i.e. any country from the EU or the UK)
  3. Once subscribed, open your Stripe customer portal: the country in your billing address should be the same as in 2. (and not "United States" by default)
  4. In the Stripe admin dashboard, automatic tax collection should be enabled for your subscription
  5. Now cancel the subscription (or create a new team -- should work the same)
  6. Add a payment method from a tax-unsupported country (e.g. Canada)
  7. Subscribing should still work successfully
  8. In the Stripe admin dashboard, automatic tax collection should not be enabled for your new subscription

Release Notes

NONE

Documentation

Werft options:

  • /werft with-clean-slate-deployment
  • /werft with-preview
  • /werft with-payment

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Sep 15, 2022

/werft run

👍 started the job as gitpod-build-jx-stripe-tax.1
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Sep 15, 2022

/werft run

👍 started the job as gitpod-build-jx-stripe-tax.2
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

Depends on #13008

@jankeromnes jankeromnes changed the title Enable automatic tax on Stripe transactions [Stripe] Enable automatic tax on transactions Sep 15, 2022
@jankeromnes jankeromnes force-pushed the jx/stripe-tax branch 2 times, most recently from 1c0d27b to 80b3c87 Compare September 16, 2022 09:26
@jankeromnes

This comment was marked as outdated.

@roboquat roboquat added size/M and removed size/XS labels Sep 19, 2022
@jankeromnes jankeromnes force-pushed the jx/stripe-tax branch 4 times, most recently from 9c26407 to 98b5f19 Compare September 19, 2022 14:11
@roboquat roboquat added size/L and removed size/M labels Sep 19, 2022
@jankeromnes jankeromnes force-pushed the jx/stripe-tax branch 4 times, most recently from 62b578c to fdb0663 Compare September 20, 2022 15:12
@roboquat roboquat added size/XL and removed size/L labels Sep 21, 2022
@jankeromnes jankeromnes force-pushed the jx/stripe-tax branch 2 times, most recently from e7eeca9 to ee04da1 Compare September 21, 2022 13:03
invoice_settings: { default_payment_method: setupIntent.payment_method },
...(paymentMethod.billing_details.address?.country
? { address: { line1: "", country: paymentMethod.billing_details.address?.country } }
Copy link
Member

@svenefftinge svenefftinge Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why line1 is mandatory? Why don't you copy over the full address here?

Copy link
Contributor Author

@jankeromnes jankeromnes Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line1 isn't actually mandatory: https://stripe.com/docs/api/customers/create#create_customer-address-line1

However, it seems that Stripe's TypeScript bindings marked it as mandatory, so I provide an empty value (undefined or null were not allowed, but I believe the result is the same).

Also, the country by itself is already the full address we get from the upgrade flow (we only ask for country, not for a full billing address, so new subscribers didn't have a change to fill this in yet):

Screenshot 2022-09-23 at 10 14 47

However, I'm not exactly sure what happens if:

  • You subscribe from a given country
  • Then, you set a complete billing address (e.g. all lines) in your Stripe customer portal
  • Then, you cancel
  • Then, you subscribe from a different country

It's sort of an edge case, but should also be tested. Thanks for pointing it out!

Copy link
Contributor Author

@jankeromnes jankeromnes Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've tested it -- if you cancel and re-subscribe from a different country, your billing address is entirely reset:

Screenshot 2022-09-23 at 15 45 02

I think that's a good thing.

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Sep 23, 2022

Weird 🤔 server is now in CrashLoopBackOff due to:

Error: A metric with the name process_cpu_user_seconds_total has already been registered.
    at Registry.registerMetric (/app/node_modules/prom-client/lib/registry.js:80:10)

Maybe let's rebase & build with-clean-slate just in case.

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-jx-stripe-tax.27 because the annotations in the pull request description changed
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Sep 23, 2022

Let's try this again:

/werft run

👍 started the job as gitpod-build-jx-stripe-tax.30
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-jx-stripe-tax.29 because the annotations in the pull request description changed
(with .werft/ from main)

@jankeromnes jankeromnes marked this pull request as ready for review September 23, 2022 13:47
@roboquat roboquat merged commit a99b0c3 into main Sep 23, 2022
@roboquat roboquat deleted the jx/stripe-tax branch September 23, 2022 13:53
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/XL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stripe] Enable automatic tax on transactions
4 participants