#Karli-customer-update
1 messages ยท Page 1 of 1 (latest)
Hi there, I'm not sure if this is documented anywhere but it is expected. If you update an address, you must re-pass in any information you want to keep from the previous address.
Just before calling $customer->save(), the output of $customer->address is:
=> Stripe\StripeObject {#4090 city: null, country: "US", line1: "line 1 address", line2: null, postal_code: null, state: "AZ", }
So all the fields are still filled.
Sure that is because you are updating your local variable, right?
Not updating the Address within Stripe?
yes, update only done on local variabel
so save() only sends dirty fields of changed StripeObject?
I don't know what save() does... that is your own code
What is the definition of that function?
$customer is Stripe\Customer object, so no, it is not my own code. The definition is here: \Stripe\ApiOperations\Update::save
This is our legacy PHP approach (https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0) so I'm not quite as familiar with it but I see what you are saying.
Can you provide the customer ID for the customer that you are updating?
I'd like to take a look at something
it is in test mode: cus_LeaWTVSt39465O
Hi there sorry for the delay. Give me a moment to check
Looks like the country and line 1 fields are still on that Customer object
Hi, no problem! ๐
I did some more digging as well. The save() method uses: $params = $this->serializeParameters(); to get fields that need changing, this in turn looks into \Stripe\StripeObject::$_values, which is only populated when \Stripe\StripeObject::updateAttributes or \Stripe\StripeObject::__set are called. So indeed, looks like if I do not call set on all the address fields, that already existed, they will be excluded from the API request and hence will be removed. It was a bit surprising, but I guess I have to live with it ๐
Anyway, I guess, I should use more of that non-legacy style of the API, so I won't run into problems like that ๐