public function validate_request()
 {
     $paypal_url = Colabs_PayPal::get_request_url();
     $received_values = array('cmd' => '_notify-validate');
     $received_values += stripslashes_deep($_POST);
     $params = array('body' => $received_values, 'sslverify' => false, 'timeout' => 60, 'httpversion' => '1.1', 'user-agent' => 'ColorLabs/' . get_bloginfo('version'));
     $response = wp_remote_post($paypal_url, $params);
     if (is_wp_error($response)) {
         return false;
     }
     if ($response['response']['code'] >= 200 && $response['response']['code'] < 300) {
         if (preg_match("/VERIFIED/s", $response['body'])) {
             return true;
         }
     }
     return false;
 }
Пример #2
0
 /**
  * Checks whether the current response is a valid transaction key
  * @param  APP_Order  $order   Order being processed
  * @param  array  $options     User inputted options
  * @return boolean              True if transaction key is valid, false if invalid
  */
 public static function get_transaction($transaction_key, $identity_token, $sandbox = false)
 {
     $data = array('cmd' => '_notify-synch', 'tx' => $transaction_key, 'at' => $identity_token);
     $url = Colabs_PayPal::get_request_url();
     $options = array('method' => 'POST', 'body' => $data, 'sslverify' => false, 'httpversion' => '1.1');
     $response = self::get_url($url, $options);
     if (strpos($response, 'SUCCESS') !== 0) {
         return false;
     }
     $values = array();
     $lines = explode("\n", $response);
     foreach ($lines as $string) {
         $key_value_string = explode('=', $string);
         if (array_key_exists(1, $key_value_string)) {
             $value = $key_value_string[1];
         } else {
             $value = '';
         }
         $values[$key_value_string[0]] = urldecode($value);
     }
     return $values;
     wp_update_post(array("ID" => $order->get_id(), "post_content" => $transaction_id));
 }