Skip to content

Commit

Permalink
BP-2977 GraphQL issue with virtual products in cart resulting in an e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
Ivascu Madalin committed Oct 3, 2023
1 parent c7c128b commit 69db1e0
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions Model/Service/Plugin/PaypalSellersProtection/Order.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* NOTICE OF LICENSE
*
Expand Down Expand Up @@ -70,16 +71,24 @@ public function afterGetOrderTransactionBuilder(
* @var \Magento\Sales\Model\Order $order
*/
$order = $payment->getOrder();
$shippingAddress = $order->getShippingAddress();
$address = $order->getShippingAddress();

$services = $result->getServices();

if (!empty($services['Action']) && ($services['Action'] == 'PayRemainder')) {
return $result;
}

if ($address === null) {
$address = $order->getBillingAddress();
}

if ($address === null) {
return $result;
}

// Build ExtraInfo Request Parameter
$extraInfoRequestParameter = $this->getRequestParameter($shippingAddress);
$extraInfoRequestParameter = $this->getRequestParameter($address);

// Build ExtraInfo Service
$services = [
Expand All @@ -97,28 +106,27 @@ public function afterGetOrderTransactionBuilder(
return $result;
}

private function getRequestParameter($shippingAddress)
private function getRequestParameter($address)
{

$extraInfoRequestParameter = [
[
'_' => mb_substr($shippingAddress->getName(), 0, 32),
'_' => mb_substr($address->getName(), 0, 32),
'Name' => 'Name',
],
[
'_' => mb_substr($shippingAddress->getStreetLine(1), 0, 100),
'_' => mb_substr($address->getStreetLine(1), 0, 100),
'Name' => 'Street1',
],
[
'_' => mb_substr($shippingAddress->getCity(), 0, 40),
'_' => mb_substr($address->getCity(), 0, 40),
'Name' => 'CityName',
],
[
'_' => mb_substr($shippingAddress->getPostcode(), 0, 20),
'_' => mb_substr($address->getPostcode(), 0, 20),
'Name' => 'PostalCode',
],
[
'_' => $shippingAddress->getCountryId(),
'_' => $address->getCountryId(),
'Name' => 'Country',
],
[
Expand All @@ -127,12 +135,12 @@ private function getRequestParameter($shippingAddress)
],
];

$shippingRegion = $shippingAddress->getRegion();
$shippingRegion = $address->getRegion();
if (isset($shippingRegion) && !empty($shippingRegion)) {

$twoCharacterShippingRegion = $this->paypalStateCodes->getCodeFromValue(
$shippingAddress->getCountryId(),
$shippingAddress->getRegion()
$address->getCountryId(),
$address->getRegion()
);

if ($twoCharacterShippingRegion) {
Expand Down

0 comments on commit 69db1e0

Please sign in to comment.