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 59ddfa00 authored by basm's avatar basm

PW-304 Inserted Personal number for Nordic countries

parent 1617a20d
...@@ -84,7 +84,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -84,7 +84,8 @@ class Redirect extends \Magento\Payment\Block\Form
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Tax\Model\Config $taxConfig, \Magento\Tax\Model\Config $taxConfig,
\Magento\Tax\Model\Calculation $taxCalculation \Magento\Tax\Model\Calculation $taxCalculation
) { )
{
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession; $this->_checkoutSession = $checkoutSession;
parent::__construct($context, $data); parent::__construct($context, $data);
...@@ -127,11 +128,12 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -127,11 +128,12 @@ class Redirect extends \Magento\Payment\Block\Form
} else { } else {
if ($this->getPaymentMethodSelectionOnAdyen()) { if ($this->getPaymentMethodSelectionOnAdyen()) {
$url = 'https://test.adyen.com/hpp/select.shtml'; $url = 'https://test.adyen.com/hpp/select.shtml';
} else { } else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod(
$this->_order->getPayment()->getAdditionalInformation('brand_code') $this->_order->getPayment()->getAdditionalInformation('brand_code')
)) { )
) {
$url = "https://test.adyen.com/hpp/skipDetails.shtml"; $url = "https://test.adyen.com/hpp/skipDetails.shtml";
} else { } else {
$url = "https://test.adyen.com/hpp/details.shtml"; $url = "https://test.adyen.com/hpp/details.shtml";
...@@ -144,11 +146,12 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -144,11 +146,12 @@ class Redirect extends \Magento\Payment\Block\Form
$url = 'https://live.adyen.com/hpp/pay.shtml'; $url = 'https://live.adyen.com/hpp/pay.shtml';
} else { } else {
if ($this->getPaymentMethodSelectionOnAdyen()) { if ($this->getPaymentMethodSelectionOnAdyen()) {
$url = 'https://live.adyen.com/hpp/select.shtml'; $url = 'https://live.adyen.com/hpp/select.shtml';
} else { } else {
if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod( if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod(
$this->_order->getPayment()->getAdditionalInformation('brand_code') $this->_order->getPayment()->getAdditionalInformation('brand_code')
)) { )
) {
$url = "https://live.adyen.com/hpp/skipDetails.shtml"; $url = "https://live.adyen.com/hpp/skipDetails.shtml";
} else { } else {
$url = "https://live.adyen.com/hpp/details.shtml"; $url = "https://live.adyen.com/hpp/details.shtml";
...@@ -158,7 +161,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -158,7 +161,7 @@ class Redirect extends \Magento\Payment\Block\Form
break; break;
} }
} }
} catch(Exception $e) { } catch (Exception $e) {
// do nothing for now // do nothing for now
throw($e); throw($e);
} }
...@@ -203,7 +206,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -203,7 +206,8 @@ class Redirect extends \Magento\Payment\Block\Form
// if directory lookup is enabled use the billingaddress 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() != ""
) {
$countryCode = $this->_order->getBillingAddress()->getCountryId(); $countryCode = $this->_order->getBillingAddress()->getCountryId();
} }
} }
...@@ -320,13 +324,9 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -320,13 +324,9 @@ class Redirect extends \Magento\Payment\Block\Form
$this->_adyenLogger->addAdyenDebug(print_r($formFields, true)); $this->_adyenLogger->addAdyenDebug(print_r($formFields, true));
} }
} catch(Exception $e) { } catch (Exception $e) {
// do nothing for now // do nothing for now
} }
// echo "GENDER" . $this->_order->getCustomerGender();
//
//print_r($formFields);die();
return $formFields; return $formFields;
} }
...@@ -457,7 +457,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -457,7 +457,7 @@ class Redirect extends \Magento\Payment\Block\Form
$this->_adyenHelper->formatAmount( $this->_adyenHelper->formatAmount(
$item->getPriceInclTax(), $item->getPriceInclTax(),
$currency $currency
) - $this->_adyenHelper->formatAmount( ) - $this->_adyenHelper->formatAmount(
$item->getPrice(), $item->getPrice(),
$currency $currency
) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency); ) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency);
...@@ -466,7 +466,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -466,7 +466,7 @@ class Redirect extends \Magento\Payment\Block\Form
// Calculate vat percentage // Calculate vat percentage
$itemVatPercentage = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent()); $itemVatPercentage = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent());
$numberOfItems = (int) $item->getQtyOrdered(); $numberOfItems = (int)$item->getQtyOrdered();
$formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount, $formFields = $this->setOpenInvoiceLineData($formFields, $count, $currency, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems); $itemVatAmount, $itemVatPercentage, $numberOfItems);
...@@ -514,7 +514,7 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -514,7 +514,7 @@ class Redirect extends \Magento\Payment\Block\Form
$itemVatAmount, $itemVatPercentage, $numberOfItems); $itemVatAmount, $itemVatPercentage, $numberOfItems);
} }
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for ".$formFields['merchantReference']; $formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " . $formFields['merchantReference'];
$formFields['openinvoicedata.numberOfLines'] = $count; $formFields['openinvoicedata.numberOfLines'] = $count;
return $formFields; return $formFields;
...@@ -533,9 +533,10 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -533,9 +533,10 @@ class Redirect extends \Magento\Payment\Block\Form
* @param $numberOfItems * @param $numberOfItems
*/ */
protected function setOpenInvoiceLineData($formFields, $count, $currencyCode, $description, $itemAmount, protected function setOpenInvoiceLineData($formFields, $count, $currencyCode, $description, $itemAmount,
$itemVatAmount, $itemVatPercentage, $numberOfItems $itemVatAmount, $itemVatPercentage, $numberOfItems
) { )
$linename = "line".$count; {
$linename = "line" . $count;
$formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode; $formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currencyCode;
$formFields['openinvoicedata.' . $linename . '.description'] = $description; $formFields['openinvoicedata.' . $linename . '.description'] = $description;
$formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount; $formFields['openinvoicedata.' . $linename . '.itemAmount'] = $itemAmount;
...@@ -544,7 +545,8 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -544,7 +545,8 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields['openinvoicedata.' . $linename . '.numberOfItems'] = $numberOfItems; $formFields['openinvoicedata.' . $linename . '.numberOfItems'] = $numberOfItems;
if ($this->_adyenHelper->isVatCategoryHigh($this->_order->getPayment()->getAdditionalInformation( if ($this->_adyenHelper->isVatCategoryHigh($this->_order->getPayment()->getAdditionalInformation(
\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE))) { \Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE))
) {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High"; $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High";
} else { } else {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None"; $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
......
...@@ -81,7 +81,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -81,7 +81,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
\Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\UrlInterface $urlBuilder,
\Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Session $customerSession,
\Magento\Checkout\Model\Session $session \Magento\Checkout\Model\Session $session
) { )
{
$this->_paymentHelper = $paymentHelper; $this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_request = $request; $this->_request = $request;
...@@ -123,7 +124,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -123,7 +124,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$gender = ""; $gender = "";
$dob = ""; $dob = "";
} }
// add to config // add to config
$config['payment'] ['adyenHpp']['gender'] = $gender; $config['payment'] ['adyenHpp']['gender'] = $gender;
$config['payment'] ['adyenHpp']['dob'] = $dob; $config['payment'] ['adyenHpp']['dob'] = $dob;
...@@ -137,12 +138,12 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -137,12 +138,12 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen; $config['payment'] ['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen;
$config['payment'] ['adyenHpp']['showGender'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_gender'); $config['payment'] ['adyenHpp']['showGender'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_gender');
$config['payment'] ['adyenHpp']['showDob'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_dob'); $config['payment'] ['adyenHpp']['showDob'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_dob');
$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']['ratePayId'] = $this->_adyenHelper->getRatePayId();
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->_session->getQuoteId().date('c')); $config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->_session->getQuoteId() . date('c'));
$config['payment'] ['adyenHpp']['nordicCountries'] = ['SE','NO','DK', 'FI']; $config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI'];
return $config; return $config;
} }
......
...@@ -74,7 +74,7 @@ define( ...@@ -74,7 +74,7 @@ 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 {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/retrieve-adyen-payment-methods', { serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/retrieve-adyen-payment-methods', {
...@@ -92,7 +92,7 @@ define( ...@@ -92,7 +92,7 @@ define(
).done( ).done(
function (response) { function (response) {
adyenPaymentService.setPaymentMethods(response); adyenPaymentService.setPaymentMethods(response);
if(JSON.stringify(response).indexOf("ratepay") > -1) { if (JSON.stringify(response).indexOf("ratepay") > -1) {
var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId; var ratePayId = window.checkoutConfig.payment.adyenHpp.ratePayId;
window.di = {t: '', v: ratePayId, l: 'Checkout'}; window.di = {t: '', v: ratePayId, l: 'Checkout'};
function waitForDfValue() { function waitForDfValue() {
...@@ -116,22 +116,22 @@ define( ...@@ -116,22 +116,22 @@ define(
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
} }
).fail(function(error) { ).fail(function (error) {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
fullScreenLoader.stopLoader(); fullScreenLoader.stopLoader();
}); });
}, },
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) {
var result = {}; var result = {};
result.value = value.brandCode; result.value = value.brandCode;
result.name = value; result.name = value;
result.method = self.item.method; result.method = self.item.method;
result.getCode = function() { result.getCode = function () {
return self.item.method; return self.item.method;
}; };
result.validate = function () { result.validate = function () {
...@@ -140,7 +140,7 @@ define( ...@@ -140,7 +140,7 @@ define(
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
return 5; return 5;
...@@ -150,10 +150,10 @@ define( ...@@ -150,10 +150,10 @@ define(
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);
} else if(value.isPaymentMethodOpenInvoiceMethod) { } else if (value.isPaymentMethodOpenInvoiceMethod) {
result.telephone = ko.observable(quote.shippingAddress().telephone); result.telephone = ko.observable(quote.shippingAddress().telephone);
result.gender = ko.observable(window.checkoutConfig.payment.adyenHpp.gender); result.gender = ko.observable(window.checkoutConfig.payment.adyenHpp.gender);
result.dob = ko.observable(window.checkoutConfig.payment.adyenHpp.dob); result.dob = ko.observable(window.checkoutConfig.payment.adyenHpp.dob);
...@@ -189,9 +189,8 @@ define( ...@@ -189,9 +189,8 @@ define(
}); });
return paymentList; return paymentList;
}, },
getGenderTypes: function() { getGenderTypes: function () {
// return window.checkoutConfig.payment.adyenHpp.genderTypes; return _.map(window.checkoutConfig.payment.adyenHpp.genderTypes, function (value, key) {
return _.map(window.checkoutConfig.payment.adyenHpp.genderTypes, function(value, key) {
return { return {
'key': key, 'key': key,
'value': value 'value': value
...@@ -207,7 +206,7 @@ define( ...@@ -207,7 +206,7 @@ define(
return false; return false;
} }
}, },
continueToAdyenBrandCode: function() { continueToAdyenBrandCode: function () {
// set payment method to adyen_hpp // set payment method to adyen_hpp
var self = this; var self = this;
...@@ -220,14 +219,14 @@ define( ...@@ -220,14 +219,14 @@ define(
additionalData.brand_code = self.value; additionalData.brand_code = self.value;
additionalData.df_value = dfValue(); additionalData.df_value = dfValue();
if(brandCode() == "ideal") { if (brandCode() == "ideal") {
additionalData.issuer_id = this.issuerId(); additionalData.issuer_id = this.issuerId();
} else if(self.isPaymentMethodOpenInvoiceMethod()) { } else if (self.isPaymentMethodOpenInvoiceMethod()) {
additionalData.gender = this.gender(); additionalData.gender = this.gender();
additionalData.dob = this.dob(); additionalData.dob = this.dob();
additionalData.telephone = this.telephone(); additionalData.telephone = this.telephone();
additionalData.ssn = this.ssn(); additionalData.ssn = this.ssn();
if(brandCode() == "ratepay"){ if (brandCode() == "ratepay") {
additionalData.df_value = this.getRatePayDeviceIdentToken(); additionalData.df_value = this.getRatePayDeviceIdentToken();
} }
} }
...@@ -240,11 +239,11 @@ define( ...@@ -240,11 +239,11 @@ define(
return false; return false;
}, },
selectPaymentMethodBrandCode: function() { selectPaymentMethodBrandCode: function () {
var self = this; var self = this;
// set payment method to adyen_hpp // set payment method to adyen_hpp
var data = { var data = {
"method": self.method, "method": self.method,
"po_number": null, "po_number": null,
"additional_data": { "additional_data": {
...@@ -265,25 +264,25 @@ define( ...@@ -265,25 +264,25 @@ define(
}, },
isBrandCodeChecked: ko.computed(function () { isBrandCodeChecked: ko.computed(function () {
if(!quote.paymentMethod()) { if (!quote.paymentMethod()) {
return null; return null;
} }
if(quote.paymentMethod().method == paymentMethod()) { if (quote.paymentMethod().method == paymentMethod()) {
return brandCode(); return brandCode();
} }
return null; return null;
}), }),
isPaymentMethodSelectionOnAdyen: function() { isPaymentMethodSelectionOnAdyen: function () {
return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen; return window.checkoutConfig.payment.adyenHpp.isPaymentMethodSelectionOnAdyen;
}, },
isIconEnabled: function() { isIconEnabled: function () {
return window.checkoutConfig.payment.adyen.showLogo; return window.checkoutConfig.payment.adyen.showLogo;
}, },
validate: function () { validate: function () {
return true; return true;
}, },
getRatePayDeviceIdentToken: function(){ getRatePayDeviceIdentToken: function () {
return window.checkoutConfig.payment.adyenHpp.deviceIdentToken; 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