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