protected function getToken($config, $clientId, $clientSecret, $payload)
{
$httpConfig = new PayPalHttpConfig(null, 'POST', $config);
$handlers = array(self::$AUTH_HANDLER);
/** @var IPayPalHandler $handler */
foreach ($handlers as $handler) {
if (!is_object($handler)) {
$fullHandler = "\\" . (string) $handler;
$handler = new $fullHandler(new ApiContext($this));
}
$handler->handle($httpConfig, $payload, array('clientId' => $clientId, 'clientSecret' => $clientSecret));
}
$connection = new PayPalHttpConnection($httpConfig, $config);
$res = $connection->execute($payload);
$response = json_decode($res, true);
return $response;
}