PayPal\Handler\OauthHandler::handle PHP Method

handle() public method

public handle ( PayPalHttpConfig $httpConfig, string $request, mixed $options ) : mixed | void
$httpConfig PayPal\Core\PayPalHttpConfig
$request string
$options mixed
return mixed | void
    public function handle($httpConfig, $request, $options)
    {
        $config = $this->apiContext->getConfig();
        $httpConfig->setUrl(rtrim(trim($this->_getEndpoint($config)), '/') . (isset($options['path']) ? $options['path'] : ''));
        $headers = array("User-Agent" => PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION), "Authorization" => "Basic " . base64_encode($options['clientId'] . ":" . $options['clientSecret']), "Accept" => "*/*");
        $httpConfig->setHeaders($headers);
        // Add any additional Headers that they may have provided
        $headers = $this->apiContext->getRequestHeaders();
        foreach ($headers as $key => $value) {
            $httpConfig->addHeader($key, $value);
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @dataProvider modeProvider
  * @param $configs
  */
 public function testGetEndpoint($configs)
 {
     $config = $configs + array('cache.enabled' => true, 'http.headers.header1' => 'header1value');
     $this->apiContext->setConfig($config);
     $this->httpConfig = new PayPalHttpConfig(null, 'POST', $config);
     $this->handler = new OauthHandler($this->apiContext);
     $this->handler->handle($this->httpConfig, null, $this->config);
 }