We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 039cb194 authored by Giorgos Adam's avatar Giorgos Adam Committed by GitHub

Merge pull request #213 from Adyen/issue-186

Fixes #186 Remove minify_exclude and load df.js on runtime
parents cbe900b3 16053d91
...@@ -192,12 +192,5 @@ ...@@ -192,12 +192,5 @@
<group>adyen</group> <group>adyen</group>
</adyen_boleto> </adyen_boleto>
</payment> </payment>
<dev>
<js>
<minify_exclude>
live.adyen.com/hpp/js/df
</minify_exclude>
</js>
</dev>
</default> </default>
</config> </config>
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
/*global alert*/ /*global alert*/
var config = { var config = {
paths: { paths: {
'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min', 'adyen/encrypt' : 'Adyen_Payment/js/view/payment/adyen.encrypt.min'
'adyen/df' : 'https://live.adyen.com/hpp/js/df'
}, },
config: { config: {
mixins: { mixins: {
......
...@@ -35,10 +35,9 @@ define( ...@@ -35,10 +35,9 @@ define(
'Magento_Checkout/js/model/url-builder', 'Magento_Checkout/js/model/url-builder',
'Adyen_Payment/js/model/adyen-payment-service', 'Adyen_Payment/js/model/adyen-payment-service',
'Magento_Customer/js/model/customer', 'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader', 'Magento_Checkout/js/model/full-screen-loader'
'adyen/df'
], ],
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader, deviceFingerprint) { function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader) {
'use strict'; 'use strict';
var brandCode = ko.observable(null); var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
...@@ -91,28 +90,43 @@ define( ...@@ -91,28 +90,43 @@ define(
serviceUrl, JSON.stringify(payload) serviceUrl, JSON.stringify(payload)
).done( ).done(
function (response) { function (response) {
adyenPaymentService.setPaymentMethods(response); function waitForDfSet() {
if (JSON.stringify(response).indexOf("ratepay") > -1) { // Wait for dfSet function to be loaded from df.js script
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId; if (typeof dfSet == "undefined") {
window.di = {t: '', v: ratePayId, l: 'Checkout'}; setTimeout(waitForDfSet, 500);
function waitForDfValue() { return;
var dfValueRatePay = self.getRatePayDeviceIdentToken();
if (dfValueRatePay) {
window.di.t = dfValueRatePay.replace(':', '');
var scriptTag = document.createElement('script');
scriptTag.src = "//d.ratepay.com/" + ratePayId + "/di.js";
scriptTag.type = "text/javascript";
document.body.appendChild(scriptTag);
} else {
setTimeout(waitForDfValue, 200);
}
}
waitForDfValue();
} }
// set device fingerprint value // set device fingerprint value
dfSet('dfValue', 0); dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work // propagate this manually to knockoutjs otherwise it would not work
dfValue($('#dfValue').val()); dfValue($('#dfValue').val());
}
adyenPaymentService.setPaymentMethods(response);
if (JSON.stringify(response).indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
var dfValueRatePay = self.getRatePayDeviceIdentToken();
window.di = {
t: dfValueRatePay.replace(':', ''),
v: ratePayId,
l: 'Checkout'
};
// Load Ratepay script
var ratepayScriptTag = document.createElement('script');
ratepayScriptTag.src = "//d.ratepay.com/" + ratePayId + "/di.js";
ratepayScriptTag.type = "text/javascript";
document.body.appendChild(ratepayScriptTag);
}
// Load Adyen df.js script
var dfScriptTag = document.createElement('script');
dfScriptTag.src = "//live.adyen.com/hpp/js/df.js?v=20171130";
dfScriptTag.type = "text/javascript";
document.body.appendChild(dfScriptTag);
waitForDfSet();
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
} }
...@@ -126,7 +140,6 @@ define( ...@@ -126,7 +140,6 @@ define(
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods(); var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
var paymentList = _.map(paymentMethods, function (value) { var paymentList = _.map(paymentMethods, function (value) {
var result = {}; var result = {};
result.value = value.brandCode; result.value = value.brandCode;
result.name = value; result.name = value;
...@@ -136,10 +149,10 @@ define( ...@@ -136,10 +149,10 @@ define(
}; };
result.validate = function () { result.validate = function () {
return self.validate(); return self.validate();
} };
result.isPaymentMethodOpenInvoiceMethod = function () { result.isPaymentMethodOpenInvoiceMethod = function () {
return value.isPaymentMethodOpenInvoiceMethod; return value.isPaymentMethodOpenInvoiceMethod;
} };
result.getSsnLength = function () { result.getSsnLength = function () {
if (quote.billingAddress().countryId == "NO") { if (quote.billingAddress().countryId == "NO") {
//5 digits for Norway //5 digits for Norway
...@@ -149,7 +162,7 @@ define( ...@@ -149,7 +162,7 @@ define(
//4 digits for other Nordic countries //4 digits for other Nordic countries
return 4; return 4;
} }
} };
if (value.brandCode == "ideal") { if (value.brandCode == "ideal") {
result.issuerIds = value.issuers; result.issuerIds = value.issuers;
result.issuerId = ko.observable(null); result.issuerId = ko.observable(null);
...@@ -162,16 +175,16 @@ define( ...@@ -162,16 +175,16 @@ define(
result.getRatePayDeviceIdentToken = function () { result.getRatePayDeviceIdentToken = function () {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken; return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
} };
result.showGender = function () { result.showGender = function () {
return window.checkoutConfig.payment.adyenHpp.showGender; return window.checkoutConfig.payment.adyenHpp.showGender;
} };
result.showDob = function () { result.showDob = function () {
return window.checkoutConfig.payment.adyenHpp.showDob; return window.checkoutConfig.payment.adyenHpp.showDob;
} };
result.showTelephone = function () { result.showTelephone = function () {
return window.checkoutConfig.payment.adyenHpp.showTelephone; return window.checkoutConfig.payment.adyenHpp.showTelephone;
} };
result.showSsn = function () { result.showSsn = function () {
if (value.brandCode.indexOf("klarna") >= 0) { if (value.brandCode.indexOf("klarna") >= 0) {
var ba = quote.billingAddress(); var ba = quote.billingAddress();
...@@ -183,7 +196,7 @@ define( ...@@ -183,7 +196,7 @@ define(
} }
} }
return false; return false;
} };
} }
return result; return result;
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment