Use the order reference object to query the order information, including
the current physical delivery address as selected by the buyer

@return OffAmazonPaymentsService_Model_GetOrderReferenceDetailsResponse service response
325844
public function getOrderReferenceDetails($addressConsentToken = null)
	{
		$getOrderReferenceDetailsRequest = new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
		$getOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
		$getOrderReferenceDetailsRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
		
		if (is_null($addressConsentToken) == FALSE) {
			$decodedToken = urldecode($addressConsentToken);
			$getOrderReferenceDetailsRequest->setAddressConsentToken($decodedToken);
		}
	
		return $this->_service->getOrderReferenceDetails($getOrderReferenceDetailsRequest);
	}
1027519
function _GetTransactionDetails($oID) {
    if ($oID == '' || $oID < 1) return FALSE;
    global $db, $messageStack, $doPayPal;
    $doPayPal = $this->paypal_init();
    // look up history on this order from PayPal table
    $sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID order by last_modified DESC, date_added DESC, parent_txn_id DESC, paypal_ipn_id DESC ";
    $sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
    $zc_ppHist = $db->Execute($sql);
    if ($zc_ppHist->RecordCount() == 0) return false;
    $txnID = $zc_ppHist->fields['txn_id'];
    if ($txnID == '' || $txnID === 0) return FALSE;
    /**
     * Read data from PayPal
     */
    $response = $doPayPal->GetTransactionDetails($txnID);

    $error = $this->_errorHandler($response, 'GetTransactionDetails', 10007);
    if ($error === false) {
      return false;
    } else {
      return $response;
    }
  }
1350041
public function getOrder()
    {
        if ($this->oxorderarticles__oxorderid->value) {
            // checking if the object already exists in the cache
            if (isset($this->_aOrderCache[$this->oxorderarticles__oxorderid->value])) {
                // returning the cached object
                return $this->_aOrderCache[$this->oxorderarticles__oxorderid->value];
            }
            // creatina new order object and trying to load it
            $oOrder = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
            if ($oOrder->load($this->oxorderarticles__oxorderid->value)) {
                return $this->_aOrderCache[$this->oxorderarticles__oxorderid->value] = $oOrder;
            }
        }

        return null;
    }
1245709
private function getOrderStoreReference()
    {
        return \UOL\PagSeguro\Helper\Data::getOrderStoreReference(
            $this->_scopeConfig->getValue('pagseguro/store/reference'),
            $this->_checkoutSession->getLastRealOrder()->getEntityId()
        );
    }
288576
public function cancelOrderReference()
    {
        $cancelOrderReferenceRequest 
            = new OffAmazonPaymentsService_Model_CancelOrderReferenceRequest();
        $cancelOrderReferenceRequest->setSellerId($this->_sellerId);
        $cancelOrderReferenceRequest
            ->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
        
        return $this->_service->cancelOrderReference($cancelOrderReferenceRequest);
    }
1368325
public function setupOrderReference()
    {
        $orderTotal = new OffAmazonPaymentsService_Model_OrderTotal();
        $orderTotal->setCurrencyCode($this->_currencyCode);
        $orderTotal->setAmount($this->_orderTotalAmount);
        
        $setOrderReferenceDetailsRequest 
            = new OffAmazonPaymentsService_Model_SetOrderReferenceDetailsRequest();
        $setOrderReferenceDetailsRequest->setSellerId($this->_sellerId);
        $setOrderReferenceDetailsRequest
            ->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
        $setOrderReferenceDetailsRequest
            ->setOrderReferenceAttributes(
                new OffAmazonPaymentsService_Model_OrderReferenceAttributes()
            );
        $setOrderReferenceDetailsRequest
            ->getOrderReferenceAttributes()->setOrderTotal($orderTotal);
        
        return $this->_service->setOrderReferenceDetails(
            $setOrderReferenceDetailsRequest
        );
    }
