Example #1
0
 /**
  * Post back to PayPal to check whether this request is a valid one
  *
  * @return void
  * @throws \Exception
  */
 protected function _postBack()
 {
     $httpAdapter = $this->_curlFactory->create();
     $postbackQuery = http_build_query($this->getRequestData()) . '&cmd=_notify-validate';
     $postbackUrl = $this->_config->getPaypalUrl();
     $this->_addDebugData('postback_to', $postbackUrl);
     $httpAdapter->setConfig(array('verifypeer' => $this->_config->getConfigValue('verifyPeer')));
     $httpAdapter->write(\Zend_Http_Client::POST, $postbackUrl, '1.1', array('Connection: close'), $postbackQuery);
     try {
         $postbackResult = $httpAdapter->read();
     } catch (\Exception $e) {
         $this->_addDebugData('http_error', array('error' => $e->getMessage(), 'code' => $e->getCode()));
         throw $e;
     }
     $response = preg_split('/^\\r?$/m', $postbackResult, 2);
     $response = trim($response[1]);
     if ($response != 'VERIFIED') {
         $this->_addDebugData('postback', $postbackQuery);
         $this->_addDebugData('postback_result', $postbackResult);
         throw new \Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.');
     }
 }