Skip to content

Commit

Permalink
Merge pull request #521 from BoulangerV/MAG2-294-BNPL_DiffAddr_B2B
Browse files Browse the repository at this point in the history
MAG2-294: Activate option and adjust template/JS
  • Loading branch information
janteuber authored Aug 24, 2023
2 parents b8f6f42 + d735f62 commit a399a75
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 19 deletions.
13 changes: 12 additions & 1 deletion Model/Methods/BNPL/BNPLBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class BNPLBase extends PayoneMethod
'iban',
'installmentOption',
'optionid',
'vatid',
];

/**
Expand Down Expand Up @@ -216,10 +217,15 @@ public function getPaymentSpecificParameters(Order $oOrder)
{
$oInfoInstance = $this->getInfoInstance();

$sBusinessrelation = 'b2c';
if (!empty($oOrder->getBillingAddress()->getCompany())) {
$sBusinessrelation = 'b2b';
}

$aBaseParams = [
'financingtype' => $this->getSubType(),
'add_paydata[device_token]' => $this->getDeviceToken(),
'businessrelation' => 'b2c',
'businessrelation' => $sBusinessrelation,
'birthday' => $oInfoInstance->getAdditionalInformation('dateofbirth')
];

Expand All @@ -228,6 +234,11 @@ public function getPaymentSpecificParameters(Order $oOrder)
$aBaseParams['telephonenumber'] = $sTelephone;
}

$sVatId = $oInfoInstance->getAdditionalInformation('vatid');
if ($sBusinessrelation == 'b2b' && !empty($sVatId)) {
$aBaseParams['vatid'] = $sVatId;
}

$aSubTypeParams = $this->getSubTypeSpecificParameters($oOrder);
$aParams = array_merge($aBaseParams, $aSubTypeParams);
return $aParams;
Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system/payone_bnpl_debit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
<label>Title</label>
<config_path>payment/payone_bnpl_debit/title</config_path>
</field>
<!--BNPL_DIFFERING_ADDRESS_DEACTIVATED field id="different_address_allowed" translate="label,tooltip" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="different_address_allowed" translate="label,tooltip" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allow differing shipping address</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<tooltip>Enable this if differing billing address and shipping address are allowed. This is disabled by default because this has to be enabled by Payone for your merchant account.</tooltip>
<tooltip>Attenion: has to be enabled in the PAYONE account.</tooltip>
<config_path>payment/payone_bnpl_debit/different_address_allowed</config_path>
</field-->
</field>
<field id="order_status" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system/payone_bnpl_installment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
<label>Title</label>
<config_path>payment/payone_bnpl_installment/title</config_path>
</field>
<!--BNPL_DIFFERING_ADDRESS_DEACTIVATED field id="different_address_allowed" translate="label,tooltip" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="different_address_allowed" translate="label,tooltip" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allow differing shipping address</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<tooltip>Enable this if differing billing address and shipping address are allowed. This is disabled by default because this has to be enabled by Payone for your merchant account.</tooltip>
<tooltip>Attenion: has to be enabled in the PAYONE account.</tooltip>
<config_path>payment/payone_bnpl_installment/different_address_allowed</config_path>
</field-->
</field>
<field id="order_status" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system/payone_bnpl_invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
<label>Title</label>
<config_path>payment/payone_bnpl_invoice/title</config_path>
</field>
<!--BNPL_DIFFERING_ADDRESS_DEACTIVATED field id="different_address_allowed" translate="label,tooltip" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="different_address_allowed" translate="label,tooltip" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Allow differing shipping address</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<tooltip>Enable this if differing billing address and shipping address are allowed. This is disabled by default because this has to be enabled by Payone for your merchant account.</tooltip>
<tooltip>Attenion: has to be enabled in the PAYONE account.</tooltip>
<config_path>payment/payone_bnpl_invoice/different_address_allowed</config_path>
</field-->
</field>
<field id="order_status" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
Expand Down
5 changes: 3 additions & 2 deletions i18n/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,10 @@
"TEMPLATE","/home/thomas/Entwicklung/payone/magento-extension/app/code/community/Payone/Core/Block/Adminhtml/System/Config/Form/Field/Info.php"
"Click here to obtain more information on this section","Klicken Sie hier um weitere Informationen zu diesem Bereich zu erhalten"

"Allow differing shipping address","Abweichende Lieferadresse erlaubt"
"Enable this if differing billing address and shipping address are allowed. This is disabled by default because this has to be enabled by Payone for your merchant account.","Aktivierbar um abweichende Rechnungs- und Lieferadresse zu erlauben. Dies ist standardmäßig deaktiviert, da dies erst von Payone in ihrem Merchant Account aktiviert werden muss."
"Allow differing shipping address","Abweichende Lieferadresse zulassen"
"Attenion: has to be enabled in the PAYONE account.","Muss im PAYONE-Konto freigeschaltet sein!"
"B2B orders are not supported for this payment method","B2B Bestellungen sind nicht verfügbar für diese Zahlart"
"VAT-ID","USt-IdNr"

"bnpl_legal_text_snippet_1","Mit Abschluss dieser Bestellung erkläre ich mich mit den"
"bnpl_legal_text_snippet_2","ergänzenden Zahlungsbedingungen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ define(
return false;
},
isPlaceOrderActionAllowedBNPL: function () {
return (this.isAddressDifferent() === false && this.isB2BOrder() === false);
return this.isAddressDifferent() === false && (this.getCode() === 'payone_bnpl_invoice' || this.isB2BOrder() === false);
},
loadJavascriptSnippet: function () {
if (window.checkoutConfig.payment.payone.bnpl === undefined || window.checkoutConfig.payment.payone.bnpl === false || window.payoneBNPLSnippetLoaded !== undefined || window.payoneBNPLSnippetLoaded === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,25 @@ define(
birthday: '',
birthmonth: '',
birthyear: '',
telephone: ''
telephone: '',
vatid: ''
},
initObservable: function () {
this._super()
.observe([
'birthday',
'birthmonth',
'birthyear',
'telephone'
'telephone',
'vatid'
]);
return this;
}
},
getData: function () {
var parentReturn = this._super();
parentReturn.additional_data.vatid = this.vatid();
return parentReturn;
},
});
}
);
20 changes: 17 additions & 3 deletions view/frontend/web/template/payment/bnpl_invoice.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@
</div>
</div>
<!--/ko-->
<!-- ko if: isB2BOrder() -->
<div class="field">
<label data-bind="attr: {for: getCode() + '_vatid'}" class="label">
<span><!-- ko i18n: 'VAT-ID'--><!-- /ko --></span>
</label>
<div class="control">
<input type="text" name="payment[vatid]" class="input-text" value=""
data-bind="attr: {
autocomplete: off,
id: getCode() + '_vatid',
title: $t('VAT-ID'),
'data-container': getCode() + '-vatid'},
value: vatid,
valueUpdate: 'keyup' "/>
</div>
</div>
<!--/ko-->
</fieldset>
</form>
<p data-bind="html: getInstructions()"></p>
Expand Down Expand Up @@ -156,8 +173,5 @@
<div class="payone_place_order_not_allowed" data-bind="visible: isAddressDifferent()"><br>
<span><!-- ko i18n: 'Payment with differing billing- and shipping-address is not supported for this payment type'--><!-- /ko --></span>
</div>
<div class="payone_place_order_not_allowed" data-bind="visible: !isAddressDifferent() && isB2BOrder()"><br>
<span><!-- ko i18n: 'B2B orders are not supported for this payment method'--><!-- /ko --></span>
</div>
</div>
</div>

0 comments on commit a399a75

Please sign in to comment.