Skip to content

B2B: Missing givenName/familyName when address only has organization name #54

@powli

Description

@powli

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

  1. Set up a B2B customer with an address that has an organization name but no first/last name
  2. Place an order using a Mollie payment method
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions