From deeffa8beb80146ff42ac378c7d3bb31fbdacc67 Mon Sep 17 00:00:00 2001 From: Ivascu Madalin Date: Wed, 20 Sep 2023 09:23:17 +0300 Subject: [PATCH] Bp 1934 afterpay error occurs for orders with digital products (#801) * BP-1934 Afterpay error occurs for orders with digital products. * refactor --------- Co-authored-by: Ivascu Madalin --- Model/Method/Afterpay20.php | 11 ++++++++--- .../js/view/payment/method-renderer/afterpay20.js | 12 +++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) 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 );