Commit addfd7e4 authored by Oleksandr Gotgelf's avatar Oleksandr Gotgelf
Browse files

CREF-333: Please remove Gender and Date of Birth input fields for BUSINESS transactions

parent 9121d439
......@@ -50,7 +50,8 @@ class ConfigProvider implements ConfigProviderInterface
'crefoPayMethodCode' => PaymentMethodsCodesMap::getCrefoPayLibraryCode(self::CODE),
'logo' => $this->config->getLogoUrl(self::CODE),
'dob' => $this->crefoPayDob->getDob(),
'dateFormat' => $this->crefoPayDob->getDateFormatForJs()
'dateFormat' => $this->crefoPayDob->getDateFormatForJs(),
'isB2BEnabled' => $this->config->isB2BEnabled()
]
]
];
......
......@@ -53,7 +53,8 @@ class ConfigProvider implements ConfigProviderInterface
'ccVaultCode' => self::CC_VAULT_CODE,
'logo' => $this->config->getLogoUrl(self::CODE),
'dob' => $this->crefoPayDob->getDob(),
'dateFormat' => $this->crefoPayDob->getDateFormatForJs()
'dateFormat' => $this->crefoPayDob->getDateFormatForJs(),
'isB2BEnabled' => $this->config->isB2BEnabled()
]
]
];
......
......@@ -45,6 +45,9 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase
$crefoPayDob->expects(self::once())
->method('getDateFormatForJs')
->willReturn('dd.mm.yy');
$config->expects(self::once())
->method('isB2BEnabled')
->willReturn(true);
$actual = $configProvider->getConfig();
$expected = [
......@@ -58,6 +61,7 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase
'smartSignupUrl' => 'smartSignupUrl',
'dob' => '11.11.2011',
'dateFormat' => 'dd.mm.yy',
'isB2BEnabled' => true
]
]
];
......
......@@ -45,6 +45,9 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase
$crefoPayDob->expects(self::once())
->method('getDateFormatForJs')
->willReturn('dd.mm.yy');
$config->expects(self::once())
->method('isB2BEnabled')
->willReturn(true);
$actual = $configProvider->getConfig();
$expected = [
......@@ -59,6 +62,7 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase
'smartSignupUrl' => 'smartSignupUrl',
'dob' => '11.11.2011',
'dateFormat' => 'dd.mm.yy',
'isB2BEnabled' => true
]
]
];
......
......@@ -6,14 +6,14 @@ define(
'jquery',
'Magento_Checkout/js/view/payment/default',
'Trilix_CrefoPay/js/view/payment/adapter',
'Magento_Customer/js/customer-data'
'Magento_Customer/js/customer-data',
'Magento_Checkout/js/model/quote'
],
function (ko, $, Component, adapter, customerData) {
function (ko, $, Component, adapter, customerData, quote) {
'use strict';
return Component.extend({
gender: ko.observable(customerData.get('crefopay')().gender),
defaults: {
template: 'Trilix_CrefoPay/payment/bill'
},
......@@ -23,13 +23,16 @@ define(
},
getData: function() {
return {
let data = {
'method': this.getCode(),
'additional_data': {
};
if (this.useDateOfBirthAndGenderFields()) {
data['additional_data'] = {
'dateOfBirth': $('#crefopay-bill-dob-value').val(),
'salutation': this.gender()
}
};
}
return data;
},
beforePlaceOrder: function () {
......@@ -74,6 +77,12 @@ define(
dob = registeredCustomerDob;
}
return dob;
},
useDateOfBirthAndGenderFields: function () {
let registeredCustomerDob = window.checkoutConfig.payment[this.getCode()].isB2BEnabled;
let billingAddressData = quote.billingAddress();
return !(registeredCustomerDob && billingAddressData && billingAddressData.company);
}
});
}
......
......@@ -7,9 +7,10 @@ define(
'Magento_Checkout/js/view/payment/default',
'Trilix_CrefoPay/js/view/payment/adapter',
'Magento_Customer/js/customer-data',
'Magento_Vault/js/view/payment/vault-enabler'
'Magento_Vault/js/view/payment/vault-enabler',
'Magento_Checkout/js/model/quote'
],
function (ko, $, Component, adapter, customerData, VaultEnabler) {
function (ko, $, Component, adapter, customerData, VaultEnabler, quote) {
'use strict';
return Component.extend({
......@@ -49,14 +50,20 @@ define(
},
getData: function () {
var data = {
let data = {
'method': this.getCode(),
'additional_data': {
};
if (this.useDateOfBirthAndGenderFields()) {
data['additional_data'] = {
'paymentInstrumentId': this.paymentInstrumentId,
'dateOfBirth': $('#crefopay-dd-dob-value').val(),
'salutation': this.gender()
}
};
} else {
data['additional_data'] = {
'paymentInstrumentId': this.paymentInstrumentId
}
}
this.vaultEnabler.visitAdditionalData(data);
......@@ -113,6 +120,12 @@ define(
dob = registeredCustomerDob;
}
return dob;
},
useDateOfBirthAndGenderFields: function () {
let registeredCustomerDob = window.checkoutConfig.payment[this.getCode()].isB2BEnabled;
let billingAddressData = quote.billingAddress();
return !(registeredCustomerDob && billingAddressData && billingAddressData.company);
}
});
}
......
......@@ -18,7 +18,7 @@
</label>
</div>
<div class="payment-method-content" afterRender="initializeDobField">
<div class="payment-method-content">
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
......@@ -27,8 +27,8 @@
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<fieldset data-bind="attr: {class: 'fieldset payment items bill'}">
<!-- ko if: useDateOfBirthAndGenderFields() -->
<fieldset data-bind="attr: {class: 'fieldset payment items bill'}" id="test">
<div class="field required">
<label class="label" for="crefopay-bill-gender">
<span><!-- ko i18n: 'Gender'--><!-- /ko --></span>
......@@ -46,13 +46,13 @@
" data-validate="{required:true}"></select>
</div>
</div>
<div class="field date field-dob required">
<div class="field date field-dob required" afterRender="initializeDobField">
<label class="label" for="crefopay-bill-dob">
<span><!-- ko i18n: 'Date of birth'--><!-- /ko --></span>
</label>
<div class="control customer-dob">
<input type="text" class="input-text" id="crefopay-bill-dob"
style="width: auto" name="payment[dob]"/>
style="width: auto" name="payment[dob]" />
<input type="hidden" class="date" id="crefopay-bill-dob-value" />
<button type="button" class="ui-datepicker-trigger v-middle">
<span>Select Date</span>
......@@ -60,6 +60,7 @@
</div>
</div>
</fieldset>
<!-- /ko -->
<div class="checkout-agreements-block">
<!-- ko foreach: $parent.getRegion('before-place-order') -->
......
......@@ -19,7 +19,7 @@
</label>
</div>
<div class="payment-method-content" afterRender="initializeAdapter">
<div class="payment-method-content">
<!-- ko foreach: getRegion('messages') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
......@@ -30,6 +30,7 @@
</div>
<fieldset data-bind="attr: {class: 'fieldset payment items ccard'}">
<!-- ko if: useDateOfBirthAndGenderFields() -->
<div class="field required">
<label class="label" for="crefopay-dd-gender">
<span><!-- ko i18n: 'Gender'--><!-- /ko --></span>
......@@ -47,7 +48,7 @@
" data-validate="{required:true}"></select>
</div>
</div>
<div class="field date field-dob required">
<div class="field date field-dob required" afterRender="initializeDobField">
<label class="label" for="crefopay-dd-dob">
<span><!-- ko i18n: 'Date of birth'--><!-- /ko --></span>
</label>
......@@ -60,6 +61,7 @@
</button>
</div>
</div>
<!-- /ko -->
<div class="field text required">
<label class="label">
<span><!-- ko i18n: 'Accountholder Name.'--><!-- /ko --></span>
......
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