283039
public function getDeliveryAddress()
    {
        $address = ($this->DeliveryAddress1) ? $this->DeliveryAddress1 . ",\n" : '';
        $address .= ($this->DeliveryAddress2) ? $this->DeliveryAddress2 . ",\n" : '';
        $address .= ($this->DeliveryCity) ? $this->DeliveryCity . ",\n" : '';
        $address .= ($this->DeliveryPostCode) ? $this->DeliveryPostCode . ",\n" : '';
        $address .= ($this->DeliveryCountry) ? $this->DeliveryCountry : '';

        return $address;
    }
1301482
public function getExpressCheckoutDetails()
    {
        try {
            $payPalService = $this->getPayPalCheckoutService();
            $builder = oxNew(\OxidEsales\PayPalModule\Model\PayPalRequest\GetExpressCheckoutDetailsRequestBuilder::class);
            $builder->setSession($this->getSession());

            $request = $builder->buildRequest();

            $details = $payPalService->getExpressCheckoutDetails($request);
        } catch (\OxidEsales\Eshop\Core\Exception\StandardException $excp) {
            // display error message
            $this->getUtilsView()->addErrorToDisplay($excp);

            // problems fetching user info - redirect to payment selection
            return 'payment';
        }

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

        // next step - order page
        $next = 'order';

        // finalize order on paypal side?
        if ($this->getPayPalConfig()->finalizeOrderOnPayPalSide()) {
            $next .= "?fnc=execute";
        }

        // everything is fine - redirect to order
        return $next;
    }
1343624
public function request()
    {
        //load payments by date
        $this->getPagSeguroAbandoned();

        if ($this->_PagSeguroPaymentList->getTransactions()) {
            foreach ($this->_PagSeguroPaymentList->getTransactions() as $payment) {
                date_default_timezone_set('UTC');
                $order = \UOL\PagSeguro\Helper\Data::getReferenceDecryptOrderID($payment->getReference());
                $order = $this->_order->load($order);
                if ($this->getStoreReference() == \UOL\PagSeguro\Helper\Data::getReferenceDecrypt(
                        $payment->getReference())
                ) {
                    if (!is_null($this->_session->getData('store_id'))) {
                        array_push($this->_arrayPayments, $this->build($payment, $order));
                    }
                    if ($order) {
                        array_push($this->_arrayPayments, $this->build($payment, $order));
                    }
                }
            }
        }
        date_default_timezone_set($this->_timezone->getConfigTimezone());

        return $this->_arrayPayments;
    }
1151139
public function getShipmentDetailsClass_v2() {
		$class = new StdClass;

		$class->product = $this->getProduct();
		$class->accountNumber = $this->getAccountNumber();
		if($this->getCustomerReference() !== null)
			$class->customerReference = $this->getCustomerReference();
		$class->shipmentDate = $this->getShipmentDate();
		if($this->getReturnAccountNumber() !== null)
			$class->returnShipmentAccountNumber = $this->getReturnAccountNumber();
		if($this->getReturnReference() !== null)
			$class->returnShipmentReference = $this->getReturnReference();

		$class->ShipmentItem = new StdClass;
		$class->ShipmentItem->weightInKG = $this->getWeight();
		if($this->getLength() !== null)
			$class->ShipmentItem->lengthInCM = $this->getLength();
		if($this->getWidth() !== null)
			$class->ShipmentItem->widthInCM = $this->getWidth();
		if($this->getHeight() !== null)
			$class->ShipmentItem->heightInCM = $this->getHeight();

		if($this->getService() !== null)
			$class->Service = $this->getService()->getServiceClass_v2($this->getProduct());

		if($this->getNotificationEmail() !== null) {
			$class->Notification = new StdClass;
			$class->Notification->recipientEmailAddress = $this->getNotificationEmail();
		}

		if($this->getBank() !== null)
			$class->BankData = $this->getBank()->getBankClass_v2();

		return $class;
	}
