Skip to content
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

array_filter removes 0 as the quantity value to addPrice function #1237

Closed
jayan-blutui opened this issue Aug 18, 2021 · 2 comments · Fixed by #1238
Closed

array_filter removes 0 as the quantity value to addPrice function #1237

jayan-blutui opened this issue Aug 18, 2021 · 2 comments · Fixed by #1238
Labels

Comments

@jayan-blutui
Copy link
Contributor

  • Cashier Version: 13.4.4
  • Laravel Version: 8.55.0
  • PHP Version: 8.0.9
  • Database Driver & Version: MySQL 8.0.26

Description:

I noticed that when specifying 0 as the quantity for the second argument of addPrice, it is filtered out in the final result. Setting 0 as the quantity is committed to the database but not to Stripe, instead the default value of 1 is used in Stripe.

->create(array_filter(array_merge([

I understand that this is the default behaviour of array_filter as 0 is equivalent to false.

@jayan-blutui
Copy link
Contributor Author

Just read through the Stripe PHP library and it looks like params are formatted to convert null values to an empty string.

A link to Stripe's function: formatParams function. Would it make sense to remove the array_filter in favour of Stripe's formatParams function?

@driesvints
Copy link
Member

Heya, thanks for reporting this. While I agree that the current implementation is faulty I must stress that zero isn't a correct value to pass here (I'm not sure why you'd want that?). I did however update our implementation to always use the Stripe returned quantity: #1238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants