Example #1
0
 /**
  * Check PayPal IPN validity
  */
 private function isResponseValid()
 {
     $values = $this->wp->getHelpers()->stripSlashesDeep($_POST);
     $values['cmd'] = '_notify-validate';
     // Send back post vars to PayPal
     $params = array('body' => $values, 'sslverify' => false, 'timeout' => 30, 'user-agent' => 'Jigoshop/' . Core::VERSION);
     // Get url
     if ($this->settings['test_mode']) {
         $url = self::TEST_URL;
     } else {
         $url = self::LIVE_URL;
     }
     // Post back to get a response
     $response = $this->wp->wpSafeRemotePost($url, $params);
     // check to see if the request was valid
     if (!$this->wp->isWpError($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strcmp($response['body'], "VERIFIED") == 0) {
         return true;
     }
     Registry::getInstance(JIGOSHOP_LOGGER)->addWarning('Received invalid response from PayPal!', array('response' => $response));
     return false;
 }