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 4e492262 authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

PW-251: Update device fingerprint for ratepay (#187)

* PW-251: Update device fingerprint for ratepay
parent 5e1086fc
......@@ -200,7 +200,7 @@ class Redirect extends \Magento\Payment\Block\Form
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code'));
$countryCode = (!empty($countryCode)) ? $countryCode : false;
// if directory lookup is enabled use the billingadress as countrycode
// if directory lookup is enabled use the billingaddress as countrycode
if ($countryCode == false) {
if ($this->_order->getBillingAddress() &&
$this->_order->getBillingAddress()->getCountryId() != "") {
......
......@@ -770,6 +770,11 @@ class Data extends AbstractHelper
}
}
public function getRatePayId()
{
return $this->getAdyenHppConfigData("ratepay_id");
}
/**
* For Klarna And AfterPay use VatCategory High others use none
*
......
......@@ -59,6 +59,10 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
*/
protected $_customerSession;
/**
* @var \Magento\Checkout\Model\Session
*/
protected $_session;
/**
* AdyenHppConfigProvider constructor.
......@@ -68,23 +72,26 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Model\Session $session
*/
public function __construct(
PaymentHelper $paymentHelper,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Customer\Model\Session $customerSession
\Magento\Customer\Model\Session $customerSession,
\Magento\Checkout\Model\Session $session
) {
$this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper;
$this->_request = $request;
$this->_urlBuilder = $urlBuilder;
$this->_customerSession = $customerSession;
$this->_session = $session;
}
/**
* Set configuration for AdyenHPP payemnt method
* Set configuration for AdyenHPP payment method
*
* @return array
*/
......@@ -133,7 +140,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['showTelephone'] = $this->_adyenHelper->getAdyenHppConfigDataFlag(
'show_telephone'
);
$config['payment'] ['adyenHpp']['ratePayId'] = $this->_adyenHelper->getRatePayId();
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->_session->getQuoteId().date('c'));
return $config;
......
......@@ -79,6 +79,11 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_hpp/ignore_second_address_field</config_path>
</field>
<field id="ratepay_id" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>RatePAY Device Ident SId</label>
<tooltip>Unique RatePAY Id provided by RatePAY integration consultant</tooltip>
<config_path>payment/adyen_hpp/ratepay_id</config_path>
</field>
</group>
<group id="adyen_hpp_advanced_settings" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<label>Advanced Settings</label>
......
......@@ -96,6 +96,7 @@
<payment_routine>single</payment_routine>
<delivery_days>5</delivery_days>
<allowspecific>0</allowspecific>
<ratepay_id>oj9GsQ</ratepay_id>
<sort_order>3</sort_order>
<payment_action>order</payment_action>
<can_initialize>1</can_initialize>
......
......@@ -63,6 +63,7 @@ define(
return this;
},
initialize: function () {
var self = this;
this._super();
fullScreenLoader.startLoader();
......@@ -73,7 +74,6 @@ define(
// retrieve payment methods
var serviceUrl,
payload;
if(customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/carts/mine/retrieve-adyen-payment-methods', {});
} else {
......@@ -92,7 +92,23 @@ define(
).done(
function (response) {
adyenPaymentService.setPaymentMethods(response);
if(JSON.stringify(response).indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
window.di = {t: '', v: ratePayId, l: 'Checkout'};
function waitForDfValue() {
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
dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work
......@@ -107,7 +123,6 @@ define(
},
getAdyenHppPaymentMethods: function() {
var self = this;
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
var paymentList = _.map(paymentMethods, function(value) {
......@@ -135,6 +150,9 @@ define(
result.isPaymentMethodOpenInvoiceMethod = function() {
return value.isPaymentMethodOpenInvoiceMethod;
}
result.getRatePayDeviceIdentToken = function() {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
}
return result;
});
return paymentList;
......@@ -176,6 +194,9 @@ define(
additionalData.gender = this.gender();
additionalData.dob = this.dob();
additionalData.telephone = this.telephone();
if(brandCode() == "ratepay"){
additionalData.df_value = this.getRatePayDeviceIdentToken();
}
}
data.additional_data = additionalData;
......@@ -237,6 +258,9 @@ define(
},
validate: function () {
return true;
},
getRatePayDeviceIdentToken: function(){
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken;
}
});
}
......
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