From 346c03356325a38fb9a60f416399393e1ccbc896 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 4 Aug 2020 13:29:49 +0530 Subject: [PATCH 1/9] Add fields, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 31 +++++++++++++++++++ ...c-gateway-paypal-pro-payflow-angelleye.php | 30 ++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index 5367451de..c348edb56 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -156,6 +156,9 @@ function __construct() { $this->api_password = $this->get_option('sandbox_api_password'); $this->api_signature = $this->get_option('sandbox_api_signature'); } + $this->enable_google_recaptcha = 'yes' === $this->get_option('enable_google_recaptcha', 'no'); + $this->recaptcha_site_key = $this->get_option('recaptcha_site_key', ''); + $this->recaptcha_secret_key = $this->get_option('recaptcha_secret_key', ''); // Maestro if (!$this->enable_3dsecure) { unset($this->available_card_types['GB']['Maestro']); @@ -473,6 +476,25 @@ function init_form_fields() { ), 'default' => 'four_digit' ), + 'enable_google_recaptcha' => array( + 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), + 'label' => __('Enable Google reCAPTCHA', 'paypal-for-woocommerce'), + 'type' => 'checkbox', + 'description' => 'Sign up and get your keys here: https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', + 'default' => 'no' + ), + 'recaptcha_site_key' => array( + 'title' => __('reCAPTCHA SITE key', 'paypal-for-woocommerce'), + 'type' => 'text', + 'description' => __('', 'paypal-for-woocommerce'), + 'default' => '' + ), + 'recaptcha_secret_key' => array( + 'title' => __('reCAPTCHA SECRET key', 'paypal-for-woocommerce'), + 'type' => 'text', + 'description' => __('', 'paypal-for-woocommerce'), + 'default' => '' + ), 'debug' => array( 'title' => __('Debug Log', 'paypal-for-woocommerce'), 'type' => 'checkbox', @@ -532,6 +554,14 @@ public function admin_options() { production.show(); } }).change(); + jQuery('#woocommerce_paypal_pro_enable_google_recaptcha').change(function () { + var google_recaptcha_fields = jQuery('#woocommerce_paypal_pro_recaptcha_site_key, #woocommerce_paypal_pro_recaptcha_secret_key').closest('tr'); + if (jQuery(this).is(':checked')) { + google_recaptcha_fields.show(); + } else { + google_recaptcha_fields.hide(); + } + }).change(); jQuery('#woocommerce_paypal_pro_send_items').change(function () { var paypal_pro_subtotal_mismatch_behavior = jQuery('#woocommerce_paypal_pro_subtotal_mismatch_behavior').closest('tr'); if (jQuery(this).is(':checked')) { @@ -586,6 +616,7 @@ public function log($message, $level = 'info') { */ public function payment_fields() { do_action('before_angelleye_pc_payment_fields', $this); + wp_enqueue_script('google-recaptcha', 'https://www.google.com/recaptcha/api.js', array('jquery'), null, false); if ($this->description) { echo '

