We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Requests.php 19.7 KB
Newer Older
attilak's avatar
[WIP]  
attilak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?php
/**
 *                       ######
 *                       ######
 * ############    ####( ######  #####. ######  ############   ############
 * #############  #####( ######  #####. ######  #############  #############
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
 * #############  #############  #############  #############  #####  ######
 *  ############   ############  #############   ############  #####  ######
 *                                      ######
 *                               #############
 *                               ############
 *
 * Adyen Payment module (https://www.adyen.com/)
 *
 * Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
 * See LICENSE.txt for license details.
 *
 * Author: Adyen <magento@adyen.com>
 */

namespace Adyen\Payment\Helper;

26
use Adyen\Payment\Observer\AdyenOneclickDataAssignObserver;
Ángel Campos's avatar
Ángel Campos committed
27
use Adyen\Util\Uuid;
attilak's avatar
[WIP]  
attilak committed
28 29 30 31 32
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Vault\Model\Ui\VaultConfigProvider;

use Adyen\Payment\Observer\AdyenHppDataAssignObserver;
use Adyen\Payment\Observer\AdyenCcDataAssignObserver;
33
use Magento\Quote\Api\Data\PaymentInterface;
attilak's avatar
[WIP]  
attilak committed
34

attilak's avatar
[WIP]  
attilak committed
35 36 37 38 39 40
class Requests extends AbstractHelper
{
    /**
     * @var \Adyen\Payment\Helper\Data
     */
    private $adyenHelper;
attilak's avatar
attilak committed
41 42 43 44 45
    /**
     * Requests constructor.
     *
     * @param Data $adyenHelper
     */
Ángel Campos's avatar
Ángel Campos committed
46

attilak's avatar
[WIP]  
attilak committed
47 48 49 50 51 52 53 54 55 56 57 58
    public function __construct(
        \Adyen\Payment\Helper\Data $adyenHelper
    ) {
        $this->adyenHelper = $adyenHelper;
    }

    /**
     * @param $request
     * @param $paymentMethod
     * @param $storeId
     * @return mixed
     */
59
    public function buildMerchantAccountData($paymentMethod, $storeId, $request = [])
attilak's avatar
[WIP]  
attilak committed
60 61 62 63 64 65 66 67 68 69 70 71 72
    {
        // Retrieve merchant account
        $merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($paymentMethod, $storeId);

        // Assign merchant account to request object
        $request['merchantAccount'] = $merchantAccount;

        return $request;
    }

    /**
     * @param int $customerId
     * @param $billingAddress
73 74
     * @param $storeId
     * @param null $payment
75
     * @param null $additionalData
76
     * @return array
77
     * @param array $request
attilak's avatar
[WIP]  
attilak committed
78
     */
79 80 81 82 83 84 85 86
    public function buildCustomerData(
        $billingAddress,
        $storeId,
        $customerId = 0,
        $payment = null,
        $additionalData = null,
        $request = []
    ) {
attilak's avatar
[WIP]  
attilak committed
87 88 89
        if ($customerId > 0) {
            $request['shopperReference'] = $customerId;
        }
Ángel Campos's avatar
Ángel Campos committed
90 91 92 93 94
        elseif ($this->adyenHelper->isGuestTokenizationEnabled($storeId)){
            $uuid = Uuid::generateV4();
            $guestCustomerId =  $payment->getOrder()->getIncrementId() . $uuid;
            $request['shopperReference'] = $guestCustomerId;
        }
attilak's avatar
[WIP]  
attilak committed
95

96 97 98 99
        $paymentMethod = '';
        if ($payment) {
            $paymentMethod = $payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE);
        }
attilak's avatar
attilak committed
100

101
        // In case of virtual product and guest checkout there is a workaround to get the guest's email address
102
        if (!empty($additionalData['guestEmail'])) {
103 104 105
            if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
                !$this->adyenHelper->isPaymentMethodAfterpayTouchMethod($paymentMethod)
            ) {
106
                $request['paymentMethod']['personalDetails']['shopperEmail'] = $additionalData['guestEmail'];
107
            } else {
108
                $request['shopperEmail'] = $additionalData['guestEmail'];
109 110 111
            }
        }

