Skip to content

Commit

Permalink
Bp 1934 afterpay error occurs for orders with digital products (#801)
Browse files Browse the repository at this point in the history
* BP-1934 Afterpay error occurs for orders with digital products.

* refactor

---------

Co-authored-by: Ivascu Madalin <[email protected]>
  • Loading branch information
harli91 and Ivascu Madalin authored Sep 20, 2023
1 parent 656f0cd commit deeffa8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Model/Method/Afterpay20.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
12 changes: 11 additions & 1 deletion view/frontend/web/js/view/payment/method-renderer/afterpay20.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down

0 comments on commit deeffa8

Please sign in to comment.