You are here

public function WorldPayHelper::addShipmentAddress in Commerce Worldpay 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Commerce/PaymentGateway/WorldPayHelper.php \Drupal\commerce_worldpay\Plugin\Commerce\PaymentGateway\WorldPayHelper::addShipmentAddress()

Parameters

array $addressData:

Throws

\Drupal\Core\TypedData\Exception\MissingDataException

File

src/Plugin/Commerce/PaymentGateway/WorldPayHelper.php, line 49

Class

WorldPayHelper
Class WorldPayHelper Helper class for collecting form data.

Namespace

Drupal\commerce_worldpay\Plugin\Commerce\PaymentGateway

Code

public function addShipmentAddress(array $addressData) {
  if (NULL === $addressData) {
    throw new MissingDataException('There is no address data provided!');
  }
  $address = $addressData['DeliveryAddress1'];
  $address .= PHP_EOL;
  $address .= $addressData['DeliveryAddress2'];
  $address .= PHP_EOL;
  $address .= $addressData['DeliveryCity'];
  $this->data += [
    'name' => $addressData['DeliveryFirstname'] . ' ' . $addressData['DeliverySurname'],
    'address' => $address,
    'postcode' => $addressData['DeliveryPostCode'],
    'country' => $addressData['DeliveryCountry'],
    'countryString' => $addressData['DeliveryCountryString'],
  ];
}