Prepare address data array from PayPal response data.

@param \OxidEsales\PayPalModule\Model\Response\ResponseGetExpressCheckoutDetails $payPalData PayPal data.

@return array
774670
protected function prepareDataPayPalUser($payPalData)
    {
        $userData = array();

        $fullName = oxNew(\OxidEsales\PayPalModule\Core\FullName::class, $payPalData->getShipToName());

        $userData['oxfname'] = $fullName->getFirstName();
        $userData['oxlname'] = $fullName->getLastName();

        $street = $this->splitShipToStreetPayPalUser($payPalData->getShipToStreet());
        $userData['oxstreet'] = $street['street'];
        $userData['oxstreetnr'] = $street['streetnr'];

        $userData['oxcity'] = $payPalData->getShipToCity();

        $country = oxNew(\OxidEsales\Eshop\Application\Model\Country::class);
        $countryId = $country->getIdByCode($payPalData->getShipToCountryCode());
        $userData['oxcountryid'] = $countryId;

        $stateId = '';
        if ($payPalData->getShipToState()) {
            $state = oxNew(\OxidEsales\Eshop\Application\Model\State::class);
            $stateId = $state->getIdByCode($payPalData->getShipToState(), $countryId);
        }
        $userData['oxstateid'] = $stateId;

        $userData['oxzip'] = $payPalData->getShipToZip();
        $userData['oxfon'] = $payPalData->getShipToPhoneNumber();
        $userData['oxaddinfo'] = $payPalData->getShipToStreet2();
        $userData['oxsal'] = $payPalData->getSalutation();
        $userData['oxcompany'] = $payPalData->getBusiness();

        return $userData;
    }
905239
public function get_details_for($token, $payer_id)
  {
      $this->payer_id = urldecode($payer_id);
      $this->token = urldecode($token);

      $params = array(
        'METHOD' => 'GetExpressCheckoutDetails',
        'TOKEN' => $token,
    );
      $this->post = array_merge($this->post, $params);

      Merchant_Logger::log('Commit Paypal Method: GetExpressCheckoutDetails');

      return $this->commit($this->urlize($this->post));
  }
1301294
public function getPaymentDetailAction(PayoneGetPaymentDetailTransfer $getPaymentDetailTransfer)
    {
        if (!empty($getPaymentDetailTransfer->getOrderReference())) {
            $order = SpySalesOrderQuery::create()
                ->filterByOrderReference($getPaymentDetailTransfer->getOrderReference())
                ->findOne();
            $getPaymentDetailTransfer->setOrderId($order->getIdSalesOrder());
        }
        $response = $this->getFacade()->getPaymentDetail($getPaymentDetailTransfer->getOrderId());
        $getPaymentDetailTransfer->setPaymentDetail($response);
        return $getPaymentDetailTransfer;
    }
874722
protected function PrepareDataForSave($postData)
    {
        if (array_key_exists('active', $postData)) {
            if (!array_key_exists('variant_parent_id', $postData) || empty($postData['variant_parent_id'])) {
                $postData['variant_parent_is_active'] = $postData['active'];
            }
        }

        return $postData;
    }
1338844
private function prepareValues($arrayData)
    {
        $arrayData = array_values($arrayData);

        $preparedValues = [];
        $vNumber = 1;
        foreach ($arrayData as $value) {
            $preparedValues[":value{$vNumber}"] = "$value";
            $vNumber++;
        }

        unset($arrayData);
        unset($vNumber);

        return $preparedValues;
    }
817432
private function _readBIFF5CellRangeAddressList($subData)
	{
		$cellRangeAddresses = array();

		// offset: 0; size: 2; number of the following cell range addresses
		$nm = self::_GetInt2d($subData, 0);

		$offset = 2;
		// offset: 2; size: 6 * $nm; list of $nm (fixed) cell range addresses
		for ($i = 0; $i < $nm; ++$i) {
			$cellRangeAddresses[] = $this->_readBIFF5CellRangeAddressFixed(substr($subData, $offset, 6));
			$offset += 6;
		}

		return array(
			'size' => 2 + 6 * $nm,
			'cellRangeAddresses' => $cellRangeAddresses,
		);
	}