attilak's avatar
[WIP]  
attilak committed
112
        if (!empty($billingAddress)) {
attilak's avatar
attilak committed
113 114 115
            // Openinvoice (klarna and afterpay BUT not afterpay touch) methods requires different request format
            if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethod) &&
                !$this->adyenHelper->isPaymentMethodAfterpayTouchMethod($paymentMethod)
attilak's avatar
[WIP]  
attilak committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
            ) {
                if ($customerEmail = $billingAddress->getEmail()) {
                    $request['paymentMethod']['personalDetails']['shopperEmail'] = $customerEmail;
                }

                if ($customerTelephone = trim($billingAddress->getTelephone())) {
                    $request['paymentMethod']['personalDetails']['telephoneNumber'] = $customerTelephone;
                }

                if ($firstName = $billingAddress->getFirstname()) {
                    $request['paymentMethod']['personalDetails']['firstName'] = $firstName;
                }

                if ($lastName = $billingAddress->getLastname()) {
                    $request['paymentMethod']['personalDetails']['lastName'] = $lastName;
                }
            } else {
                if ($customerEmail = $billingAddress->getEmail()) {
                    $request['shopperEmail'] = $customerEmail;
                }

                if ($customerTelephone = trim($billingAddress->getTelephone())) {
                    $request['telephoneNumber'] = $customerTelephone;
                }

                if ($firstName = $billingAddress->getFirstname()) {
                    $request['shopperName']['firstName'] = $firstName;
                }

                if ($lastName = $billingAddress->getLastname()) {
                    $request['shopperName']['lastName'] = $lastName;
                }
            }

            if ($countryId = $billingAddress->getCountryId()) {
                $request['countryCode'] = $countryId;
            }
attilak's avatar
attilak committed
153 154

            $request['shopperLocale'] = $this->adyenHelper->getCurrentLocaleCode($storeId);
attilak's avatar
[WIP]  
attilak committed
155 156 157 158 159 160 161 162 163 164
        }

        return $request;
    }

    /**
     * @param $request
     * @param $ipAddress
     * @return mixed
     */
165
    public function buildCustomerIpData($ipAddress, $request = [])
attilak's avatar
[WIP]  
attilak committed
166 167 168 169 170 171 172 173 174 175 176 177
    {
        $request['shopperIP'] = $ipAddress;

        return $request;
    }

    /**
     * @param $request
     * @param $billingAddress
     * @param $shippingAddress
     * @return mixed
     */
178
    public function buildAddressData($billingAddress, $shippingAddress, $request = [])
attilak's avatar
[WIP]  
attilak committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192
    {
        if ($billingAddress) {
            // Billing address defaults
            $requestBillingDefaults = [
                "street" => "N/A",
                "postalCode" => '',
                "city" => "N/A",
                "houseNumberOrName" => '',
                "country" => "ZZ"
            ];

            // Save the defaults for later to compare if anything has changed
            $requestBilling = $requestBillingDefaults;

193
            $address = $this->getStreetStringFromAddress($billingAddress);
attilak's avatar
[WIP]  
attilak committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210

            if (!empty($address["name"])) {
                $requestBilling["street"] = $address["name"];
            }

            if (!empty($address["house_number"])) {
                $requestBilling["houseNumberOrName"] = $address["house_number"];
            }

            if (!empty($billingAddress->getPostcode())) {
                $requestBilling["postalCode"] = $billingAddress->getPostcode();
            }

            if (!empty($billingAddress->getCity())) {
                $requestBilling["city"] = $billingAddress->getCity();
            }

attilak's avatar
[WIP]  
attilak committed
211 212 213
            if (!empty($billingAddress->getRegionCode())) {
                $requestBilling["stateOrProvince"] = $billingAddress->getRegionCode();
            }
attilak's avatar
[WIP]  
attilak committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238

            if (!empty($billingAddress->getCountryId())) {
                $requestBilling["country"] = $billingAddress->getCountryId();
            }

            // If nothing is changed which means delivery address is not filled
            if ($requestBilling !== $requestBillingDefaults) {
                $request['billingAddress'] = $requestBilling;
            }
        }

        if ($shippingAddress) {
            // Delivery address defaults
            $requestDeliveryDefaults = [
                "street" => "N/A",
                "postalCode" => '',
                "city" => "N/A",
                "houseNumberOrName" => '',
                "country" => "ZZ"
            ];

            // Save the defaults for later to compare if anything has changed
            $requestDelivery = $requestDeliveryDefaults;

            // Parse address into street and house number where possible
239
            $address = $this->getStreetStringFromAddress($shippingAddress);
attilak's avatar
[WIP]  
attilak committed
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256

            if (!empty($address['name'])) {
                $requestDelivery["street"] = $address["name"];
            }

            if (!empty($address["house_number"])) {
                $requestDelivery["houseNumberOrName"] = $address["house_number"];
            }

            if (!empty($shippingAddress->getPostcode())) {
                $requestDelivery["postalCode"] = $shippingAddress->getPostcode();
            }

            if (!empty($shippingAddress->getCity())) {
                $requestDelivery["city"] = $shippingAddress->getCity();
            }

attilak's avatar
[WIP]  
attilak committed
257 258 259
            if (!empty($shippingAddress->getRegionCode())) {
                $requestDelivery["stateOrProvince"] = $shippingAddress->getRegionCode();
            }
attilak's avatar
[WIP]  
attilak committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274

            if (!empty($shippingAddress->getCountryId())) {
                $requestDelivery["country"] = $shippingAddress->getCountryId();
            }

            // If nothing is changed which means delivery address is not filled
            if ($requestDelivery !== $requestDeliveryDefaults) {
                $request['deliveryAddress'] = $requestDelivery;
            }
        }

        return $request;
    }

    /**
275
     * @param array $request
attilak's avatar
[WIP]  
attilak committed
276 277 278
     * @param $amount
     * @param $currencyCode
     * @param $reference
279 280
     * @param $paymentMethod
     * @return array
attilak's avatar
[WIP]  
attilak committed
281
     */
