Skip to content

Commit eb527cd

Browse files
naydavviktym
authored andcommitted
MC-30896: Move PayPalRecaptcha module to Magento Security Extension
1 parent cdc79b3 commit eb527cd

File tree

16 files changed

+28
-21
lines changed

16 files changed

+28
-21
lines changed

ReCaptchaAdminUi/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
10-
<virtualType name="Magento\ReCaptchaApi\Model\OptionSource\Type"
10+
<virtualType name="Magento\ReCaptchaAdminUi\Model\OptionSource\Type"
1111
type="Magento\ReCaptchaAdminUi\Model\OptionSource">
1212
<arguments>
1313
<argument name="options" xsi:type="array">

ReCaptchaCheckout/view/frontend/layout/checkout_index_index.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<item name="displayArea" xsi:type="string">additional-login-form-fields</item>
2929
<item name="configSource" xsi:type="string">checkoutConfig</item>
3030
<item name="reCaptchaId" xsi:type="string">recaptcha-checkout-inline-login</item>
31-
<item name="zone" xsi:type="string">login</item>
3231
</item>
3332
</item>
3433
</item>
@@ -47,7 +46,6 @@
4746
<item name="displayArea" xsi:type="string">additional-login-form-fields</item>
4847
<item name="configSource" xsi:type="string">checkoutConfig</item>
4948
<item name="reCaptchaId" xsi:type="string">recaptcha-checkout-inline-login-billing</item>
50-
<item name="zone" xsi:type="string">login</item>
5149
</item>
5250
</item>
5351
</item>

ReCaptchaContact/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<field id="contact" translate="label" type="select" sortOrder="140" showInDefault="1"
1414
showInWebsite="1" showInStore="0" canRestore="1">
1515
<label>Enable for Contact Us</label>
16-
<source_model>Magento\ReCaptchaApi\Model\OptionSource\Type</source_model>
16+
<source_model>Magento\ReCaptchaAdminUi\Model\OptionSource\Type</source_model>
1717
</field>
1818
</group>
1919
</section>

ReCaptchaCustomer/etc/adminhtml/system.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
<field id="customer_login" translate="label" type="select" sortOrder="110" showInDefault="1"
1414
showInWebsite="1" showInStore="0" canRestore="1">
1515
<label>Enable for Customer Login</label>
16-
<source_model>Magento\ReCaptchaApi\Model\OptionSource\Type</source_model>
16+
<source_model>Magento\ReCaptchaAdminUi\Model\OptionSource\Type</source_model>
1717
</field>
1818
<field id="customer_forgot_password" translate="label" type="select" sortOrder="120" showInDefault="1"
1919
showInWebsite="1" showInStore="0" canRestore="1">
2020
<label>Enable for Forgot Password</label>
21-
<source_model>Magento\ReCaptchaApi\Model\OptionSource\Type</source_model>
21+
<source_model>Magento\ReCaptchaAdminUi\Model\OptionSource\Type</source_model>
2222
</field>
2323
<field id="customer_create" translate="label" type="select" sortOrder="130" showInDefault="1"
2424
showInWebsite="1" showInStore="0" canRestore="1">
2525
<label>Enable for Create New Customer Account</label>
26-
<source_model>Magento\ReCaptchaApi\Model\OptionSource\Type</source_model>
26+
<source_model>Magento\ReCaptchaAdminUi\Model\OptionSource\Type</source_model>
2727
</field>
2828
</group>
2929
</section>

ReCaptchaNewsletter/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
showInWebsite="1" showInStore="0" canRestore="1">
1515
<label>Enable Invisible reCAPTCHA in Newsletter Subscription</label>
1616
<comment>If enabled, a badge will be displayed in every page.</comment>
17-
<source_model>Magento\ReCaptchaApi\Model\OptionSource\Type</source_model>
17+
<source_model>Magento\ReCaptchaAdminUi\Model\OptionSource\Type</source_model>
1818
</field>
1919
</group>
2020
</section>

ReCaptchaPaypal/Block/LayoutProcessor/Checkout/Onepage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\ReCaptchaPaypal\Block\LayoutProcessor\Checkout;
99

1010
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
11+
use Magento\Framework\Exception\InputException;
1112
use Magento\ReCaptchaUi\Model\IsCaptchaEnabledInterface;
1213
use Magento\ReCaptchaUi\Model\UiConfigResolverInterface;
1314

@@ -39,10 +40,11 @@ public function __construct(
3940
}
4041

4142
/**
42-
* Process js Layout of block
43+
* {@inheritdoc}
4344
*
4445
* @param array $jsLayout
4546
* @return array
47+
* @throws InputException
4648
*/
4749
public function process($jsLayout)
4850
{

ReCaptchaPaypal/Observer/PayPalObserver.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,21 @@ public function execute(Observer $observer): void
103103
$request = $controller->getRequest();
104104
$response = $controller->getResponse();
105105

106+
$validationConfig = $this->validationConfigResolver->get($key);
107+
106108
try {
107109
$reCaptchaResponse = $this->captchaResponseResolver->resolve($request);
108110
} catch (InputException $e) {
109-
$reCaptchaResponse = '';
110111
$this->logger->error($e);
112+
113+
$jsonPayload = $this->serializer->serialize([
114+
'success' => false,
115+
'error' => true,
116+
'error_messages' => $validationConfig->getValidationFailureMessage(),
117+
]);
118+
$response->representJson($jsonPayload);
119+
return;
111120
}
112-
$validationConfig = $this->validationConfigResolver->get($key);
113121

114122
$validationResult = $this->captchaValidator->isValid($reCaptchaResponse, $validationConfig);
115123
if (false === $validationResult->isValid()) {

ReCaptchaPaypal/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"require": {
55
"php": "~7.1.3||~7.2.0||~7.3.0",
66
"magento/module-re-captcha-frontend-ui": "*",
7-
"magento/module-paypal-captcha": "*"
7+
"magento/module-re-captcha-validation-api": "*"
88
},
99
"type": "magento2-module",
1010
"license": "OSL-3.0",

ReCaptchaPaypal/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<field id="paypal_payflowpro" translate="label" type="select" sortOrder="200" showInDefault="1"
1414
showInWebsite="1" showInStore="0" canRestore="1">
1515
<label>Enable for PayPal PayflowPro payment form</label>
16-
<source_model>Magento\ReCaptchaApi\Model\OptionSource\Type</source_model>
16+
<source_model>Magento\ReCaptchaAdminUi\Model\OptionSource\Type</source_model>
1717
</field>
1818
</group>
1919
</section>

ReCaptchaPaypal/view/frontend/layout/checkout_index_index.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<item name="displayArea" xsi:type="string">additional-payment-fields</item>
3030
<item name="configSource" xsi:type="string">checkoutConfig</item>
3131
<item name="reCaptchaId" xsi:type="string">recaptcha-checkout-paypal-form</item>
32-
<item name="zone" xsi:type="string">paypal</item>
3332
</item>
3433
</item>
3534
</item>

0 commit comments

Comments
 (0)