Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Mapper/MollieDtoMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ public function getOrderData(PaymentTransaction $paymentTransaction)
),
]);

// Fall back to CustomerUser name when address has no first/last name (common in B2B)
$customerUser = $order->getCustomerUser();
$mollieAddress = $orderData->getBillingAddress();
if (
$customerUser
&& ((string) $billingAddress->getFirstName() === '' || (string) $billingAddress->getLastName() === '')
) {
$mollieAddress->setGivenName($customerUser->getFirstName());
$mollieAddress->setFamilyName($customerUser->getLastName());
$orderData->setBillingAddress($mollieAddress);
}

$orderData->setLines(
array_merge(
$this->getOrderLinesData($orderLines),
Expand All @@ -212,6 +224,16 @@ public function getOrderData(PaymentTransaction $paymentTransaction)

if ($shippingAddress = $order->getShippingAddress()) {
$orderData->setShippingAddress($this->getAddressData($shippingAddress, $order->getEmail()));

if (
$customerUser
&& ((string) $shippingAddress->getFirstName() === '' || (string) $shippingAddress->getLastName() === '')
) {
$mollieShipping = $orderData->getShippingAddress();
$mollieShipping->setGivenName($customerUser->getFirstName());
$mollieShipping->setFamilyName($customerUser->getLastName());
$orderData->setShippingAddress($mollieShipping);
}
}

if ($frontendOwner = $paymentTransaction->getFrontendOwner()) {
Expand Down