Skip to content

Commit

Permalink
#89 add support for devicefingerprint to support ratepay
Browse files Browse the repository at this point in the history
  • Loading branch information
rikterbeek committed Jul 21, 2017
1 parent 6b457dc commit cea55f4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
8 changes: 6 additions & 2 deletions Block/Redirect/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,13 @@ public function getFormFields()
$formFields['deliveryAddressType'] = "1";

// make setting to make this optional
$adyFields['shopperType'] = "1";
$formFields['shopperType'] = "1";
}


if ($this->_order->getPayment()->getAdditionalInformation("df_value") != "") {
$formFields['dfValue'] = $this->_order->getPayment()->getAdditionalInformation("df_value");
}

// Sort the array by key using SORT_STRING order
ksort($formFields, SORT_STRING);

Expand Down
4 changes: 3 additions & 1 deletion Observer/AdyenHppDataAssignObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
const GENDER = 'gender';
const DOB = 'dob';
const TELEPHONE = 'telephone';
const DF_VALUE = 'df_value';


/**
Expand All @@ -46,7 +47,8 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
self::ISSUER_ID,
self::GENDER,
self::DOB,
self::TELEPHONE
self::TELEPHONE,
self::DF_VALUE
];

/**
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
/*global alert*/
var config = {
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: {
mixins: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ define(
'Magento_Checkout/js/model/url-builder',
'Adyen_Payment/js/model/adyen-payment-service',
'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) {
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader, deviceFingerprint) {
'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
var dfValue = ko.observable(null);

return Component.extend({
self: this,
Expand All @@ -55,7 +57,8 @@ define(
'issuerId',
'gender',
'dob',
'telephone'
'telephone',
'dfValue'
]);
return this;
},
Expand Down Expand Up @@ -89,6 +92,12 @@ define(
).done(
function (response) {
adyenPaymentService.setPaymentMethods(response);

// set device fingerprint value
dfSet('dfValue', 0);
// propagate this manually to knockoutjs otherwise it would not work
dfValue($('#dfValue').val());

fullScreenLoader.stopLoader();
}
).fail(function(error) {
Expand All @@ -114,7 +123,6 @@ define(
return self.validate();
}


if(value.brandCode == "ideal") {
result.issuerIds = value.issuers;
result.issuerId = ko.observable(null);
Expand Down Expand Up @@ -155,13 +163,12 @@ define(

if (this.validate() && additionalValidators.validate()) {


var data = {};
data.method = self.method;
data.po_number = null;

var additionalData = {};
additionalData.brand_code = self.value;
additionalData.df_value = dfValue();

if(brandCode() == "ideal") {
additionalData.issuer_id = this.issuerId();
Expand All @@ -187,7 +194,7 @@ define(
"method": self.method,
"po_number": null,
"additional_data": {
brand_code: self.value,
brand_code: self.value
}
};

Expand All @@ -205,7 +212,7 @@ define(
isBrandCodeChecked: ko.computed(function () {

if(!quote.paymentMethod()) {
return null;
return null;
}

if(quote.paymentMethod().method == paymentMethod()) {
Expand Down

0 comments on commit cea55f4

Please sign in to comment.