Problem
The MollieDtoMapper::getAddressData() method maps givenName and familyName directly from OrderAddress::getFirstName() and OrderAddress::getLastName(). In B2B scenarios addresses frequently only contain an organization name — personal names are left empty.
The Mollie API requires givenName and familyName on billing and shipping addresses. When these are empty, API requests either fail or produce incomplete order data.
Reproduction
- Set up a B2B customer with an address that has an organization name but no first/last name
- Place an order using a Mollie payment method
- Observe that the Mollie order's billing/shipping address has empty
givenName and familyName
Suggested Fix
When OrderAddress lacks a first or last name, fall back to the CustomerUser's first and last name. The CustomerUser is always available via the order entity and reliably has name data.
The fallback should be applied in getOrderData() (which has access to the PaymentTransaction and therefore the Order and its CustomerUser) rather than in getAddressData() (which only receives the OrderAddress).
// After getOrderData() creates the order DTO:
$order = $paymentTransaction->getEntityReference();
$customerUser = $order->getCustomerUser();
// Billing address fallback
if ((string) $order->getBillingAddress()?->getFirstName() === ''
|| (string) $order->getBillingAddress()?->getLastName() === '') {
$billingAddress->setGivenName($customerUser?->getFirstName());
$billingAddress->setFamilyName($customerUser?->getLastName());
}
// Same for shipping address
Environment
- mollie/orocommerce: 6.1.0 (also affects 5.x)
- OroCommerce with B2B customers
Problem
The
MollieDtoMapper::getAddressData()method mapsgivenNameandfamilyNamedirectly fromOrderAddress::getFirstName()andOrderAddress::getLastName(). In B2B scenarios addresses frequently only contain an organization name — personal names are left empty.The Mollie API requires
givenNameandfamilyNameon billing and shipping addresses. When these are empty, API requests either fail or produce incomplete order data.Reproduction
givenNameandfamilyNameSuggested Fix
When
OrderAddresslacks a first or last name, fall back to theCustomerUser's first and last name. TheCustomerUseris always available via the order entity and reliably has name data.The fallback should be applied in
getOrderData()(which has access to thePaymentTransactionand therefore theOrderand itsCustomerUser) rather than ingetAddressData()(which only receives theOrderAddress).Environment