Skip to content

Commit

Permalink
Merge pull request #532 from FatchipRobert/MAG2-306-Ratepay-Device-Fi…
Browse files Browse the repository at this point in the history
…ngerprint

MAG2-306 - Load Ratepay device fingerprint script only when needed
  • Loading branch information
janteuber authored Mar 13, 2024
2 parents c15511b + 62e73f5 commit f4d50ff
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 256 deletions.
111 changes: 0 additions & 111 deletions Block/RatepayDeviceFingerprint.php

This file was deleted.

2 changes: 2 additions & 0 deletions Helper/Ratepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ public function getRatepayConfig()
$aReturn[$sRatepayMethod] = $this->getRatepaySingleConfig($sRatepayMethod);
}
}
$aReturn['snippetId'] = $this->getConfigParam('devicefingerprint_snippet_id', 'ratepay', 'payone_misc');
$aReturn['token'] = $this->getRatepayDeviceFingerprintToken();
return $aReturn;
}

Expand Down
106 changes: 0 additions & 106 deletions Test/Unit/Block/RatepayDeviceFingerprintTest.php

This file was deleted.

1 change: 0 additions & 1 deletion view/frontend/layout/checkout_index_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@
<referenceBlock name="content">
<block class="Payone\Core\Block\ClientApi" name="payone_client_api" template="client_api.phtml"/>
<block class="Payone\Core\Block\RedirectReturn" name="payone_redirect_return" template="redirect_return.phtml"/>
<block class="Payone\Core\Block\RatepayDeviceFingerprint" name="payone_ratepay_device_fingerprint" template="ratepay_device_fingerprint.phtml"/>
</referenceBlock>
</body>
</page>
37 changes: 0 additions & 37 deletions view/frontend/templates/ratepay_device_fingerprint.phtml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ define(
'Magento_Checkout/js/model/quote',
'Magento_Customer/js/model/customer',
'Payone_Core/js/action/ratepayconfig',
'Magento_Checkout/js/checkout-data',
'mage/translate'
],
function (Component, quote, customer, ratepayconfig, $t) {
function (Component, quote, customer, ratepayconfig, checkoutData, $t) {
'use strict';
return Component.extend({
initialize: function () {
Expand All @@ -38,8 +39,15 @@ define(
ratepayconfig();
window.checkoutConfig.payment.payone.ratepayRefreshed = true;
}
if (checkoutData.getSelectedPaymentMethod() === this.getCode()) {
this.handleDeviceFingerprint();
}
return parentReturn;
},
selectPaymentMethod: function () {
this.handleDeviceFingerprint();
return this._super();
},
isPlaceOrderActionAllowedRatePay: function () {
return this.isDifferentAddressNotAllowed() === false && this.isB2BNotAllowed() === false;
},
Expand Down Expand Up @@ -154,6 +162,21 @@ define(
return false;
}
return true;
},
handleDeviceFingerprint: function () {
if (window.checkoutConfig.payment.payone.ratepay.token) {
var diSkriptVar = document.createElement('script');
diSkriptVar.type = 'text/javascript';
diSkriptVar.text = "var di = {t:'" + window.checkoutConfig.payment.payone.ratepay.token + "',v:'" + window.checkoutConfig.payment.payone.ratepay.snippetId + "',l:'checkout'};";
document.getElementsByTagName('head')[0].appendChild(diSkriptVar);

var diSkript = document.createElement('script');
diSkript.type = 'text/javascript';
diSkript.src = '//d.ratepay.com/' + window.checkoutConfig.payment.payone.ratepay.snippetId + '/di.js';
document.getElementsByTagName('head')[0].appendChild(diSkript);

window.checkoutConfig.payment.payone.ratepay.token = false;
}
}
});
}
Expand Down

0 comments on commit f4d50ff

Please sign in to comment.