Mangopay / mangopay2-php-sdk

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

User Update endpoint is not working. #357

Closed ShooterArk closed 4 years ago

ShooterArk commented 5 years ago

Hi,

I am trying to update user info on mangopay. But I keep getting this error: Method not allowed. The Requested resource does not support http method 'PUT'.

I contacted MangoPay to check if I might be making some mistake but I double checked my code and its structure as directed in the MangoPay documentation. So they asked me to inform you guys to please look into this issue.

Thank you

ShooterArk commented 5 years ago

No response for the past 20 days ? IS this repo even currently active or dormant ?

mickaelpois commented 5 years ago

Hello @ShooterArk ,

Could you provide some code sample ? Which version are you using? 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.

ShooterArk commented 4 years ago

Hi Mickael,

$user = new MangoPay\UserNatural(); $user->FirstName = $this->request->firstname; $user->LastName = $this->request->lastname; $user->Email = $email; $user->Birthday = strtotime($this->request->dob); $user->Nationality = $this->request->nationality; $user->CountryOfResidence = $this->request->countryofresidence; $user->Id = $this->request->authorId; $createdUser = $api->Users->Update($user);

Here is my code my friend. Can you please let me know if I am not setting it up properly ?

Riwak commented 4 years ago

Hello @ShooterArk,

In your code you are trying to update $createdUser without creating it first.

You should do :

$user = new \MangoPay\UserNatural();
$user->FirstName = "John";
$user->LastName = "Doe";
$user->Email = "john.doe@sample.org";
$user->Birthday = mktime(0, 0, 0, 12, 21, 1975);
$user->Nationality = "FR";
$user->CountryOfResidence = "FR";

$createdUser = $this->_api->Users->Create($user); // Creating the user
$userSaved = $this->_api->Users->Update($createdUser); // Updating
ShooterArk commented 4 years ago

Hi Riwak, thank you for responding back. I would request you to please review my previous message again. I am not creating the user because its already created. I am using the existing record of the user and updating it.

As you can see here: $user->Id = $this->request->authorId

Please advise.

Best Regards,

Riwak commented 4 years ago

Hi @ShooterArk,

In your code $this->request->authorId does not correspond to your existing user id. In fact authorId are used to identify a transaction author. It's never used to identify a user.

Let's say you have John user already created and you want to edit his last-name.

As already said 🙂 You should get the user first : $userFetched = $this->_api->Users->Get($john->Id);

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

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

ShooterArk commented 4 years ago

Hi Riwak,

Thank you for responding back. Actually I followed the documentation of mangopay and the above code was copied from there. I am still facing the same issue which I mentioned before.

Here is the error: "MangoPay Error Method not allowed. The requested resource does not support http method 'PUT'"

I have contacted mangopay Support and they told me that the required SDK is pointing to the wrong end point. Can you please confirm it. If you want I can share the support emails as well for reference.

Thank you

Riwak commented 4 years ago

Yes please, Is it possible to have ?

Audouin

ShooterArk commented 4 years ago

Hi Riwak,

I think this response message from mangopay support will be helpful to you:

This is your response regarding above issue. "It seems you are trying to update/PUT user details on: /users/natural/ If you are updating an existing user, you should be doing PUT towards: /users/natural/userId/ "

Regards,

ShooterArk commented 4 years ago

Yes please, Is it possible to have ?

  • case ID
  • client-id

Thanks in advance,

Audouin

What is a Case ID ?

I can provide you the client-id: 2706

Regards,

Riwak commented 4 years ago

Hello @ShooterArk,

Actually I followed the documentation of mangopay and the above code was copied from there.

As already said, $user->Id = $this->request->authorId is not mentioned anywhere on the documentation 🙂 In fact authorId are used to identify a transaction author. It's never used to identify a user.

Can you please try this code :

$userFetched = $this->_api->Users->Get($john->Id);

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

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

ShooterArk commented 4 years ago

Hi Riwak,

Thank you so much for your assistance. Now I understood what you were trying to explain. Its working now.

Regards,