From 16f97537b4f00f0c0a7ca3f500b231a1a51938bb Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 22 Oct 2019 12:56:53 +0530 Subject: [PATCH] IP not being captured and forwarded to PayPal, PFW-484 --- angelleye-includes/angelleye-utility.php | 17 ---------------- ...flows-pro-gateway-paypal-pro-angelleye.php | 4 ++-- ...o-gateway-paypal-pro-payflow-angelleye.php | 4 ++-- .../wc-gateway-paypal-advanced-angelleye.php | 4 ++-- .../wc-gateway-paypal-express-angelleye.php | 2 +- classes/wc-gateway-paypal-pro-angelleye.php | 14 ++++++------- ...c-gateway-paypal-pro-payflow-angelleye.php | 20 ++++++++++--------- 7 files changed, 25 insertions(+), 40 deletions(-) diff --git a/angelleye-includes/angelleye-utility.php b/angelleye-includes/angelleye-utility.php index d1ec8e764..c4333c1e7 100644 --- a/angelleye-includes/angelleye-utility.php +++ b/angelleye-includes/angelleye-utility.php @@ -2032,23 +2032,6 @@ public function angelleye_display_user_instruction_for_payment_action($payment_a } } - public static function get_user_ip() { - $ip_address = ''; - if(class_exists('WC_Geolocation')) { - $ip_address = WC_Geolocation::get_ip_address(); - } else { - $ip_address = !empty($_SERVER['HTTP_X_FORWARD_FOR']) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $_SERVER['REMOTE_ADDR']; - } - $ipv4_pattern = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/'; - if ( ! preg_match( $ipv4_pattern, $ip_address ) && filter_var($ip_address, FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) ) { - $ip_address = ''; - } - if(strlen($ip_address) > 16) { - $ip_address = ''; - } - return $ip_address; - } - public static function woo_compatibility_notice() { echo ''; } diff --git a/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-angelleye.php b/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-angelleye.php index 413a155f8..6ef6bb3be 100644 --- a/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-angelleye.php +++ b/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-angelleye.php @@ -71,7 +71,7 @@ public function process_offer_payment($order, $product) { $description = sprintf(__('%1$s - Order %2$s - One Time offer', 'cartflows-pro'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number()); $DPFields = array( 'paymentaction' => 'Sale', - 'ipaddress' => AngellEYE_Utility::get_user_ip(), + 'ipaddress' => WC_Geolocation::get_ip_address(), 'returnfmfdetails' => '1', 'softdescriptor' => $gateway->softdescriptor ); @@ -166,7 +166,7 @@ public function process_offer_payment($order, $product) { $message = __("DoDirectPayment API call failed.", "paypal-for-woocommerce") . "\n\n"; $message .= __('Error Code: ', 'paypal-for-woocommerce') . $error_code . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $long_message . "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message .= __('Order ID: ') . $order_id . "\n"; $message .= __('Customer Name: ') . $billing_first_name . ' ' . $billing_last_name . "\n"; $message .= __('Customer Email: ') . $billing_email . "\n"; diff --git a/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-payflow-angelleye.php b/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-payflow-angelleye.php index 029aeda8a..aa6cd0ac0 100644 --- a/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-payflow-angelleye.php +++ b/angelleye-includes/cartflows-pro/class-cartflows-pro-gateway-paypal-pro-payflow-angelleye.php @@ -102,7 +102,7 @@ public function process_offer_payment($order, $product) { 'origid' => '', 'custref' => '', 'custcode' => '', - 'custip' => AngellEYE_Utility::get_user_ip(), + 'custip' => WC_Geolocation::get_ip_address(), 'invnum' => $gateway->invoice_id_prefix . str_replace("#", "", $order->get_order_number()) . '-' . $product['step_id'], 'ponum' => '', 'starttime' => '', @@ -223,7 +223,7 @@ public function process_offer_payment($order, $product) { $message .= __('Error Code: ', 'paypal-for-woocommerce') . $PayPalResult['RESULT'] . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $PayPalResult['RESPMSG']; $message .= isset($PayPalResult['PREFPSMSG']) && $PayPalResult['PREFPSMSG'] != '' ? ' - ' . $PayPalResult['PREFPSMSG'] . "\n" : "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message .= __('Order ID: ') . $order_id . "\n"; $message .= __('Customer Name: ') . $firstname . ' ' . $lastname . "\n"; $message .= __('Customer Email: ') . $billing_email . "\n"; diff --git a/classes/wc-gateway-paypal-advanced-angelleye.php b/classes/wc-gateway-paypal-advanced-angelleye.php index 1368dd258..210886c26 100644 --- a/classes/wc-gateway-paypal-advanced-angelleye.php +++ b/classes/wc-gateway-paypal-advanced-angelleye.php @@ -1471,7 +1471,7 @@ public function are_reference_transactions_enabled($token_id) { 'origid' => $token_id, 'custref' => '', 'custcode' => '', - 'custip' => AngellEYE_Utility::get_user_ip(), + 'custip' => WC_Geolocation::get_ip_address(), 'invnum' => '', 'ponum' => '', 'starttime' => '', @@ -1488,7 +1488,7 @@ public function are_reference_transactions_enabled($token_id) { $message .= __('Error Code: ', 'paypal-for-woocommerce') . $PayPalResult['RESULT'] . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $PayPalResult['RESPMSG']; $message .= isset($PayPalResult['PREFPSMSG']) && $PayPalResult['PREFPSMSG'] != '' ? ' - ' . $PayPalResult['PREFPSMSG'] . "\n" : "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message = apply_filters('ae_pppf_error_email_message', $message); $subject = apply_filters('ae_pppf_error_email_subject', "PayPal Payments Pro (PayFlow) Error Notification"); wp_mail($admin_email, $subject, $message); diff --git a/classes/wc-gateway-paypal-express-angelleye.php b/classes/wc-gateway-paypal-express-angelleye.php index af07a6f20..a9a8cf2c6 100644 --- a/classes/wc-gateway-paypal-express-angelleye.php +++ b/classes/wc-gateway-paypal-express-angelleye.php @@ -2098,7 +2098,7 @@ public function paypal_express_checkout_error_handler($request_name = '', $redir $message .= __('Error Severity Code: ', 'paypal-for-woocommerce') . $ErrorSeverityCode . "\n"; $message .= __('Short Error Message: ', 'paypal-for-woocommerce') . $ErrorShortMsg . "\n"; $message .= __('Long Error Message: ', 'paypal-for-woocommerce') . $ErrorLongMsg . "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $error_email_notify_mes = apply_filters('ae_ppec_error_email_message', $message, $ErrorCode, $ErrorSeverityCode, $ErrorShortMsg, $ErrorLongMsg); $subject = "PayPal Express Checkout Error Notification"; $error_email_notify_subject = apply_filters('ae_ppec_error_email_subject', $subject); diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index 4f2398d7b..00e2b31c9 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -1033,7 +1033,7 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp */ $DPFields = array( 'paymentaction' => ($order->get_total() > 0) ? $this->payment_action : 'Authorization', // How you want to obtain payment. Authorization indidicates the payment is a basic auth subject to settlement with Auth & Capture. Sale indicates that this is a final sale for which you are requesting payment. Default is Sale. - 'ipaddress' => AngellEYE_Utility::get_user_ip(), // Required. IP address of the payer's browser. + 'ipaddress' => WC_Geolocation::get_ip_address(), // Required. IP address of the payer's browser. 'returnfmfdetails' => '1', // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0. 'softdescriptor' => $this->softdescriptor ); @@ -1368,7 +1368,7 @@ function do_payment($order, $card_number, $card_type, $card_exp_month, $card_exp $message = __("DoDirectPayment API call failed.", "paypal-for-woocommerce") . "\n\n"; $message .= __('Error Code: ', 'paypal-for-woocommerce') . $error_code . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $long_message . "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message .= __('Order ID: ') . $order_id . "\n"; $message .= __('Customer Name: ') . $firstname . ' ' . $lastname . "\n"; $message .= __('Customer Email: ') . $billing_email . "\n"; @@ -1610,7 +1610,7 @@ public function paypal_pro_error_handler($request_name = '', $redirect_url = '', $message .= __('Error Severity Code: ', 'paypal-for-woocommerce') . $ErrorSeverityCode . "\n"; $message .= __('Short Error Message: ', 'paypal-for-woocommerce') . $ErrorShortMsg . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $ErrorLongMsg . "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $error_email_notify_mes = apply_filters('ae_ppec_error_email_message', $message, $ErrorCode, $ErrorSeverityCode, $ErrorShortMsg, $ErrorLongMsg); $subject = "PayPal Pro Error Notification"; $error_email_notify_subject = apply_filters('ae_ppec_error_email_subject', $subject); @@ -1641,7 +1641,7 @@ public function add_payment_method($order = null) { $this->angelleye_load_paypal_pro_class($this->gateway, $this, null); $DPFields = array( 'paymentaction' => 'Authorization', - 'ipaddress' => AngellEYE_Utility::get_user_ip(), + 'ipaddress' => WC_Geolocation::get_ip_address(), 'returnfmfdetails' => '1', 'softdescriptor' => $this->softdescriptor ); @@ -1780,7 +1780,7 @@ public function process_subscription_payment($order) { $this->calculation_angelleye = new WC_Gateway_Calculation_AngellEYE(null, $this->subtotal_mismatch_behavior); $DPFields = array( 'paymentaction' => !empty($this->payment_action) ? $this->payment_action : 'Sale', // How you want to obtain payment. Authorization indidicates the payment is a basic auth subject to settlement with Auth & Capture. Sale indicates that this is a final sale for which you are requesting payment. Default is Sale. - 'ipaddress' => AngellEYE_Utility::get_user_ip(), // Required. IP address of the payer's browser. + 'ipaddress' => WC_Geolocation::get_ip_address(), // Required. IP address of the payer's browser. 'returnfmfdetails' => '1', // Flag to determine whether you want the results returned by FMF. 1 or 0. Default is 0. 'softdescriptor' => $this->softdescriptor ); @@ -1942,7 +1942,7 @@ public function process_subscription_payment($order) { $message = __("DoDirectPayment API call failed.", "paypal-for-woocommerce") . "\n\n"; $message .= __('Error Code: ', 'paypal-for-woocommerce') . $error_code . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $long_message . "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message .= __('Order ID: ') . $order_id . "\n"; $message .= __('Customer Name: ') . $billing_first_name . ' ' . $billing_last_name . "\n"; $message .= __('Customer Email: ') . $billing_email . "\n"; @@ -2203,7 +2203,7 @@ public function subscription_change_payment($order_id) { $this->angelleye_load_paypal_pro_class($this->gateway, $this, $order_id); $DPFields = array( 'paymentaction' => 'Authorization', - 'ipaddress' => AngellEYE_Utility::get_user_ip(), + 'ipaddress' => WC_Geolocation::get_ip_address(), 'returnfmfdetails' => '1', 'softdescriptor' => $this->softdescriptor ); diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index 6f3de0a68..902107680 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -846,7 +846,7 @@ function process_payment($order_id) { $message .= __('Error Code: ', 'paypal-for-woocommerce') . $PayPalResult['RESULT'] . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $PayPalResult['RESPMSG']; $message .= isset($PayPalResult['PREFPSMSG']) && $PayPalResult['PREFPSMSG'] != '' ? ' - ' . $PayPalResult['PREFPSMSG'] . "\n" : "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message .= __('Order ID: ') . $order_id . "\n"; $message .= __('Customer Name: ') . $firstname . ' ' . $lastname . "\n"; $message .= __('Customer Email: ') . $billing_email . "\n"; @@ -1134,7 +1134,7 @@ function do_payment($order, $card_number, $card_exp, $card_csc, $centinel = null 'origid' => '', // Required by some transaction types. ID of the original transaction referenced. The PNREF parameter returns this ID, and it appears as the Transaction ID in PayPal Manager reports. 'custref' => '', // 'custcode' => '', // - 'custip' => AngellEYE_Utility::get_user_ip(), // + 'custip' => WC_Geolocation::get_ip_address(), // 'invnum' => $this->invoice_id_prefix . str_replace("#", "", $order->get_order_number()), // 'ponum' => '', // 'starttime' => '', // For inquiry transaction when using CUSTREF to specify the transaction. @@ -1249,6 +1249,7 @@ function do_payment($order, $card_number, $card_exp, $card_csc, $centinel = null $order->update_status('failed', __('Payment failed due to a duplicate order ID.', 'paypal-for-woocommerce')); throw new Exception(__('Payment failed due to duplicate order ID', 'paypal-for-woocommerce')); } + $order->add_order_note(sprintf(__('Response message: %s', 'paypal-for-woocommerce'), $PayPalResult['RESPMSG'])); $avs_address_response_code = isset($PayPalResult['AVSADDR']) ? $PayPalResult['AVSADDR'] : ''; $avs_zip_response_code = isset($PayPalResult['AVSZIP']) ? $PayPalResult['AVSZIP'] : ''; $proc_avs_response_code = isset($PayPalResult['PROCAVS']) ? $PayPalResult['PROCAVS'] : ''; @@ -1275,6 +1276,7 @@ function do_payment($order, $card_number, $card_exp, $card_csc, $centinel = null $cvv2_response_order_note = __('Card Security Code Result', 'paypal-for-woocommerce'); $cvv2_response_order_note .= "\n"; $cvv2_response_order_note .= sprintf(__('CVV2 Match: %s', 'paypal-for-woocommerce'), $cvv2_response_code); + if ($old_wc) { update_post_meta($order_id, '_CVV2MATCH', $cvv2_response_code); update_post_meta($order_id, 'is_sandbox', $this->testmode); @@ -1411,7 +1413,7 @@ function do_payment($order, $card_number, $card_exp, $card_csc, $centinel = null $message .= __('Error Code: ', 'paypal-for-woocommerce') . $PayPalResult['RESULT'] . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $PayPalResult['RESPMSG']; $message .= isset($PayPalResult['PREFPSMSG']) && $PayPalResult['PREFPSMSG'] != '' ? ' - ' . $PayPalResult['PREFPSMSG'] . "\n" : "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message .= __('Order ID: ') . $order_id . "\n"; $message .= __('Customer Name: ') . $firstname . ' ' . $lastname . "\n"; $message .= __('Customer Email: ') . $billing_email . "\n"; @@ -1744,7 +1746,7 @@ public function add_payment_method() { 'origid' => '', 'custref' => '', 'custcode' => '', - 'custip' => AngellEYE_Utility::get_user_ip(), + 'custip' => WC_Geolocation::get_ip_address(), 'invnum' => '', 'ponum' => '', 'starttime' => '', @@ -1843,7 +1845,7 @@ public function process_subscription_payment($order, $amount, $payment_token = n 'origid' => '', // Required by some transaction types. ID of the original transaction referenced. The PNREF parameter returns this ID, and it appears as the Transaction ID in PayPal Manager reports. 'custref' => '', // 'custcode' => '', // - 'custip' => AngellEYE_Utility::get_user_ip(), // + 'custip' => WC_Geolocation::get_ip_address(), // 'invnum' => $this->invoice_id_prefix . str_replace("#", "", $order->get_order_number()), // 'ponum' => '', // 'starttime' => '', // For inquiry transaction when using CUSTREF to specify the transaction. @@ -2017,7 +2019,7 @@ public function process_subscription_payment($order, $amount, $payment_token = n $message .= __('Error Code: ', 'paypal-for-woocommerce') . $PayPalResult['RESULT'] . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $PayPalResult['RESPMSG']; $message .= isset($PayPalResult['PREFPSMSG']) && $PayPalResult['PREFPSMSG'] != '' ? ' - ' . $PayPalResult['PREFPSMSG'] . "\n" : "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message .= __('Order ID: ') . $order_id . "\n"; $message .= __('Customer Name: ') . $firstname . ' ' . $lastname . "\n"; $message .= __('Customer Email: ') . $billing_email . "\n"; @@ -2071,7 +2073,7 @@ public function are_reference_transactions_enabled($token_id) { 'origid' => $token_id, 'custref' => '', 'custcode' => '', - 'custip' => AngellEYE_Utility::get_user_ip(), + 'custip' => WC_Geolocation::get_ip_address(), 'invnum' => '', 'ponum' => '', 'starttime' => '', @@ -2088,7 +2090,7 @@ public function are_reference_transactions_enabled($token_id) { $message .= __('Error Code: ', 'paypal-for-woocommerce') . $PayPalResult['RESULT'] . "\n"; $message .= __('Detailed Error Message: ', 'paypal-for-woocommerce') . $PayPalResult['RESPMSG']; $message .= isset($PayPalResult['PREFPSMSG']) && $PayPalResult['PREFPSMSG'] != '' ? ' - ' . $PayPalResult['PREFPSMSG'] . "\n" : "\n"; - $message .= __('User IP: ', 'paypal-for-woocommerce') . AngellEYE_Utility::get_user_ip() . "\n"; + $message .= __('User IP: ', 'paypal-for-woocommerce') . WC_Geolocation::get_ip_address() . "\n"; $message = apply_filters('ae_pppf_error_email_message', $message); $subject = apply_filters('ae_pppf_error_email_subject', "PayPal Payments Pro (PayFlow) Error Notification"); wp_mail($admin_email, $subject, $message); @@ -2289,7 +2291,7 @@ public function subscription_change_payment($order_id) { 'origid' => '', 'custref' => '', 'custcode' => '', - 'custip' => AngellEYE_Utility::get_user_ip(), + 'custip' => WC_Geolocation::get_ip_address(), 'invnum' => '', 'ponum' => '', 'starttime' => '',