-
Notifications
You must be signed in to change notification settings - Fork 850
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
Ignore null values in params #526
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments but LGTM
public static function objectsToIds($h) | ||
{ | ||
if ($h instanceof \Stripe\ApiResource) { | ||
return $h->id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there will be some cases where some resources will not have an id and break this logic and we will regret this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I considered that. This would only happen if a user passed a resource without an ID inside a parameter hash though. We could check if the resource has an id
property and output an error message if not, but I don't think it's worth the hassle.
(stripe-ruby has the same issue fwiw)
tests/Stripe/Util/UtilTest.php
Outdated
'customer' => Util\Util::convertToStripeObject([ | ||
'id' => 'cus_123', | ||
'object' => 'customer', | ||
], null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation on this kind of threw me off
cf172a6
to
275ce65
Compare
Released as 6.19.1. |
r? @remi-stripe
cc @stripe/api-libraries @EatonZ
This fixes a regression I caused in #517 that caused
null
values in parameters to be encoded as empty strings and sent in requests.stripe-ruby handles this via the
objects_to_ids
helper method, whose main purpose is to replace instances of Stripe resources with their IDs, but that also clears null values. Since the parameter encoding logic in stripe-php is already very similar to stripe-ruby's, I simply ported the method.Fixes #525.