Closed victoralbino closed 10 months ago
I have news about the problem:
The log of my request that generates the error is this:
{
"payment_method_types": {
"0": "card"
},
"line_items": {
"0": {
"quantity": "1",
"price": "price_*****"
}
},
"cancel_url": "http://localhost/dashboard",
"tax_id_collection": {
"enabled": "false"
},
"customer": "cus_*****",
"mode": "subscription",
"success_url": "http://localhost/dashboard",
"subscription_data": {
"metadata": {
"name": "default"
},
"trial_end": "1700872427"
}
}
However, Stripe is considering the 'customer update' field as mandatory with the following values when calling checkout:
return $subscriptionBuilder->checkout([
'customer_update' => ['name' => 'auto', 'address' => 'auto'],
'success_url' => route('dashboard'),
'cancel_url' => route('dashboard'),
])->redirect();
In theory, to fix it, it would be necessary to change the Laravel\Cashier\Checkout
class in the create
method by changing the following if:
if ($sessionOptions['tax_id_collection']['enabled'] ?? false) {
$sessionOptions['customer_update']['address'] = 'auto';
$sessionOptions['customer_update']['name'] = 'auto';
}
to
$sessionOptions['customer_update']['address'] = 'auto';
$sessionOptions['customer_update']['name'] = 'auto';
However, as Stripe Tax is not available in my country, I cannot say if it will work properly in this situation.
Although the documentation states that they are optional https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer_update-name
I didn't find anything stating that they are mandatory when the tax_id_collection.enabled = true
So my solution to solve it in my case was:
I add to SubscriptionController
'customer_update' => ['name' => 'auto', 'address' => 'auto'],
return $subscriptionBuilder->checkout([
'customer_update' => ['name' => 'auto', 'address' => 'auto'],
'success_url' => route('dashboard'),
'cancel_url' => route('dashboard'),
])->redirect();
It works normally again. If anyone knows if this same solution keeps everything working when Stripe Tax is active, I can send a PR later
Note: In version v14.12.3, his method was changed, but even updating the Cashier version to the latest I tested it and the error persists.
Have the same issue. Last day feature still works until today. I think Stripe already updated something that makes this issue happens.
I tested that removing tax_id_collection from payload if you not need to use tax will work.
Hope team can update early
Thank you.
I started having this same exception as well, it now looks like tax_id_collection.enabled
key cannot be present in the request to create a session at all if its set to false
. If I modify the vendor directory Laravel\Cashier\Checkout
and unset($data['tax_id_collection']['enabled'])
and comment out the customer_update
block, then I'm able to get to the Stripe checkout page successfully:
unset($data['tax_id_collection']['enabled']);
// Make sure to collect address and name when Tax ID collection is enabled...
// if (isset($data['customer']) && $data['tax_id_collection']['enabled'] ?? false) {
// $data['customer_update']['address'] = 'auto';
// $data['customer_update']['name'] = 'auto';
// }
It looks like Stripe must have changed something in their October 16th release, as I wasn't encountering this before that date:
I am seeing this starting today too, but only on my dev server. Strangly both my dev and production servers are using the older API version, and have no usage on the 10/16 update, but I am still seeing the issue.
Cashier Stripe Version
13.17
Laravel Version
10.8
PHP Version
8.1
Database Driver & Version
No response
Description
Hello everybody,
I was using Cashier with Stripe (checkout). It was working normally, but I started getting this error:
Steps To Reproduce
Este é o meu
AppServiceProvider
:I'm not using
Cashier::calculateTaxes();
.This is my model
User
which must be billable:And this is the controller where I try to make the subscription:
All migrations were executed.
My .env file has the registered keys: