PayPal\Handler\PPGenericServiceHandler::handle PHP Method

handle() public method

public handle ( $httpConfig, $request, $options )
    public function handle($httpConfig, $request, $options)
    {
        $httpConfig->addHeader('X-PAYPAL-REQUEST-DATA-FORMAT', $request->getBindingType());
        $httpConfig->addHeader('X-PAYPAL-RESPONSE-DATA-FORMAT', $request->getBindingType());
        $httpConfig->addHeader('X-PAYPAL-DEVICE-IPADDRESS', PPUtils::getLocalIPAddress());
        $httpConfig->addHeader('X-PAYPAL-REQUEST-SOURCE', $this->getRequestSource());
        if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) {
            $httpConfig->addHeader("User-Agent", PPUserAgent::getValue($this->sdkName, $this->sdkVersion));
        }
        if (isset($options['config']['service.SandboxEmailAddress'])) {
            $httpConfig->addHeader('X-PAYPAL-SANDBOX-EMAIL-ADDRESS', $options['config']['service.SandboxEmailAddress']);
        }
    }

Usage Example

 public function handle($httpConfig, $request, $options)
 {
     parent::handle($httpConfig, $request, $options);
     $this->config = $options['config'];
     $credential = $request->getCredential();
     //TODO: Assuming existence of getApplicationId
     if ($credential && $credential->getApplicationId() != NULL) {
         $httpConfig->addHeader('X-PAYPAL-APPLICATION-ID', $credential->getApplicationId());
     }
     if ($options['port'] != null && isset($this->config['service.EndPoint.' . $options['port']])) {
         $endpnt = 'service.EndPoint.' . $options['port'];
         $this->endpoint = $this->config[$endpnt];
     } else {
         if (isset($this->config['service.EndPoint'])) {
             $this->endpoint = $this->config['service.EndPoint'];
         } else {
             if (isset($this->config['mode'])) {
                 if (strtoupper($this->config['mode']) == 'SANDBOX') {
                     $this->endpoint = PPConstants::PLATFORM_SANDBOX_ENDPOINT;
                 } else {
                     if (strtoupper($this->config['mode']) == 'LIVE') {
                         $this->endpoint = PPConstants::PLATFORM_LIVE_ENDPOINT;
                     }
                 }
             } else {
                 throw new PPConfigurationException('endpoint Not Set');
             }
         }
     }
     $httpConfig->setUrl($this->endpoint . $options['serviceName'] . '/' . $options['apiMethod']);
 }
All Usage Examples Of PayPal\Handler\PPGenericServiceHandler::handle