159661
public function getDeliveryAddressInfo()
    {
        $address = new Address();

        $address->setAddress($this->getDeliveryAddress());
        $address->setPostalCode($this->getDeliveryPostalCode());
        $address->setCity($this->getDeliveryCity());
        $address->setState($this->getDeliveryState());
        $address->setCountry($this->getDeliveryCountry());

        return $address;
    }
622010
public function getOrderDeliveryPrice()
    {
        if ($this->_oDelPrice != null) {
            return $this->_oDelPrice;
        }

        $this->_oDelPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $this->_oDelPrice->setBruttoPriceMode();
        $this->_oDelPrice->setPrice($this->oxorder__oxdelcost->value, $this->oxorder__oxdelvat->value);

        return $this->_oDelPrice;
    }
1256597
public function usememberaddress()
    {
        $allowed_otherids = array("billing","delivery");
        $id = $this->request->param("ID");
        $otherid = $this->request->param("OtherID");
        $data = array();
        $member = Member::currentUser();
        $address = MemberAddress::get()->byID($id);
        $action = "billing";

        // If our required details are not set, return a server error
        if (
            !$address ||
            !$member ||
            ($address && !$address->canView($member)) ||
            !in_array($otherid, $allowed_otherids)
        ) {
            return $this
                ->httpError(
                    404,
                    "There was an error selecting your address"
                );
        }

        // Set the session data
        if ($otherid == "billing") {
            $data["FirstName"]  = $address->FirstName;
            $data["Surname"]    = $address->Surname;
            $data["Address1"]   = $address->Address1;
            $data["Address2"]   = $address->Address2;
            $data["City"]       = $address->City;
            $data["PostCode"]   = $address->PostCode;
            $data["Country"]    = $address->Country;
            $data["Email"]      = $member->Email;
            $data["PhoneNumber"]= $member->PhoneNumber;
            $data["Company"]    = $address->Company;

            Session::set("Checkout.BillingDetailsForm.data", $data);
            $action = "delivery";
        }

        if ($otherid == "delivery" || !ShoppingCart::get()->isDeliverable()) {
            $data['DeliveryCompany']  = $address->Company;
            $data['DeliveryFirstnames']  = $address->FirstName;
            $data['DeliverySurname']    = $address->Surname;
            $data['DeliveryAddress1']   = $address->Address1;
            $data['DeliveryAddress2']   = $address->Address2;
            $data['DeliveryCity']       = $address->City;
            $data['DeliveryPostCode']   = $address->PostCode;
            $data['DeliveryCountry']    = $address->Country;

            Session::set("Checkout.DeliveryDetailsForm.data", $data);
            $action = "finish";
        }

        $this->extend("onBeforeUseMemberAddress");

        return $this->redirect($this->Link($action));
    }
402482
private function _calculatePaymentAmountBasedOnBuyerDestinationAddress ()
    {
        $response = $this->callStepAndCheckForException('getBillingAgreementDetails');
        
        $this->printResponseToWebpage("printGetBillingAgreementDetailsResponse", array(
            $response
        ));
        
        $paymentAmountPreTaxAndShipping = $this->_getPreTaxAndShippingPaymentAmountFromQueryParams();
        $shippingType = $this->_getShippingTypeFromQueryParams();
        
        return $this->exampleClass->calculatePaymentAmountBasedOnBuyerDetails(
                $response->getGetBillingAgreementDetailsResult()
                    ->getBillingAgreementDetails(), $paymentAmountPreTaxAndShipping, $shippingType);
    }
138720
public function getDeliveryList()
    {
        if ($this->_oDelList === null) {
            $this->_oDelList = oxNew(\OxidEsales\Eshop\Application\Model\DeliveryList::class);
            $this->_oDelList->getList();
        }

        return $this->_oDelList;
    }
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;
    }
1138044
public function getOrderReference(TransactionInterface $transaction)
    {
        $order = $transaction->get('order', null);

        if ($this->getLogger()) {
            $this->getLogger()->notice(sprintf('[BasePaypalPayment::loadOrder] order=%s', $order));
        }

        return $order;
    }