Mangopay / mangopay2-php-sdk

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

Can't update the KYC document #488

Closed khrigo closed 3 years ago

khrigo commented 3 years ago

Hello, guys!

I am trying to update the KYC document like this written in the documentation:

$KycDocument->Type = "IDENTITY_PROOF";
$Result = $mainmp->create_kyc_document($UserId, $KycDocument); // returns KYC document
$Page = $mainmp->create_kyc_page_from_file($UserId, $Result->Id, $file); // returns true

$KycDocument->Status = \MangoPay\KycDocumentStatus::ValidationAsked; 
$ResultUpdate = $mainmp->update_kyc_document($UserId, $KycDocument); // returns error

But I am getting this error:

Fatal error: Uncaught MangoPay\Libraries\ResponseException: Method not allowed. The requested resource does not support http method 'PUT'. in /sdk/MangoPay/Libraries/RestTool.php:366
Stack trace:
#0 /sdk/MangoPay/Libraries/RestTool.php(152): MangoPay\Libraries\RestTool->CheckResponseCode(405, Object(stdClass))
#1 /sdk/MangoPay/Libraries/ApiBase.php(346): MangoPay\Libraries\RestTool->Request('/users/96113714...', 'PUT', Array)
#2 /sdk/MangoPay/ApiUsers.php(282): MangoPay\Libraries\ApiBase->SaveObject('kyc_documents_s...', Object(MangoPay\KycDocument), '\\MangoPay\\KycDo...', 96113714)

Please, help.

fredericdelordm commented 3 years ago

Hello @khrigo,

Thanks for reaching us. Are you using the last version of the SDK ?

As you can see below, you should use UpdateKycDocument in User class to submit the KYC document to validation.

//submit the doc for validation
$KycDocument = new MangoPay\KycDocument();
$KycDocument->Id = $KycDocumentId;
$KycDocument->Status = \MangoPay\KycDocumentStatus::ValidationAsked;
$result3 = $mangoPayApi->Users->UpdateKycDocument($_SESSION["MangoPayDemo"]["UserNatural"], $KycDocument);

More demos about KYC in demos/worflow/

Tell me if it's fix your issue.

khrigo commented 3 years ago

Hello @khrigo,

Thanks for reaching us. Are you using the last version of the SDK ?

As you can see below, you should use UpdateKycDocument in User class to submit the KYC document to validation.

//submit the doc for validation
$KycDocument = new MangoPay\KycDocument();
$KycDocument->Id = $KycDocumentId;
$KycDocument->Status = \MangoPay\KycDocumentStatus::ValidationAsked;
$result3 = $mangoPayApi->Users->UpdateKycDocument($_SESSION["MangoPayDemo"]["UserNatural"], $KycDocument);

More demos about KYC in demos/worflow/

Tell me if it's fix your issue.

Hello @fredericdelordm,

Yes, it is the last version. I just use WordPress plugin and use update_kyc_document which has:

public function update_kyc_document($userId,$KycDocument){
     return $this->mangoPayApi->Users->UpdateKycDocument($userId,$KycDocument);
}
fredericdelordm commented 3 years ago

@khrigo

you are using the official plugin : https://fr.wordpress.org/plugins/mangopay-woocommerce/ ? With WC Vendors ?

If yes, you should open a topic in the official forum : https://wordpress.org/support/plugin/mangopay-woocommerce/.

If not, let me know.

khrigo commented 3 years ago

@fredericdelordm I have a problem with PHP SDK, not in the plugin, I send you an error.

khrigo commented 3 years ago

I have a problem with this part:

return $this->mangoPayApi->Users->UpdateKycDocument($userId,$KycDocument);

I did it as you said:

//submit the doc for validation
$KycDocument = new MangoPay\KycDocument();
$KycDocument->Id = $KycDocumentId;
$KycDocument->Status = \MangoPay\KycDocumentStatus::ValidationAsked;
$result3 = $mangoPayApi->Users->UpdateKycDocument($_SESSION["MangoPayDemo"]["UserNatural"], $KycDocument);

And receive an error The requested resource does not support http method 'PUT' – REQUESTED, I think a problem not in code.

fredericdelordm commented 3 years ago

Our tech team is going to review this and will get back to you soon.

Have a nice day,

SoloJr commented 3 years ago

Hi @khrigo

`

If you take a look at this, you will find that the first parameter needs to be a string, not an object.

khrigo commented 3 years ago

Hi @khrigo

`

  • @param string $userId User Id
  • @param \MangoPay\KycDocument $kycDocument Document to save
  • @return \MangoPay\KycDocument Document returned from API`

If you take a look at this, you will find that the first parameter needs to be a string, not an object.

If you check my request, you can see what user_id is a string.

khrigo commented 3 years ago

@fredericdelordm please, open the issue.

khrigo commented 3 years ago

@fredericdelordm @SoloJr any news?

fredericdelordm commented 3 years ago

Hello @khrigo,

We cannot reproduce your error. The SDK is doing a PUT request as requested by the documentation.

Are you sure this error is coming from the SDK call to update the KYC Document status? Do you have more logs?

Just to be sure. Are you creating the KYC Document correctly (example here) before trying the update?

Regarding your code below, I think you are not creating the document as you should.

$KycDocument = new MangoPay\KycDocument();
$KycDocument->Id = $KycDocumentId;