feat: turn off Stripe automatic tax on subscription and credit checkout, plan changes and proration previews in internal/app/stripe/service.go, keeping required billing address, business name and tax ID collection

This commit is contained in:
Matthew Meszaros
2026-10-04 09:59:24 +02:00
parent 315b19a63a
commit 751dd5e08c
2 changed files with 7 additions and 7 deletions
+4 -4
View File
@@ -245,7 +245,7 @@ func (s *stripeService) CreateCheckoutSession(ctx context.Context, userID uuid.U
params := &stripe.CheckoutSessionParams{
Mode: stripe.String(string(stripe.CheckoutSessionModeSubscription)),
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)},
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(false)},
BillingAddressCollection: stripe.String(string(stripe.CheckoutSessionBillingAddressCollectionRequired)),
TaxIDCollection: &stripe.CheckoutSessionTaxIDCollectionParams{Enabled: stripe.Bool(true)},
NameCollection: businessNameCollection(),
@@ -415,7 +415,7 @@ func (s *stripeService) CreateCreditCheckoutSession(ctx context.Context, userID,
params := &stripe.CheckoutSessionParams{
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)},
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(false)},
BillingAddressCollection: stripe.String(string(stripe.CheckoutSessionBillingAddressCollectionRequired)),
TaxIDCollection: &stripe.CheckoutSessionTaxIDCollectionParams{Enabled: stripe.Bool(true)},
NameCollection: businessNameCollection(),
@@ -733,7 +733,7 @@ func (s *stripeService) ChangePlan(ctx context.Context, orgID uuid.UUID, newPlan
},
},
ProrationBehavior: stripe.String(prorationBehavior),
AutomaticTax: &stripe.SubscriptionAutomaticTaxParams{Enabled: stripe.Bool(true)},
AutomaticTax: &stripe.SubscriptionAutomaticTaxParams{Enabled: stripe.Bool(false)},
}
if couponID != nil {
params.Discounts = []*stripe.SubscriptionDiscountParams{{Coupon: stripe.String(*couponID)}}
@@ -792,7 +792,7 @@ func (s *stripeService) PreviewPlanChange(ctx context.Context, orgID uuid.UUID,
// Preview the upcoming invoice with the plan change
params := &stripe.InvoiceCreatePreviewParams{
AutomaticTax: &stripe.InvoiceCreatePreviewAutomaticTaxParams{Enabled: stripe.Bool(true)},
AutomaticTax: &stripe.InvoiceCreatePreviewAutomaticTaxParams{Enabled: stripe.Bool(false)},
Customer: stripe.String(sub.StripeCustomerID),
Subscription: stripe.String(*sub.StripeSubscriptionID),
SubscriptionDetails: &stripe.InvoiceCreatePreviewSubscriptionDetailsParams{
+3 -3
View File
@@ -94,8 +94,8 @@ func TestSubscriptionCheckoutCustomerParameters(t *testing.T) {
if r.Form.Get("mode") != "subscription" || r.Form.Has("customer_creation") || r.Form.Get("customer") != customerID {
t.Errorf("invalid checkout parameters: %v", r.Form)
}
if r.Form.Get("automatic_tax[enabled]") != "true" || r.Form.Get("billing_address_collection") != "required" || r.Form.Get("tax_id_collection[enabled]") != "true" {
t.Errorf("tax collection is not enabled: %v", r.Form)
if r.Form.Get("automatic_tax[enabled]") != "false" || r.Form.Get("billing_address_collection") != "required" || r.Form.Get("tax_id_collection[enabled]") != "true" {
t.Errorf("checkout tax parameters are wrong: %v", r.Form)
}
if customerID == "" && (r.Form.Has("customer_update[address]") || r.Form.Has("customer_update[name]")) {
t.Errorf("new-customer checkout included customer_update: %v", r.Form)
@@ -126,7 +126,7 @@ func TestCreditCheckoutCollectsTaxAndBusinessDetails(t *testing.T) {
if err := r.ParseForm(); err != nil {
t.Fatal(err)
}
if r.Form.Get("mode") != "payment" || r.Form.Get("automatic_tax[enabled]") != "true" || r.Form.Get("billing_address_collection") != "required" || r.Form.Get("tax_id_collection[enabled]") != "true" {
if r.Form.Get("mode") != "payment" || r.Form.Get("automatic_tax[enabled]") != "false" || r.Form.Get("billing_address_collection") != "required" || r.Form.Get("tax_id_collection[enabled]") != "true" {
t.Errorf("invalid tax-aware credit checkout: %v", r.Form)
}
if customerID == "" && r.Form.Get("customer_creation") != "always" {