' . wp_kses_post($this->description); } diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index d5c912252..c79e601a0 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -166,6 +166,7 @@ function __construct() { $this->fraud_codes = array('125', '128', '131', '126', '127'); $this->fraud_error_codes = array('125', '128', '131'); $this->fraud_warning_codes = array('126', '127'); + $this->enable_google_recaptcha = 'yes' === $this->get_option('enable_google_recaptcha', 'no'); do_action('angelleye_paypal_for_woocommerce_multi_account_api_' . $this->id, $this, null, null); } @@ -516,6 +517,25 @@ function init_form_fields() { 'description' => __('Display card holder first and last name in credit card form.', 'paypal-for-woocommerce'), 'default' => 'no' ), + 'enable_google_recaptcha' => array( + 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), + 'label' => __('Enable Google reCAPTCHA', 'paypal-for-woocommerce'), + 'type' => 'checkbox', + 'description' => 'Sign up and get your keys here: https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', + 'default' => 'no' + ), + 'recaptcha_site_key' => array( + 'title' => __('reCAPTCHA SITE key', 'paypal-for-woocommerce'), + 'type' => 'text', + 'description' => __('', 'paypal-for-woocommerce'), + 'default' => '' + ), + 'recaptcha_secret_key' => array( + 'title' => __('reCAPTCHA SECRET key', 'paypal-for-woocommerce'), + 'type' => 'text', + 'description' => __('', 'paypal-for-woocommerce'), + 'default' => '' + ), 'debug' => array( 'title' => __('Debug Log', 'paypal-for-woocommerce'), 'type' => 'checkbox', @@ -614,6 +634,14 @@ public function admin_options() { production.show(); } }).change(); + jQuery('#woocommerce_paypal_pro_payflow_enable_google_recaptcha').change(function () { + var payflow_google_recaptcha_fields = jQuery('#woocommerce_paypal_pro_payflow_recaptcha_site_key, #woocommerce_paypal_pro_payflow_recaptcha_secret_key').closest('tr'); + if (jQuery(this).is(':checked')) { + payflow_google_recaptcha_fields.show(); + } else { + payflow_google_recaptcha_fields.hide(); + } + }).change(); jQuery('#woocommerce_paypal_pro_payflow_send_items').change(function () { var payflow_subtotal_mismatch_behavior = jQuery('#woocommerce_paypal_pro_payflow_subtotal_mismatch_behavior').closest('tr'); if (jQuery(this).is(':checked')) { @@ -1520,6 +1548,8 @@ public function payment_fields() { } else { $this->form(); } + wp_enqueue_script('google-recaptcha', 'https://www.google.com/recaptcha/api.js', array('jquery'), null, false); + echo '

'; do_action('payment_fields_saved_payment_methods', $this); } From 5300990c740d08bd0b9b34f1e9370fe9ef37d6f3 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 4 Aug 2020 16:43:06 +0530 Subject: [PATCH 2/9] Add Google recaptcha verification code, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 53 +++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index e6fad179e..65f32c69b 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -159,6 +159,11 @@ function __construct() { $this->enable_google_recaptcha = 'yes' === $this->get_option('enable_google_recaptcha', 'no'); $this->recaptcha_site_key = $this->get_option('recaptcha_site_key', ''); $this->recaptcha_secret_key = $this->get_option('recaptcha_secret_key', ''); + if($this->enable_google_recaptcha) { + if(empty($this->recaptcha_site_key) || empty($this->recaptcha_secret_key)) { + $this->enable_google_recaptcha = false; + } + } // Maestro if (!$this->enable_3dsecure) { unset($this->available_card_types['GB']['Maestro']); @@ -644,6 +649,33 @@ public function payment_fields() { $this->form(); } do_action('payment_fields_saved_payment_methods', $this); + if( $this->enable_google_recaptcha ) { + wp_enqueue_script('pfw_recaptcha', 'https://www.google.com/recaptcha/api.js?render='.$this->recaptcha_site_key, array(), '', true); + echo ''; + ?> + + + enable_google_recaptcha ) { + if(isset($_POST['pfw_google']) && !empty($_POST['pfw_google']) ) { + $response_data = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array( + 'body' => array('secret' => $this->recaptcha_secret_key, 'response' => $_POST['pfw_google']) + ) ); + if (is_wp_error($response_data)) { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } + $body = wp_remote_retrieve_body($response_data); + if( !empty($body)) { + $response = json_decode($body); + if(!$response->success ) { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } elseif($response->score == 0.0) { + throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); + } + } + } else { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } + } if (isset($_POST['wc-paypal_pro-payment-token']) && 'new' !== $_POST['wc-paypal_pro-payment-token']) { $token_id = wc_clean($_POST['wc-paypal_pro-payment-token']); $token = WC_Payment_Tokens::get($token_id); From 9f047bcf970ebafd1c5e8a4aa3a8104c15184a55 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 4 Aug 2020 17:38:26 +0530 Subject: [PATCH 3/9] update hook, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 106 ++++++++++-------- ...c-gateway-paypal-pro-payflow-angelleye.php | 65 ++++++++++- 2 files changed, 119 insertions(+), 52 deletions(-) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index 65f32c69b..ab2699e86 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -191,6 +191,9 @@ function __construct() { $this->calculation_angelleye = new WC_Gateway_Calculation_AngellEYE(); } do_action( 'angelleye_paypal_for_woocommerce_multi_account_api_' . $this->id, $this, null, null ); + if( $this->enable_google_recaptcha ) { + add_action('angelleye_pfw_add_google_recaptcha', array($this, 'own_angelleye_pfw_add_google_recaptcha')); + } } /** @@ -621,7 +624,7 @@ public function log($message, $level = 'info') { */ public function payment_fields() { do_action('before_angelleye_pc_payment_fields', $this); - wp_enqueue_script('google-recaptcha', 'https://www.google.com/recaptcha/api.js', array('jquery'), null, false); + if ($this->description) { echo '

