diff --git a/Model/Method/Afterpay20.php b/Model/Method/Afterpay20.php index 4403043c8..0a7091fd1 100644 --- a/Model/Method/Afterpay20.php +++ b/Model/Method/Afterpay20.php @@ -919,15 +919,20 @@ public function validate() $paymentInfo = $this->getInfoInstance(); + $shippingCompany = null; + if ($paymentInfo instanceof Payment) { $storeId = $paymentInfo->getOrder()->getStoreId(); $billingCompany = $paymentInfo->getOrder()->getBillingAddress()->getCompany(); - $shippingCompany = $paymentInfo->getOrder()->getShippingAddress()->getCompany(); - + $shippingAddress = $paymentInfo->getOrder()->getShippingAddress(); } else { $storeId = $paymentInfo->getQuote() !== null? $paymentInfo->getQuote()->getStoreId(): null; $billingCompany = $paymentInfo->getQuote()->getBillingAddress()->getCompany(); - $shippingCompany = $paymentInfo->getQuote()->getShippingAddress()->getCompany(); + $shippingAddress = $paymentInfo->getQuote()->getShippingAddress(); + } + + if ($shippingAddress !== null) { + $shippingCompany = $shippingAddress->getCompany(); } if ( diff --git a/view/frontend/web/js/view/payment/method-renderer/afterpay20.js b/view/frontend/web/js/view/payment/method-renderer/afterpay20.js index 1cbe63f96..9cdc6cee5 100644 --- a/view/frontend/web/js/view/payment/method-renderer/afterpay20.js +++ b/view/frontend/web/js/view/payment/method-renderer/afterpay20.js @@ -249,7 +249,17 @@ define( this.billingName = ko.computed( function () { - return this.activeAddress().firstname + " " + this.activeAddress().lastname; + let firstname = this.activeAddress().firstname; + if (firstname === undefined) { + firstname = ''; + } + + + let lastname = this.activeAddress().lastname; + if (lastname === undefined) { + lastname = ''; + } + return firstname + " " + lastname; }, this );