Пример #1
0
 function verify()
 {
     $vars = $this->ipn_vars;
     $this->ipn = $this->ipn_vars;
     $vars['cmd'] = '_notify-validate';
     $options = array('headers' => array('Content-Type' => 'application/x-www-form-urlencoded'), 'method' => 'POST', 'data' => drupal_http_build_query($vars));
     $result = drupal_http_request($this->ipnLink, $options);
     $this->ipnResult = $result->data;
     if (!empty($result->error)) {
         $this->lastError = t('IPN Validation Error: @error', array('@error' => $result->error));
         return FALSE;
     } else {
         if ($result->code == 200) {
             if ($result->data == 'VERIFIED') {
                 return TRUE;
             } else {
                 $this->lastError = t('IPN Validation Failed: @error', array('@error' => $result->data));
                 return FALSE;
             }
         } else {
             // The server might be down, let's log an error but still pass the
             // validation.
             ms_core_log_error('ms_paypal_wps', 'The Validation Server had an error processing a request. Request: !request Response: !response', array('!request' => ms_core_print_r($options), '!response' => ms_core_print_r($result)), WATCHDOG_CRITICAL);
             return TRUE;
         }
     }
 }
Пример #2
0
 /**
  * Send parameters
  *
  * @param array $params
  * @return string result
  */
 function sentPost($params)
 {
     if (!file_exists($this->keystore)) {
         $result = "file " . $this->keystore . " not exists";
         error_log($result);
         return $result;
     }
     if (!is_readable($this->keystore)) {
         $result = "Please check CHMOD for file \"" . $this->keystore . "\"! It must be readable!";
         error_log($result);
         return $result;
     }
     $post = "";
     foreach ($params as $key => $value) {
         $post .= "{$key}={$value}&";
     }
     $curl = curl_init();
     if ($this->verbose) {
         curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
     }
     curl_setopt($curl, CURLOPT_URL, $this->url);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
     //curl_setopt($curl, CURLOPT_SSLVERSION,2);
     curl_setopt($curl, CURLOPT_SSLCERT, $this->keystore);
     curl_setopt($curl, CURLOPT_CAINFO, $this->keystore);
     curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $this->keystorepassword);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $result = curl_exec($curl);
     if (curl_error($curl)) {
         $result = curl_error($curl);
         ms_core_log_error('ms_ibis', 'Error with CURL call. Settings: !settings CURL: !curl Result: !result', array('!settings' => ms_core_print_r($this), '!curl' => ms_core_print_r(curl_getinfo($curl)), '!result' => $result));
     }
     curl_close($curl);
     return $result;
 }