laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.38k stars 677 forks source link

Error: You cannot set automatic_tax[enabled]=true in setup mode. #1581

Closed enricobono closed 1 year ago

enricobono commented 1 year ago

Cashier Stripe Version

14.12.8

Laravel Version

10.26.2

PHP Version

8.2.8

Database Driver & Version

No response

Description

I'm using Laravel Spark (Spark Stripe, v4.2.3). I have a customer with an active subscription since months. Now his card expired, so he's trying to add a new card. When the user presses the "Add Payment Method" button, Laravel shows the following error message:

An unexpected error occurred and we have notified our support team. Please try again later

On the logs I can see:

You cannot set `automatic_tax[enabled]=true` in `setup` mode.

From Stripe I can see my app is trying to perform a POST call to this endpoint: POST /v1/checkout/sessions with the following body:

{
  "customer_update": {
    "address": "auto",
    "name": "auto"
  },
  "cancel_url": "https://MYAPP.com/billing?checkout=cancelled",
  "tax_id_collection": {
    "enabled": "true"
  },
  "customer": ["cus_REDACTED"](https://dashboard.stripe.com/customers/cus_REDACTED),
  "automatic_tax": {
    "enabled": "true"
  },
  "billing_address_collection": "required",
  "success_url": "https://MYAPP.com/billing?checkout=payment_method_added",
  "mode": "setup",
  "payment_method_types": {
    "0": "card"
  }
}

and Stripe returns the following response:

{
  "error": {
    "message": "You cannot set `automatic_tax[enabled]=true` in `setup` mode.",
    "request_log_url": "https://dashboard.stripe.com/logs/req_REDACTED?t=1696783529",
    "type": "invalid_request_error"
  }
}

The POST call is using mode=setup and "automatic_tax": {"enabled": "true"}, and it seems we can not. Maybe Cashier should pass mode=subscription? (Cfr: https://stripe.com/docs/api/checkout/sessions/create?lang=php)

Steps To Reproduce

GIVEN a customer card expired WHEN the user presses the "Add Payment Method" button THEN Laravel displays the following error message:

An unexpected error occurred and we have notified our support team. Please try again later

AND the log has the following message:

You cannot set `automatic_tax[enabled]=true` in `setup` mode.
enricobono commented 1 year ago

I noticed this does not happen if I comment the line:

Cashier::calculateTaxes();

in the AppServiceProvider::boot() method.

driesvints commented 1 year ago

Spark Stripe does not support Stripe Tax unfortunately so you cannot use that. Setup mode is correct when handling adding payment methods.