private function WorldpayPaymentTrait::getBillingAddress in Commerce Worldpay 8
Same name and namespace in other branches
- 8.2 src/Plugin/Commerce/PaymentGateway/WorldpayPaymentTrait.php \Drupal\commerce_worldpay\Plugin\Commerce\PaymentGateway\WorldpayPaymentTrait::getBillingAddress()
Get the billing address for this order.
Parameters
OrderInterface $order: The commerce order object.
Return value
array
Throws
\Drupal\Core\TypedData\Exception\MissingDataException
1 call to WorldpayPaymentTrait::getBillingAddress()
- WorldpayRedirect::buildFormData in src/
Plugin/ Commerce/ PaymentGateway/ WorldpayRedirect.php
File
- src/
Plugin/ Commerce/ PaymentGateway/ WorldpayPaymentTrait.php, line 20
Class
Namespace
Drupal\commerce_worldpay\Plugin\Commerce\PaymentGatewayCode
private function getBillingAddress(OrderInterface $order) {
/** @var \Drupal\address\Plugin\Field\FieldType\AddressItem $address */
$billingAddress = $order
->getBillingProfile()
->get('address')
->first();
$country_list = \Drupal::service('address.country_repository')
->getList();
return [
'email' => $order
->get('mail')
->first()->value,
'first_name' => $billingAddress
->getGivenName(),
'surname' => $billingAddress
->getFamilyName(),
'address1' => $billingAddress
->getAddressLine1(),
'address2' => $billingAddress
->getAddressLine2(),
'city' => $billingAddress
->getLocality(),
'postCode' => $billingAddress
->getPostalCode(),
'countryCode' => $billingAddress
->getCountryCode(),
'country' => $country_list[$billingAddress
->getCountryCode()],
];
}