Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IP not being captured and forwarded to PayPal, PFW-484 #1381

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions angelleye-includes/angelleye-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<div class="error angelleye-notice" style="display:none;"><div class="angelleye-notice-logo"><span></span></div><div class="angelleye-notice-message">' . __('PayPal for WooCommerce requires WooCommerce version 2.6 or higher. Please backup your site files and database, update WooCommerce, and try again.','paypal-for-woocommerce') . '</div></div>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
Expand Down Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions classes/wc-gateway-paypal-advanced-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions classes/wc-gateway-paypal-pro-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
);
Expand Down
20 changes: 11 additions & 9 deletions classes/wc-gateway-paypal-pro-payflow-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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'] : '';
Expand All @@ -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);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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' => '',
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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' => '',
Expand All @@ -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);
Expand Down Expand Up @@ -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' => '',
Expand Down