Mangopay / mangopay2-php-sdk

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

KYC page - the body cannot be empty #429

Closed samuelecavalleri closed 3 years ago

samuelecavalleri commented 3 years ago

Hi,

I am trying to create a KYC document and pages using the PHP sdk in a Laravel 7 project.

I can create the document correctly, in fact I am able to see them in the MangoPay dashboard, however, when posting a new page I get the following error:

MangoPay\Libraries\ResponseException: Bad request. the body cannot be empty in file...

This is my code:

// create KYC document
$kyc = new MangoPay\KycDocument();
$kyc->Type = 'IDENTITY_PROOF';

$kycDoc = $this->api->Users->CreateKycDocument($userId, $kyc);

// create KYC page
$kycPage = new MangoPay\KycPage();
$kycPage->File = \Illuminate\Support\Facades\File::get($file); 
// $file contains the path to an image saved in the filesystem
// the image exists and if I dump its content, I can see that it is not empty 

$this->api->Users->CreateKycPage($userId, $kycDoc->Id, $kycPage);

Am I missing something? Any suggestions?

Thank you!

samuelecavalleri commented 3 years ago

Fixed by using the method CreateKycPageFromFile

Hope someone else finds this useful.