937948
protected function storeCartDetails($cartData)
    {
        $cartData = $this->arraySnakeCase($cartData);

        $cart = Cart::updateOrCreate(
            $this->cartIdentifier(),
            array_merge($cartData, $this->getCookieElement())
        );

        return $cart->id;
    }
996322
public function getExpressCheckoutDetails()
    {
        $basket = $this->getSession()->getBasket();

        try {
            $payPalService = $this->getPayPalCheckoutService();
            $builder = oxNew(\OxidEsales\PayPalModule\Model\PayPalRequest\GetExpressCheckoutDetailsRequestBuilder::class);
            $builder->setSession($this->getSession());
            $request = $builder->buildRequest();
            $details = $payPalService->getExpressCheckoutDetails($request);

            // Remove flag of "new item added" to not show "Item added" popup when returning to checkout from paypal
            $basket->isNewItemAdded();

            // creating new or using session user
            $user = $this->initializeUserData($details);
        } catch (\OxidEsales\Eshop\Core\Exception\StandardException $excp) {
            $this->getUtilsView()->addErrorToDisplay($excp);

            $logger = $this->getLogger();
            $logger->log("PayPal error: " . $excp->getMessage());

            return "basket";
        }

        // setting PayPal as current active payment
        $this->getSession()->setVariable('paymentid', "oxidpaypal");
        $basket->setPayment("oxidpaypal");

        if (!$this->isPaymentValidForUserCountry($user)) {
            $this->getUtilsView()->addErrorToDisplay('MESSAGE_PAYMENT_SELECT_ANOTHER_PAYMENT');

            $logger = $this->getLogger();
            $logger->log("Shop error: PayPal payment validation by user country failed. Payment is not valid for this country.");

            return "payment";
        }

        $shippingId = $this->extractShippingId(urldecode($details->getShippingOptionName()), $user);

        $this->setAnonymousUser($basket, $user);

        $basket->setShipping($shippingId);
        $basket->onUpdate();
        $basket->calculateBasket(true);

        $basketPrice = $basket->getPrice()->getBruttoPrice();

        if (!$this->isPayPalPaymentValid($user, $basketPrice, $basket->getShippingId())) {
            $this->getUtilsView()->addErrorToDisplay("OEPAYPAL_SELECT_ANOTHER_SHIPMENT");

            return "order";
        }

        // Checking if any additional discount was applied after we returned from PayPal.
        if ($basketPrice != $details->getAmount()) {
            $this->getUtilsView()->addErrorToDisplay("OEPAYPAL_ORDER_TOTAL_HAS_CHANGED");

            return "basket";
        }

        $this->getSession()->setVariable("oepaypal-payerId", $details->getPayerId());
        $this->getSession()->setVariable("oepaypal-userId", $user->getId());
        $this->getSession()->setVariable("oepaypal-basketAmount", $details->getAmount());

        $next = "order";

        if ($this->getPayPalConfig()->finalizeOrderOnPayPalSide()) {
            $next .= "?fnc=execute";
        }

        return $next;
    }
242730
private function setPaymentOptionsReceiverDetails($receivers)
    {
        return collect($receivers)->map(function ($receiver) {
            $item = [];

            $item['receiver'] = [
                'email' => $receiver['email'],
            ];

            $item['invoiceData']['item'] = collect($receiver['invoice_data'])->map(function ($invoice) {
                return $invoice;
            })->toArray();

            $item['description'] = $receiver['description'];

            return $item;
        })->toArray();
    }
442026
private function preparePaymentMethod()
    {
        $paymentMethod = "";

        if(!empty($this->_detailsTransactionByCode->getPaymentMethod()))
        {
            $paymentMethod = array(
                'code' => $this->_detailsTransactionByCode->getPaymentMethod()->getCode(),
                'type' => $this->_detailsTransactionByCode->getPaymentMethod()->getType(),
                'titleType' => \UOL\PagSeguro\Helper\Data::getTitleTypePaymentMethod($this->_detailsTransactionByCode->getPaymentMethod()->getType()),
                'titleCode' => \UOL\PagSeguro\Helper\Data::getTitleCodePaymentMethod($this->_detailsTransactionByCode->getPaymentMethod()->getCode())
            );
        }
        return $paymentMethod;
    }