282
    public function buildPaymentData($amount, $currencyCode, $reference, $paymentMethod, $request = [])
attilak's avatar
[WIP]  
attilak committed
283 284 285
    {
        $request['amount'] = [
            'currency' => $currencyCode,
attilak's avatar
[WIP]  
attilak committed
286
            'value' => $this->adyenHelper->formatAmount($amount, $currencyCode)
attilak's avatar
[WIP]  
attilak committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300
        ];

        $request["reference"] = $reference;
        $request["fraudOffset"] = "0";

        return $request;
    }

    /**
     * @param array $request
     * @return array
     */
    public function buildBrowserData($request = [])
    {
301 302 303 304 305 306 307
        if (!empty($_SERVER['HTTP_USER_AGENT'])) {
            $request['browserInfo']['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
        }

        if (!empty($_SERVER['HTTP_ACCEPT'])) {
            $request['browserInfo']['acceptHeader'] = $_SERVER['HTTP_ACCEPT'];
        }
attilak's avatar
[WIP]  
attilak committed
308 309 310 311 312 313

        return $request;
    }

    /**
     * @param array $request
314 315
     * @param $additionalData
     * @param $storeId
attilak's avatar
[WIP]  
attilak committed
316 317
     * @return array
     */
318
    public function buildThreeDS2Data($additionalData, $storeId, $request = [])
attilak's avatar
[WIP]  
attilak committed
319
    {
320 321
        if ($this->adyenHelper->isCreditCardThreeDS2Enabled($storeId)) {
            $request['additionalData']['allow3DS2'] = true;
Ángel Campos's avatar
Ángel Campos committed
322
            $request['origin'] = $this->adyenHelper->getOrigin($storeId);
323 324 325 326 327 328 329 330 331 332 333 334
            $request['channel'] = 'web';
            $request['browserInfo']['screenWidth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_WIDTH];
            $request['browserInfo']['screenHeight'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_HEIGHT];
            $request['browserInfo']['colorDepth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_COLOR_DEPTH];
            $request['browserInfo']['timeZoneOffset'] = $additionalData[AdyenCcDataAssignObserver::TIMEZONE_OFFSET];
            $request['browserInfo']['language'] = $additionalData[AdyenCcDataAssignObserver::LANGUAGE];

            if ($javaEnabled = $additionalData[AdyenCcDataAssignObserver::JAVA_ENABLED]) {
                $request['browserInfo']['javaEnabled'] = $javaEnabled;
            } else {
                $request['browserInfo']['javaEnabled'] = false;
            }
attilak's avatar
[WIP]  
attilak committed
335
        } else {
336
            $request['additionalData']['allow3DS2'] = false;
Ángel Campos's avatar
Ángel Campos committed
337
            $request['origin'] = $this->adyenHelper->getOrigin($storeId);
338
            $request['channel'] = 'web';
attilak's avatar
[WIP]  
attilak committed
339
        }
340

attilak's avatar
[WIP]  
attilak committed
341 342 343
        return $request;
    }

Ángel Campos's avatar
Ángel Campos committed
344 345 346 347 348 349 350 351 352 353 354 355 356
    /**
     * @param array $request
     * @return array
     */
    public function buildRedirectData($storeId, $request = [])
    {
        $request['redirectFromIssuerMethod'] = 'GET';
        $request['redirectToIssuerMethod'] = 'POST';
        $request['returnUrl'] = $this->adyenHelper->getOrigin($storeId) . '/adyen/process/redirect';

        return $request;
    }

attilak's avatar
[WIP]  
attilak committed
357 358 359 360 361 362
    /**
     * @param $request
     * @param $areaCode
     * @param $storeId
     * @param $payment
     */
Ángel Campos's avatar
Ángel Campos committed
363
    public function buildRecurringData($areaCode, int $storeId, $additionalData, $customerId, $request = [])
attilak's avatar
[WIP]  
attilak committed
364
    {
Ángel Campos's avatar
Ángel Campos committed
365 366 367 368 369
        $isGuestUser = true;
        if ($customerId > 0) {
            $isGuestUser = false;
        }

attilak's avatar
[WIP]  
attilak committed
370 371 372 373 374 375 376 377
        // If the vault feature is on this logic is handled in the VaultDataBuilder
        if (!$this->adyenHelper->isCreditCardVaultEnabled()) {
            if ($areaCode !== \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
                $storeId = null;
            }

            $enableOneclick = $this->adyenHelper->getAdyenAbstractConfigData('enable_oneclick', $storeId);
            $enableRecurring = $this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', $storeId);
Ángel Campos's avatar
Ángel Campos committed
378
            if ($enableOneclick && !$isGuestUser) {
attilak's avatar
[WIP]  
attilak committed
379 380 381 382 383 384 385 386 387 388 389
                $request['enableOneClick'] = true;
            } else {
                $request['enableOneClick'] = false;
            }

            if ($enableRecurring) {
                $request['enableRecurring'] = true;
            } else {
                $request['enableRecurring'] = false;
            }

390
            // value can be 0,1 or true
Ángel Campos's avatar
Ángel Campos committed
391
            if (!empty($additionalData[AdyenCcDataAssignObserver::STORE_CC]) || ($isGuestUser && $this->adyenHelper->isGuestTokenizationEnabled($storeId))) {
attilak's avatar
[WIP]  
attilak committed
392 393 394 395 396 397 398 399 400 401
                $request['paymentMethod']['storeDetails'] = true;
            }
        }

        return $request;
    }

    /**
     * @param $request
     * @param $payment
402
     * @param $storeIdbuildCCData
attilak's avatar
[WIP]  
attilak committed
403 404
     * @return mixed
     */
405
    public function buildCCData($payload, $storeId, $areaCode, $request = [])
attilak's avatar
[WIP]  
attilak committed
406 407 408
    {
        // If ccType is set use this. For bcmc you need bcmc otherwise it will fail

409 410 411 412 413 414 415 416
        if (!empty($payload['method']) && $payload['method'] == 'adyen_oneclick' &&
            !empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]['variant'])
        ) {
            $request['paymentMethod']['type'] = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]['variant'];
        } else {
            $request['paymentMethod']['type'] = 'scheme';
        }

417 418 419 420
        if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER]) &&
            $cardNumber = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER]) {
attilak's avatar
[WIP]  
attilak committed
421 422 423
            $request['paymentMethod']['encryptedCardNumber'] = $cardNumber;
        }

