Mangopay / mangopay2-php-sdk

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

Getting Unauthorized #376

Closed Premlimbachiya closed 4 years ago

Premlimbachiya commented 4 years ago

using my client id and login password i am trying to get all user but it will return Unauthorized from php sdk

Riwak commented 4 years ago

Hello @Premlimbachiya

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.

Premlimbachiya commented 4 years ago

require_once FCPATH . '/payment/vendor/autoload.php';

class Payment_mongo extends CI_Controller {

public $curlang = 'en';

function __construct() {
    parent::__construct();
}

public function index() {
    $api = new MangoPay\MangoPayApi();
    $api->Config->ClientId = 'your-client-id';
    $api->Config->ClientPassword = 'your-client-password';
    $api->Config->TemporaryFolder = '/some/path/';
    try {
        $users = $api->Users->GetAll();
        //pre($users);
    } catch (MangoPay\Libraries\ResponseException $e) {
        pre($e);
        // handle/log the response exception with code $e->GetCode(), message $e->GetMessage() and error(s) $e->GetErrorDetails()
    } catch (MangoPay\Libraries\Exception $e) {
        pre($e->getMessage());
        // handle/log the exception $e->GetMessage()
    }
}

}

Riwak commented 4 years ago

Hey @Premlimbachiya

Thanks for this response. Is you temporary folder well set ? I can see '/some/path/' in you code.

$api->Config->TemporaryFolder = '/some/path/'; Is there a folder in read+write available at this path ?

Additional question : can I have your client-id ?

Thanks !

Premlimbachiya commented 4 years ago

yes there is permission of temporary folder and client-id is "harbin".

Riwak commented 4 years ago

Thanks for this response. Is your ClientPassword identical to your API Key ?

Premlimbachiya commented 4 years ago

no both are different.

Premlimbachiya commented 4 years ago

currently i am set password which is use in sandbox login and also try with API key but not working.

Riwak commented 4 years ago

ClientPassword should be identical to your API Key.

Riwak commented 4 years ago

You can contact-us directly from this page if you need any direct assistance during your implementation --> https://www.mangopay.com/fr/contact/