Skip to content

Commit 348edaa

Browse files
committed
MC-15427: Token Abuse in PayPal Payflow module
- Added Captcha reload on negative place order flow
1 parent b9745a3 commit 348edaa

File tree

2 files changed

+23
-3
lines changed
  • app/code/Magento

2 files changed

+23
-3
lines changed

app/code/Magento/Payment/view/frontend/templates/transparent/iframe.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ $params = $block->getParams();
4040
$(parent).trigger('clearTimeout');
4141
fullScreenLoader.stopLoader();
4242
globalMessageList.addErrorMessage({
43-
message: $t(<?= /* @escapeNotVerified */ json_encode($params['error_msg'])?>)
43+
message: $t(<?= /* @noEscape */ json_encode($params['error_msg'])?>)
4444
});
4545
}
4646
);

app/code/Magento/PaypalCaptcha/view/frontend/web/js/view/payment/list-mixin.js

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

6-
define([], function () {
6+
define([
7+
'jquery',
8+
'Magento_Captcha/js/model/captchaList'
9+
], function ($, captchaList) {
710
'use strict';
811

912
var mixin = {
13+
14+
formId: 'co-payment-form',
15+
1016
/**
1117
* Sets custom template for Payflow Pro
1218
*
@@ -17,11 +23,25 @@ define([], function () {
1723

1824
var component = this._super(payment);
1925

20-
if (payment.method === 'payflowpro') {
26+
if (component.component === 'Magento_Paypal/js/view/payment/method-renderer/payflowpro-method') {
2127
component.template = 'Magento_PaypalCaptcha/payment/payflowpro-form';
28+
$(window).off('clearTimeout')
29+
.on('clearTimeout', this.clearTimeout.bind(this));
2230
}
2331

2432
return component;
33+
},
34+
35+
/**
36+
* Overrides default window.clearTimeout() to catch errors from iframe and reload Captcha.
37+
*/
38+
clearTimeout: function () {
39+
var captcha = captchaList.getCaptchaByFormId(this.formId);
40+
41+
if (captcha !== null) {
42+
captcha.refresh();
43+
}
44+
clearTimeout();
2545
}
2646
};
2747

0 commit comments

Comments
 (0)