1071733
private function serializePaymentDataGooglePay(PaymentDataGooglePay $paymentData)
    {
        $result = array(
            'type'                  => $paymentData->getType(),
            'payment_method_token'  => $paymentData->getPaymentMethodToken(),
            'google_transaction_id' => $paymentData->getGoogleTransactionId(),
        );

        return $result;
    }
871642
public function isSameAddressPayPalUser($details)
    {
        $userData = array();
        $userData[] = \OxidEsales\Eshop\Core\Str::getStr()->html_entity_decode($this->oxuser__oxstreet->value);
        $userData[] = \OxidEsales\Eshop\Core\Str::getStr()->html_entity_decode($this->oxuser__oxstreetnr->value);
        $userData[] = \OxidEsales\Eshop\Core\Str::getStr()->html_entity_decode($this->oxuser__oxcity->value);

        $street = $this->splitShipToStreetPayPalUser($details->getShipToStreet());

        $compareData = array();
        $compareData[] = $street['street'];
        $compareData[] = $street['streetnr'];
        $compareData[] = $details->getShipToCity();

        return $userData == $compareData;
    }
1366721
protected function getAddressData($type = 'Billing')
    {
        $card = $this->getCard();

        // Mapping is Sage Pay name => Omnipay Name

        $mapping = [
            'Firstnames'    => 'FirstName',
            'Surname'       => 'LastName',
            'Address1'      => 'Address1',
            'Address2'      => 'Address2',
            'City'          => 'City',
            'PostCode'      => 'Postcode',
            'State'         => 'State',
            'Country'       => 'Country',
            'Phone'         => 'Phone',
        ];

        $data = [];

        foreach ($mapping as $sagepayName => $omnipayName) {
            $data[$sagepayName] = call_user_func([$card, 'get' . $type . $omnipayName]);
        }

        // The state must not be set for non-US countries.

        if ($data['Country'] !== 'US') {
            $data['State'] = '';
        }

        return $data;
    }
394708
public function updatePaymentDetail(PaymentDetailTransfer $paymentData, $idOrder)
    {
        $this->getFactory()->createPaymentManager()->updatePaymentDetail($paymentData, $idOrder);
    }
441342
public function getData()
    {
        $this->validate('transactionReference', 'MD', 'PaRes');

        return [
            'opcode'     => 3,
            'payment_id' => $this->getTransactionReference(),
            'PaRes'      => $this->getPaRes(),
            'MD'         => $this->getMD(),
            'token'      => $this->getRequestToken(),
        ];
    }
82281
private function _calculateOrderTotalBasedOnBuyerDestinationAddress() 
    {
        $response = $this->callStepAndCheckForException('getOrderReferenceDetails');
        printGetOrderReferenceDetailsResponse($response);
        
        $orderTotalPreTaxAndShipping 
             = $this->_getPreTaxAndShippingOrderAmountFromStdIn();
        $shippingType = $this->_getShippingTypeFromStdIn();

        return $this->exampleClass->calculateOrderTotalBasedOnBuyerDetails(
            $response->getGetOrderReferenceDetailsResult()->getOrderReferenceDetails(),
            $orderTotalPreTaxAndShipping, 
            $shippingType
        );
    }
862988
public static function GetDirectLinkResponsePaymentUserDataFields()
    {
        return array(self::GetDirectLinkResponsePaymentUserDataFieldPrefix().'PAYID', self::GetDirectLinkResponsePaymentUserDataFieldPrefix().'STATUS', self::GetDirectLinkResponsePaymentUserDataFieldPrefix().'AMOUNT', self::GetDirectLinkResponsePaymentUserDataFieldPrefix().'CURRENCY', self::GetDirectLinkResponsePaymentUserDataFieldPrefix().'PM', self::GetDirectLinkResponsePaymentUserDataFieldPrefix().'BRAND', self::GetDirectLinkResponsePaymentUserDataFieldPrefix().'HTML_ANSWER');
    }