' . wp_kses_post($this->description); } @@ -649,33 +652,7 @@ public function payment_fields() { $this->form(); } do_action('payment_fields_saved_payment_methods', $this); - if( $this->enable_google_recaptcha ) { - wp_enqueue_script('pfw_recaptcha', 'https://www.google.com/recaptcha/api.js?render='.$this->recaptcha_site_key, array(), '', true); - echo ''; - ?> - - - enable_google_recaptcha ) { - if(isset($_POST['pfw_google']) && !empty($_POST['pfw_google']) ) { - $response_data = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array( - 'body' => array('secret' => $this->recaptcha_secret_key, 'response' => $_POST['pfw_google']) - ) ); - if (is_wp_error($response_data)) { - throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); - } - $body = wp_remote_retrieve_body($response_data); - if( !empty($body)) { - $response = json_decode($body); - if(!$response->success ) { - throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); - } elseif($response->score == 0.0) { - throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); - } - } - } else { - throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); - } - } + + $this->angelleye_pfw_validate_google_recaptcha(); if (isset($_POST['wc-paypal_pro-payment-token']) && 'new' !== $_POST['wc-paypal_pro-payment-token']) { $token_id = wc_clean($_POST['wc-paypal_pro-payment-token']); $token = WC_Payment_Tokens::get($token_id); @@ -2391,4 +2349,54 @@ public function angelleye_successwithwarning_payment_response_handler($order, $P } } } + + public function own_angelleye_pfw_add_google_recaptcha() { + if( $this->enable_google_recaptcha ) { + wp_enqueue_script('pfw_recaptcha', 'https://www.google.com/recaptcha/api.js?render='.$this->recaptcha_site_key, array(), '', true); + echo ''; + ?> + + enable_google_recaptcha ) { + if(isset($_POST['pfw_google']) && !empty($_POST['pfw_google']) ) { + $response_data = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array( + 'body' => array('secret' => $this->recaptcha_secret_key, 'response' => $_POST['pfw_google']) + ) ); + if (is_wp_error($response_data)) { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } + $body = wp_remote_retrieve_body($response_data); + if( !empty($body)) { + $response = json_decode($body); + if(!$response->success ) { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } elseif($response->score === 0.0) { + throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); + } + } + } else { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } + } + } } diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index 8c8d9d3bc..40c2e7b7c 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -167,7 +167,17 @@ function __construct() { $this->fraud_error_codes = array('125', '128', '131'); $this->fraud_warning_codes = array('126', '127'); $this->enable_google_recaptcha = 'yes' === $this->get_option('enable_google_recaptcha', 'no'); + $this->recaptcha_site_key = $this->get_option('recaptcha_site_key', ''); + $this->recaptcha_secret_key = $this->get_option('recaptcha_secret_key', ''); + if($this->enable_google_recaptcha) { + if(empty($this->recaptcha_site_key) || empty($this->recaptcha_secret_key)) { + $this->enable_google_recaptcha = false; + } + } do_action('angelleye_paypal_for_woocommerce_multi_account_api_' . $this->id, $this, null, null); + if( $this->enable_google_recaptcha ) { + add_action('angelleye_pfw_payflow_add_google_recaptcha', array($this, 'own_angelleye_pfw_payflow_add_google_recaptcha')); + } } public function add_log($message, $level = 'info') { @@ -1548,9 +1558,8 @@ public function payment_fields() { } else { $this->form(); } - wp_enqueue_script('google-recaptcha', 'https://www.google.com/recaptcha/api.js', array('jquery'), null, false); - echo '

