Closed driesvints closed 11 months ago
Thanks @driesvints!
I was heading back here to do a PR (did the issue at the end of my day) only to find you'd done it already! You rock.
Just dropping this here as this PR might be a breaking change to others like it was for me:
When I first used Cashier, I had to (or at least read in Stripe or Cashier's docs) that I had to set mode
to subscription
in the checkout attributes.
Because of this change, the mode gets merged and changed into an array instead of string, causing this error:
Fixed by removing the mode
attribute from my checkout builder.
@bjarn can you share the code that causes this?
@driesvints Sure!
I used the following builder:
$builder = $team->newSubscription(
'default',
$plan->priceId($data->billing_cycle)
);
// ...
return $builder->checkout([
'mode' => 'subscription',
'client_reference_id' => $team->id,
'customer_update' => [
'name' => 'auto',
'address' => 'auto',
'shipping' => 'never',
],
'billing_address_collection' => 'required',
'allow_promotion_codes' => true,
'success_url' => xxx,
'cancel_url' => xxx
])->asStripeCheckoutSession()->url;
I'm not sure why the mode ended up here, but I saw it was also set here: https://github.com/laravel/cashier-stripe/pull/1579/files#diff-6ddbc0726400777bbee69d4448fa971720fb206f613abda0e165fffd8a340316L356
Now it is recursively merged, I think it's appended instead of overwritten of course. Probably have overlooked something when diving into the Stripe docs to see all available parameters not thinking about Cashier's abstractions.
Removed the mode from the builder and it was all fine again.
Yeah, I'm sorry but I don't feel we can consider this an issue since the builder already adds this for you.
Yeah, I'm sorry but I don't feel we can consider this an issue since the builder already adds this for you.
Yea, no worries at all! It definitely was an error on my end, just sharing in case anyone else made the same mistake :)
Thanks!
Makes sure the payload for checkout is recursively merged instead of overwritten. The
create
method of the builder doesn't suffers from this because the default payload doesn't have multidimensional options.Fixes https://github.com/laravel/cashier-stripe/issues/1578