Esempio n. 1
0
 /**
  * @param Request $request
  *
  * @return Response
  */
 private function call(Request $request)
 {
     Debugger::firelog($request);
     $ch = curl_init($this->endPoint);
     // Set up verbose mode
     curl_setopt($ch, CURLOPT_VERBOSE, true);
     //turning off the server and peer verification(TrustManager Concept).
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     // We should check if paypal has valid certificate
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // Just do normal POST
     curl_setopt($ch, CURLOPT_POST, true);
     if ($this->useProxy) {
         curl_setopt($ch, CURLOPT_PROXY, $this->proxyHost . ':' . $this->proxyPort);
     }
     $request->addQuery(array('version' => self::VERSION, 'pwd' => $this->password, 'user' => $this->username, 'signature' => $this->signature));
     // POST data
     // Conversion to string is important!
     // It's because it's called __toString magic method which calls
     // in real $request->query->build();
     curl_setopt($ch, CURLOPT_POSTFIELDS, (string) $request);
     // Execute
     $responseNVP = curl_exec($ch);
     if (curl_errno($ch)) {
         $this->err(curl_error($ch));
     }
     curl_close($ch);
     $response = new Response($responseNVP);
     Debugger::firelog($response);
     return $response;
 }