'; do_action('payment_fields_saved_payment_methods', $this); + do_action('angelleye_pfw_payflow_add_google_recaptcha'); } public function save_payment_method_checkbox() { @@ -1668,7 +1677,7 @@ public function process_refund($order_id, $amount = null, $reason = '') { * @since 1.1.7.6 */ public function validate_fields() { - + $this->angelleye_pfw_payflow_validate_google_recaptcha(); if (isset($_POST['wc-paypal_pro_payflow-payment-token']) && 'new' !== $_POST['wc-paypal_pro_payflow-payment-token']) { $token_id = wc_clean($_POST['wc-paypal_pro_payflow-payment-token']); $token = WC_Payment_Tokens::get($token_id); @@ -2485,5 +2494,55 @@ public function get_order_item_names( $order ) { $orderdesc = apply_filters( 'ae_pppf_paypal_orderdesc', implode( ', ', $item_names ), $order ); return substr($orderdesc, 0, 127); } + + public function angelleye_pfw_payflow_add_google_recaptcha() { + if( $this->enable_google_recaptcha ) { + wp_enqueue_script('pfw_payflow_recaptcha', 'https://www.google.com/recaptcha/api.js?render='.$this->recaptcha_site_key, array(), '', true); + echo ''; + ?> + + enable_google_recaptcha ) { + if(isset($_POST['pfw_payflow_google']) && !empty($_POST['pfw_payflow_google']) ) { + $response_data = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array( + 'body' => array('secret' => $this->recaptcha_secret_key, 'response' => $_POST['pfw_payflow_google']) + ) ); + if (is_wp_error($response_data)) { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } + $body = wp_remote_retrieve_body($response_data); + if( !empty($body)) { + $response = json_decode($body); + if(!$response->success ) { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } elseif($response->score === 0.0) { + throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); + } + } + } else { + throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); + } + } + } } From 9d739c6ce468017f3da44d55d897f5530e072af0 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Tue, 4 Aug 2020 17:55:32 +0530 Subject: [PATCH 4/9] update function name, PFW-668 --- classes/wc-gateway-paypal-pro-payflow-angelleye.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index 40c2e7b7c..70ec97681 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -2495,7 +2495,7 @@ public function get_order_item_names( $order ) { return substr($orderdesc, 0, 127); } - public function angelleye_pfw_payflow_add_google_recaptcha() { + public function own_angelleye_pfw_payflow_add_google_recaptcha() { if( $this->enable_google_recaptcha ) { wp_enqueue_script('pfw_payflow_recaptcha', 'https://www.google.com/recaptcha/api.js?render='.$this->recaptcha_site_key, array(), '', true); echo ''; From 6fb1a327b6e50b8514e6772e6be286e6b42af335 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Thu, 6 Aug 2020 09:48:24 +0530 Subject: [PATCH 5/9] update condition, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 3 ++- classes/wc-gateway-paypal-pro-payflow-angelleye.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index ab2699e86..66e02ee5c 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -2390,7 +2390,8 @@ public function angelleye_pfw_validate_google_recaptcha() { $response = json_decode($body); if(!$response->success ) { throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); - } elseif($response->score === 0.0) { + } + if($response->score == 0.0) { throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); } } diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index 70ec97681..b05a97485 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -2535,7 +2535,8 @@ public function angelleye_pfw_payflow_validate_google_recaptcha() { $response = json_decode($body); if(!$response->success ) { throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); - } elseif($response->score === 0.0) { + } + if($response->score == 0.0) { throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); } } From 5a3f546005f9df2b2282e5771d23be775c33b26b Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Thu, 6 Aug 2020 11:01:18 +0530 Subject: [PATCH 6/9] update label, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 2 +- classes/wc-gateway-paypal-pro-payflow-angelleye.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index 66e02ee5c..a5bf7cfe9 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -486,7 +486,7 @@ function init_form_fields() { ), 'enable_google_recaptcha' => array( 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), - 'label' => __('Enable Google reCAPTCHA', 'paypal-for-woocommerce'), + 'label' => __('Enable Google reCAPTCHA v3', 'paypal-for-woocommerce'), 'type' => 'checkbox', 'description' => 'Sign up and get your keys here: https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', 'default' => 'no' diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index b05a97485..6eff0a893 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -529,7 +529,7 @@ function init_form_fields() { ), 'enable_google_recaptcha' => array( 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), - 'label' => __('Enable Google reCAPTCHA', 'paypal-for-woocommerce'), + 'label' => __('Enable Google reCAPTCHA v3', 'paypal-for-woocommerce'), 'type' => 'checkbox', 'description' => 'Sign up and get your keys here: https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', 'default' => 'no' From 2cb58808366a6dd33f71cadbfae1b5cea102f3b8 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Thu, 6 Aug 2020 13:24:32 +0530 Subject: [PATCH 7/9] Update score logic, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 10 +++++----- classes/wc-gateway-paypal-pro-payflow-angelleye.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index a5bf7cfe9..60cfc0c73 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -492,15 +492,15 @@ function init_form_fields() { 'default' => 'no' ), 'recaptcha_site_key' => array( - 'title' => __('reCAPTCHA SITE key', 'paypal-for-woocommerce'), + 'title' => __('reCAPTCHA V3 - Site Key', 'paypal-for-woocommerce'), 'type' => 'text', - 'description' => __('', 'paypal-for-woocommerce'), + 'description' => __('Please enter only Google reCAPTCHA V3 Credentials, V2 Credentials are not supported', 'paypal-for-woocommerce'), 'default' => '' ), 'recaptcha_secret_key' => array( - 'title' => __('reCAPTCHA SECRET key', 'paypal-for-woocommerce'), + 'title' => __('reCAPTCHA V3 - Secret Key', 'paypal-for-woocommerce'), 'type' => 'text', - 'description' => __('', 'paypal-for-woocommerce'), + 'description' => __('Please enter only Google reCAPTCHA V3 Credentials, V2 Credentials are not supported', 'paypal-for-woocommerce'), 'default' => '' ), 'debug' => array( @@ -2391,7 +2391,7 @@ public function angelleye_pfw_validate_google_recaptcha() { if(!$response->success ) { throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); } - if($response->score == 0.0) { + if($response->score < 0.2) { throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); } } diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index 6eff0a893..26ca3f9f9 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -535,15 +535,15 @@ function init_form_fields() { 'default' => 'no' ), 'recaptcha_site_key' => array( - 'title' => __('reCAPTCHA SITE key', 'paypal-for-woocommerce'), + 'title' => __('reCAPTCHA V3 - Site Key', 'paypal-for-woocommerce'), 'type' => 'text', - 'description' => __('', 'paypal-for-woocommerce'), + 'description' => __('Please enter only Google reCAPTCHA V3 Credentials, V2 Credentials are not supported', 'paypal-for-woocommerce'), 'default' => '' ), 'recaptcha_secret_key' => array( - 'title' => __('reCAPTCHA SECRET key', 'paypal-for-woocommerce'), + 'title' => __('reCAPTCHA V3 - Secret Key', 'paypal-for-woocommerce'), 'type' => 'text', - 'description' => __('', 'paypal-for-woocommerce'), + 'description' => __('Please enter only Google reCAPTCHA V3 Credentials, V2 Credentials are not supported', 'paypal-for-woocommerce'), 'default' => '' ), 'debug' => array( @@ -2536,7 +2536,7 @@ public function angelleye_pfw_payflow_validate_google_recaptcha() { if(!$response->success ) { throw new Exception(__('Google recaptcha verification Failed', 'paypal-for-woocommerce')); } - if($response->score == 0.0) { + if($response->score < 0.2) { throw new Exception(__('Very likely a bot', 'paypal-for-woocommerce')); } } From 567685852f103f886abc0d7a8388a9627222dadd Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Thu, 6 Aug 2020 13:34:50 +0530 Subject: [PATCH 8/9] update reCAPTCHA URL, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 2 +- classes/wc-gateway-paypal-pro-payflow-angelleye.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index 60cfc0c73..d233194ba 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -488,7 +488,7 @@ function init_form_fields() { 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), 'label' => __('Enable Google reCAPTCHA v3', 'paypal-for-woocommerce'), 'type' => 'checkbox', - 'description' => 'Sign up and get your keys here: https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', + 'description' => 'Sign up and get your keys : https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', 'default' => 'no' ), 'recaptcha_site_key' => array( diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index 26ca3f9f9..de383f264 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -531,7 +531,7 @@ function init_form_fields() { 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), 'label' => __('Enable Google reCAPTCHA v3', 'paypal-for-woocommerce'), 'type' => 'checkbox', - 'description' => 'Sign up and get your keys here: https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', + 'description' => 'Sign up and get your keys : https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', 'default' => 'no' ), 'recaptcha_site_key' => array( From f4bb6883bdff61c6b09de4e13e634ac9eca89143 Mon Sep 17 00:00:00 2001 From: kcppdevelopers Date: Thu, 6 Aug 2020 13:39:34 +0530 Subject: [PATCH 9/9] update link, PFW-668 --- classes/wc-gateway-paypal-pro-angelleye.php | 2 +- classes/wc-gateway-paypal-pro-payflow-angelleye.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/wc-gateway-paypal-pro-angelleye.php b/classes/wc-gateway-paypal-pro-angelleye.php index d233194ba..3a28d5b91 100644 --- a/classes/wc-gateway-paypal-pro-angelleye.php +++ b/classes/wc-gateway-paypal-pro-angelleye.php @@ -488,7 +488,7 @@ function init_form_fields() { 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), 'label' => __('Enable Google reCAPTCHA v3', 'paypal-for-woocommerce'), 'type' => 'checkbox', - 'description' => 'Sign up and get your keys : https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', + 'description' => 'Sign up and get your keys : https://www.google.com/recaptcha/admin/create (you will get a SITE key and a SECRET key)', 'default' => 'no' ), 'recaptcha_site_key' => array( diff --git a/classes/wc-gateway-paypal-pro-payflow-angelleye.php b/classes/wc-gateway-paypal-pro-payflow-angelleye.php index de383f264..78c7d8a99 100644 --- a/classes/wc-gateway-paypal-pro-payflow-angelleye.php +++ b/classes/wc-gateway-paypal-pro-payflow-angelleye.php @@ -531,7 +531,7 @@ function init_form_fields() { 'title' => __('Enable/Disable', 'paypal-for-woocommerce'), 'label' => __('Enable Google reCAPTCHA v3', 'paypal-for-woocommerce'), 'type' => 'checkbox', - 'description' => 'Sign up and get your keys : https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key)', + 'description' => 'Sign up and get your keys : https://www.google.com/recaptcha/admin/create (you will get a SITE key and a SECRET key)', 'default' => 'no' ), 'recaptcha_site_key' => array(