Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BP-2766 Billink B2B input fields #754

Merged
merged 3 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions Model/Method/Billink.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,30 @@ public function getArticleArrayLine(

return $article;
}

/**
* @param \Magento\Sales\Api\Data\OrderPaymentInterface|\Magento\Payment\Model\InfoInterface $payment
*
* @return string|null
*/
private function getBirthDate($payment)
{
$birth = $payment->getAdditionalInformation('customer_DoB');

if(!is_string($birth) || strlen(trim($birth)) === 0) {
return null;
}

$birthDayStamp = date(
"d-m-Y",
strtotime(str_replace('/', '-', $birth))
);

if($birthDayStamp === false) {
return null;
}
return $birthDayStamp;
}

/**
* @param \Magento\Sales\Api\Data\OrderPaymentInterface|\Magento\Payment\Model\InfoInterface $payment
Expand All @@ -659,10 +683,8 @@ public function getRequestBillingData($payment)
$billingAddress = $order->getBillingAddress();
$streetFormat = $this->formatStreet($billingAddress->getStreet());

$birthDayStamp = date(
"d-m-Y",
strtotime(str_replace('/', '-', $payment->getAdditionalInformation('customer_DoB')))
);
$birthDayStamp = $this->getBirthDate($payment);

$chamberOfCommerce = $payment->getAdditionalInformation('customer_chamberOfCommerce');
$VATNumber = $payment->getAdditionalInformation('customer_VATNumber');
$telephone = $payment->getAdditionalInformation('customer_telephone');
Expand Down
10 changes: 8 additions & 2 deletions view/frontend/web/js/view/payment/method-renderer/billink.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ define(
);
this.billingName = ko.computed(
function () {
if(this.isB2B && quote.billingAddress() !== null) {
return quote.billingAddress().company;
}
if(quote.billingAddress() !== null) {
return quote.billingAddress().firstname + " " + quote.billingAddress().lastname;
}
Expand Down Expand Up @@ -236,15 +239,18 @@ define(
getActiveValidationFields() {
let fields = [
'buckaroo_magento2_billink_TermsCondition',
'buckaroo_magento2_billink_DoB',
'buckaroo_magento2_bilink_genderSelect'
];
if(this.showPhone()) {
fields.push('buckaroo_magento2_billink_Telephone')
}

if(this.isB2B) {
fields.push('buckaroo_magento2_billink_chamberOfCommerce')
} else {
fields = fields.concat([
'buckaroo_magento2_billink_DoB',
'buckaroo_magento2_bilink_genderSelect'
]);
}

return fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
attr: {'data-hasrequired': $t('* Required Fields')}">
<fieldset class="fieldset payment">

<!-- ko if: !isB2B -->
<div class="field required">
<label class="label" for="buckaroo_magento2_payperemail_genderSelect"> <span data-bind="i18n: 'Salutation:'"> </span> </label>
<div class="control">
Expand All @@ -45,6 +46,7 @@
</select>
</div>
</div>
<!-- /ko -->

<div class="field required">
<label class="label" for="buckaroo_magento2_billink_BillingName"> <span data-bind="i18n: 'Billing Name:'"> </span> </label>
Expand Down Expand Up @@ -77,6 +79,7 @@
</div>
<!-- /ko -->

<!-- ko if: !isB2B -->
<div class="field required">
<label class="label" for="buckaroo_magento2_billink_DoB"> <span data-bind="i18n: 'Date of Birth:'"> </span> </label>
<div class="control addon">
Expand Down Expand Up @@ -104,6 +107,7 @@
name="payment[buckaroo_magento2_billink][customer_DoB]">
</div>
</div>
<!-- /ko -->

<!-- ko if: isB2B -->
<div class="field required">
Expand Down
Loading