424 425 426 427
        if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH]) &&
            $expiryMonth = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH]) {
attilak's avatar
[WIP]  
attilak committed
428 429 430
            $request['paymentMethod']['encryptedExpiryMonth'] = $expiryMonth;
        }

431 432 433 434
        if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR]) &&
            $expiryYear = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR]) {
attilak's avatar
[WIP]  
attilak committed
435 436 437
            $request['paymentMethod']['encryptedExpiryYear'] = $expiryYear;
        }

438 439
        if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::HOLDER_NAME]) && $holderName =
440
                $payload[PaymentInterface::KEY_ADDITIONAL_DATA][AdyenCcDataAssignObserver::HOLDER_NAME]) {
attilak's avatar
[WIP]  
attilak committed
441 442 443
            $request['paymentMethod']['holderName'] = $holderName;
        }

444 445 446 447
        if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE]) &&
            $securityCode = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE]) {
attilak's avatar
[WIP]  
attilak committed
448 449 450
            $request['paymentMethod']['encryptedSecurityCode'] = $securityCode;
        }

451 452 453 454
        if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE]) &&
            $recurringDetailReference = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
            [AdyenOneclickDataAssignObserver::RECURRING_DETAIL_REFERENCE]
455
        ) {
456 457 458
            $request['paymentMethod']['recurringDetailReference'] = $recurringDetailReference;
        }

