Mangopay / mangopay2-php-sdk

PHP SDK for MANGOPAY
https://packagist.org/packages/mangopay/php-sdk-v2
MIT License
123 stars 134 forks source link

Update Natural user #372

Closed Azim-pix closed 4 years ago

Azim-pix commented 4 years ago

Hi i am facing issue while updating natural user,if try to execute the code i am getting an error

"Method not allowed. The requested resource does not support http method 'PUT'."

here is my code

$UserNatural = new MangoPay\UserNatural(); $UserNatural->Id = $id; $UserNatural->FirstName = $firstname; $UserNatural->LastName = $lastname; $UserNatural->Email = $email; $UserNatural->Birthday = 1409735187; $UserNatural->Nationality = "FR"; $UserNatural->CountryOfResidence = "FR";

        return $this->mangoPayApi->Users->Update($UserNatural);
Riwak commented 4 years ago

Hello @Azim-pix

In you code you should get the user first : $userFetched = $this->mangoPayApi->Users->Get($id);

Then you can do the edit : $userFetched->LastName .= " - CHANGED";

When the edit is done you can save it : $userSaved = $this->mangoPayApi->Users->Update($userFetched);

For more details, you can have a look at our tests here: https://github.com/Mangopay/mangopay2-php-sdk/blob/master/tests/cases/UsersTest.php#L138 which are currently passing.

Hope it's clear 🙂

Best regards,

Azim-pix commented 4 years ago

Hi @Riwak Thanks for your reply, i followed your steps but user is not updated in Mangopay Dashboard. Here is the code

        $userFetched = $this->mangoPayApi->Users->Get($id);
        $userFetched->FirstName = $firstname; (Taking new name from form)
        $userSaved = $this->mangoPayApi->Users->Update($userFetched);
        dd($this->mangoPayApi->Users->Get($id));

I did not understand the " - CHANGED" here ,and how i can update a new first Name and can i update multiple parameter at a time ,

Please let me know where am i doing wrong

Thanks Azim

Riwak commented 4 years ago

Hey @Azim-pix,

We have at the moment some delays in the mangopay dashboard. (so it's "normal"). Can you please try to refresh the webpage with cleared cache and a fresh login ?

The " - CHANGED" was just here to explain that this string it's the new one (Taking new name from form) 😉 And Yes of course you can update multiple parameters at a time.

I'm at your disposal if needed,

Best regards,

Audouin,