Skip to content

Commit

Permalink
Fix for auth customers and express pay (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolenorman authored Oct 31, 2024
1 parent 91c264f commit 9c6dee0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Service/ExpressPay/QuoteConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,22 @@ public function convertCustomer(Quote $quote): array
return [];
}

return [
$email = $billingAddress->getEmail() ?? $shippingAddress->getEmail();

$convertedQuote = [
'order_data' => [
'customer' => [
'first_name' => $billingAddress->getFirstname() ?? '',
'last_name' => $billingAddress->getLastname() ?? '',
'email' => $billingAddress->getEmail() ?? $shippingAddress->getEmail() ?? ''
'last_name' => $billingAddress->getLastname() ?? ''
]
]
];

if ($email) {
$convertedQuote['order_data']['customer']['email'] = $email;
}

return $convertedQuote;
}

/**
Expand Down Expand Up @@ -192,7 +199,7 @@ static function (Rate $rate) use ($currencyCode): array {
if ($shippingAddress->getTelephone()) {
$convertedQuote['order_data']['shipping_address']['phone_number'] = $shippingAddress->getTelephone();
}
if ($hasRequiredAddressData && $shippingAddress->hasShippingMethod()) { // @phpstan-ignore method.notFound
if ($hasRequiredAddressData && $shippingAddress->hasShippingMethod() && $shippingAddress->getShippingMethod() !== '') { // @phpstan-ignore method.notFound
$convertedQuote['order_data']['selected_shipping_option'] = [
'id' => $shippingAddress->getShippingMethod(),
'label' => $shippingAddress->getShippingDescription() ?? $shippingAddress->getShippingMethod(),
Expand Down

0 comments on commit 9c6dee0

Please sign in to comment.