Skip to content

Commit b5afaf4

Browse files
committed
ACP2E-1338: Google reCaptcha in Incorrect position
1 parent b53fbed commit b5afaf4

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

ReCaptchaCheckout/view/frontend/web/js/reCaptchaCheckout.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
// jscs:disable jsDoc
7-
8-
/* global grecaptcha */
96
define(
107
[
118
'Magento_ReCaptchaWebapiUi/js/webapiReCaptcha',
@@ -22,23 +19,36 @@ define(
2219

2320
/**
2421
* Render reCAPTCHA
22+
*
23+
* @param {Object} method
2524
*/
26-
renderReCaptchaForPayment: function (method) {
25+
renderReCaptchaFor: function (method) {
2726
var reCaptcha;
2827

29-
if (!this.skipPayments || !this.skipPayments.hasOwnProperty(method.getCode())) {
30-
reCaptcha = $.extend({}, this);
31-
32-
reCaptcha.reCaptchaId = this.getPaymentReCaptchaId(method);
28+
if (this.isCheckoutReCaptchaRequiredFor(method)) {
29+
reCaptcha = $.extend(true, {}, this, {reCaptchaId: this.getReCaptchaIdFor(method)});
3330
reCaptcha.renderReCaptcha();
3431
}
3532
},
3633

3734
/**
38-
* Render reCAPTCHA
35+
* Get reCAPTCHA ID
36+
*
37+
* @param {Object} method
38+
* @returns {String}
3939
*/
40-
getPaymentReCaptchaId: function (method) {
40+
getReCaptchaIdFor: function (method) {
4141
return this.getReCaptchaId() + '-' + method.getCode();
42+
},
43+
44+
/**
45+
* Check whether checkout reCAPTCHA is required for payment method
46+
*
47+
* @param {Object} method
48+
* @returns {Boolean}
49+
*/
50+
isCheckoutReCaptchaRequiredFor: function (method) {
51+
return !this.skipPayments || !this.skipPayments.hasOwnProperty(method.getCode());
4252
}
4353
});
4454
}

ReCaptchaCheckout/view/frontend/web/template/reCaptcha.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* See COPYING.txt for license details.
55
*/
66
-->
7-
7+
<!-- ko if: (isCheckoutReCaptchaRequiredFor($parents[1]))-->
88
<div data-bind="{
99
attr: {
10-
'id': getPaymentReCaptchaId($parents[1]) + '-wrapper'
10+
'id': getReCaptchaIdFor($parents[1]) + '-wrapper'
1111
},
12-
'afterRender': renderReCaptchaForPayment($parents[1])
12+
'afterRender': renderReCaptchaFor($parents[1])
1313
}">
1414
<div class="g-recaptcha"></div>
1515
<!-- ko if: (!getIsInvisibleRecaptcha()) -->
@@ -25,3 +25,4 @@
2525
</div>
2626
<!-- /ko -->
2727
</div>
28+
<!-- /ko -->

ReCaptchaPaypal/Plugin/SkipPlaceOrderRecaptchaValidation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
}
4242

4343
/**
44-
* Skip captcha validation for "place order" button if captcha is enabled for payflow
44+
* Skip captcha validation for "place order" button if captcha is enabled for payflowpro
4545
*
4646
* @param WebapiConfigProvider $subject
4747
* @param ValidationConfigInterface $result

0 commit comments

Comments
 (0)