Ejemplo n.º 1
0
 public static function init()
 {
     if (!self::$_instance) {
         self::$_instance = new WP_User_Frontend();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 /**
  * Validate the IPN notification
  *
  * @param none
  * @return boolean
  */
 public function validateIpn()
 {
     global $wp_version;
     WP_User_Frontend::log('paypal', 'Checking if PayPal IPN response is valid');
     $this->set_mode();
     // Get received values from post data
     $validate_ipn = array('cmd' => '_notify-validate');
     $validate_ipn += wp_unslash($_POST);
     // Send back post vars to paypal
     $params = array('body' => $validate_ipn, 'timeout' => 60, 'httpversion' => '1.1', 'compress' => false, 'decompress' => false, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'));
     $response = wp_safe_remote_post($this->gateway_url, $params);
     WP_User_Frontend::log('paypal', 'IPN Request: ' . print_r($params, true));
     WP_User_Frontend::log('paypal', 'IPN Response: ' . print_r($response, true));
     // check to see if the request was valid
     if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
         WP_User_Frontend::log('paypal', 'Received valid response from PayPal');
         return true;
     }
     WP_User_Frontend::log('paypal', 'Received invalid response from PayPal');
     if (is_wp_error($response)) {
         WP_User_Frontend::log('paypal', 'Error response: ' . $response->get_error_message());
     }
     return false;
 }