459 460 461 462 463 464 465 466 467
        // set customerInteraction
        $recurringContractType = $this->adyenHelper->getAdyenOneclickConfigData('recurring_payment_type');
        if (!empty($payload['method']) && $payload['method'] == 'adyen_oneclick'
            && $recurringContractType == \Adyen\Payment\Model\RecurringType::RECURRING) {
            $request['shopperInteraction'] = "ContAuth";
        } else {
            $request['shopperInteraction'] = "Ecommerce";
        }

attilak's avatar
[WIP]  
attilak committed
468 469 470 471 472 473 474 475 476 477 478
        /**
         * if MOTO for backend is enabled use MOTO as shopper interaction type
         */
        $enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
        if ($areaCode === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE &&
            $enableMoto
        ) {
            $request['shopperInteraction'] = "Moto";
        }

        // if installments is set add it into the request
479 480 481 482
        if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA]
        [AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS])) {
            if (($numberOfInstallment = $payload[PaymentInterface::KEY_ADDITIONAL_DATA]
                [AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS]) > 0) {
attilak's avatar
attilak committed
483 484
                $request['installments']['value'] = $numberOfInstallment;
            }
attilak's avatar
[WIP]  
attilak committed
485 486 487 488 489 490 491 492 493 494 495
        }

        return $request;
    }


    /**
     * @param $request
     * @param $additionalInformation
     * @return mixed
     */
496
    public function buildVaultData($payload, $request = [])
attilak's avatar
[WIP]  
attilak committed
497
    {
498 499
        if ($this->adyenHelper->isCreditCardVaultEnabled()) {
            if (!empty($payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE]) &&
500 501 502
                $payload[PaymentInterface::KEY_ADDITIONAL_DATA][VaultConfigProvider::IS_ACTIVE_CODE] === true ||
                !empty($payload[VaultConfigProvider::IS_ACTIVE_CODE]) &&
                $payload[VaultConfigProvider::IS_ACTIVE_CODE] === true
503 504 505 506 507 508 509
            ) {
                // store it only as oneclick otherwise we store oneclick tokens (maestro+bcmc) that will fail
                $request['enableRecurring'] = true;
            } else {
                // explicity turn this off as merchants have recurring on by default
                $request['enableRecurring'] = false;
            }
attilak's avatar
[WIP]  
attilak committed
510 511 512 513
        }

        return $request;
    }
attilak's avatar
[WIP]  
attilak committed
514 515 516 517 518 519 520 521 522

    /**
     * The billing address retrieved from the Quote and the one retrieved from the Order has some differences
     * Therefore we need to check if the getStreetFull function exists and use that if yes, otherwise use the more
     * commont getStreetLine1
     *
     * @param $billingAddress
     * @return array
     */
523
    private function getStreetStringFromAddress($address)
attilak's avatar
[WIP]  
attilak committed
524
    {
525
        if (method_exists($address, 'getStreetFull')) {
attilak's avatar
[WIP]  
attilak committed
526
            // Parse address into street and house number where possible
527
            $address = $this->adyenHelper->getStreetFromString($address->getStreetFull());
attilak's avatar
[WIP]  
attilak committed
528
        } else {
529
            $address = $this->adyenHelper->getStreetFromString(
530 531 532 533 534 535 536 537 538 539
                implode(
                    ' ',
                    [
                        $address->getStreetLine1(),
                        $address->getStreetLine2(),
                        $address->getStreetLine3(),
                        $address->getStreetLine4()
                    ]
                )
            );
attilak's avatar
[WIP]  
attilak committed
540 541 542 543
        }

        return $address;
    }
attilak's avatar
[WIP]  
attilak committed
544
}