Loads order associated with current PayPal order

@return bool
967927
public function loadPayPalOrder()
    {
        $orderId = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable("sess_challenge");

        // if order is not created yet - generating it
        if ($orderId === null) {
            $orderId = \OxidEsales\Eshop\Core\UtilsObject::getInstance()->generateUID();
            $this->setId($orderId);
            $this->save();
            \OxidEsales\Eshop\Core\Registry::getSession()->setVariable("sess_challenge", $orderId);
        }

        return $this->load($orderId);
    }
776705
public function getPayPalRequest()
    {
        if ($this->payPalRequest === null) {
            $this->payPalRequest = oxNew(\OxidEsales\PayPalModule\Core\Request::class);
        }

        return $this->payPalRequest;
    }
1196053
public function getOrder()
    {
        if (is_null($this->order)) {
            /** @var \OxidEsales\PayPalModule\Core\Exception\PayPalResponseException $exception */
            $exception = oxNew(\OxidEsales\PayPalModule\Core\Exception\PayPalResponseException::class, 'OEPAYPAL_ORDER_ERROR');
            throw $exception;
        }

        return $this->order;
    }
937913
public function getPayPalService()
    {
        if ($this->payPalService === null) {
            $this->payPalService = oxNew(\OxidEsales\PayPalModule\Core\PayPalService::class);
        }

        return $this->payPalService;
    }
423217
public function loadUserPayPalUser()
    {
        $result = false;
        if (($userId = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable("oepaypal-userId"))) {
            $result = $this->load($userId);
        }

        return $result;
    }
1236017
public function getOrder()
    {
        $request = $this->getRequestHandler();

        $listener = new PayPalListener($request);
        $listener->setMode($this->getEnvironment());

        if ($listener->verifyIpn()) {
            return $this->store($request->getData());
        } else {
            throw new InvalidIpnException("PayPal as responded with INVALID");
        }
    }
3888
public function paymentSuccessful() {
    if ($this->requestHasSucceeded() && $this->requestMethod->isDirectPayment()) {
      return $this->requestMethod->getTransactionSuccessfulCode() == $this->response['resultPayment'];
    }

    return false;
  }
197569
public function getOrdered()
    {
        if (!$this->sort) {
            return $this->content;
        }

        $unordered = [];
        foreach ($this->content as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        $sort = json_decode($this->sort, true);
        $order = $sort['order'];
        foreach ($order as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
21476
public function loadCurrency()
    {
        if ($this->_blLoadCurrency == null) {
            $this->_blLoadCurrency = false;
            if ($loadCurrency = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadCurrency')) {
                $this->_blLoadCurrency = $loadCurrency;
            }
        }

        return $this->_blLoadCurrency;
    }
1160594
public function updateOrderStatus()
    {
        $orderUpdated = false;
        $order = $this->getOrder();

        if (!is_null($order)) {
            $orderPayment = $this->getOrderPayment();
            $order = $this->recalculateAmounts($order);
            $newOrderStatus = $this->calculateOrderStatus($orderPayment, $order);
            $this->persistNewOrderStatus($order, $newOrderStatus);
            $orderUpdated = true;
        }

        return $orderUpdated;
    }
642495
public function execute()
    {
        if ($this->order !== null) {
            $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, Orders::PATH, $this->order->getId(), self::PATH);
        } else {
            $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, Multiorders::PATH, $this->multiorder->getId(), self::MULTI_PAYMENTS_PATH);
        }

        $response = $this->httpRequest($path, Requests::POST, $this);

        return $this->populate($response);
    }
1190921
private function order()
    {
        $result = [];

        $data = $this->request;

        if ($data['table1'] > $data['table2']) {
            $result['first'] = $data['table2'];
            $result['second'] = $data['table1'];
        } else {
            $result['first'] = $data['table1'];
            $result['second'] = $data['table2'];
        }

        return $result;
    }
677349
protected function getOrderFromPayment($orderPayment)
    {
        $orderId = null;
        $order = null;
        if (!is_null($orderPayment)) {
            $orderId = $orderPayment->getOrderId();
        }
        if (!is_null($orderId)) {
            $order = oxNew(\OxidEsales\PayPalModule\Model\PayPalOrder::class);
            $order->setOrderId($orderId);
            $order->load();
        }

        return $order;
    }
785113
public function getPayPalCheckoutService()
    {
        if ($this->payPalCheckoutService === null) {
            $this->payPalCheckoutService = oxNew(\OxidEsales\PayPalModule\Core\PayPalService::class);
        }

        return $this->payPalCheckoutService;
    }
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;
    }
889115
public function loadPaymorrowDefault()
    {
        /** @var OxpsPaymorrowOxPayment|oxPayment $this */

        $query = sprintf(
            "SELECT * FROM `%s`WHERE %s AND `OXCHECKED` = 1 ORDER BY `OXSORT` ASC, `OXTIMESTAMP` DESC LIMIT 1",
            $this->getViewName(),
            $this->getPaymorrowMethodWhereClause()
        );

        return $this->assignRecord($query);
    }
3291
function after_process() {
    global $insert_id, $db, $order;
    if ($_SESSION['paypal_transaction_PDT_passed'] != true) {
      $_SESSION['order_created'] = '';
      unset($_SESSION['paypal_transaction_PDT_passed']);
      return false;
    } else {
    // PDT found order to be approved, so add a new OSH record for this order's PP details
      unset($_SESSION['paypal_transaction_PDT_passed']);
      $sql_data_array= array(array('fieldName'=>'orders_id', 'value'=>$insert_id, 'type'=>'integer'),
                             array('fieldName'=>'orders_status_id', 'value'=>$this->order_status, 'type'=>'integer'),
                             array('fieldName'=>'date_added', 'value'=>'now()', 'type'=>'noquotestring'),
                             array('fieldName'=>'customer_notified', 'value'=>0, 'type'=>'integer'),
                             array('fieldName'=>'comments', 'value'=>'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency'] . '.', 'type'=>'string'));
      $db->perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
      ipn_debug_email('PDT NOTICE :: Order added: ' . $insert_id . "\n" . 'PayPal status: ' . $this->pdtData['payment_status'] . ' ' . ' @ ' . $this->pdtData['payment_date'] . "\n" . ' Trans ID:' . $this->pdtData['txn_id'] . "\n" . ' Amount: ' . $this->pdtData['mc_gross'] . ' ' . $this->pdtData['mc_currency']);

      // store the PayPal order meta data -- used for later matching and back-end processing activities
      $sql_data_array = array('order_id' => $insert_id,
                          'txn_type' => $this->pdtData['txn_type'],
                          'module_name' => $this->code . ' ' . $this->codeVersion,
                          'module_mode' => 'PDT',
                          'reason_code' => $this->pdtData['reasoncode'],
                          'payment_type' => $this->pdtData['payment_type'],
                          'payment_status' => $this->pdtData['payment_status'],
                          'pending_reason' => $this->pdtData['pendingreason'],
                          'invoice' => $this->pdtData['invoice'],
                          'first_name' => $this->pdtData['first_name'],
                          'last_name' => $this->pdtData['last_name'],
                          'payer_business_name' => $order->billing['company'],
                          'address_name' => $order->billing['name'],
                          'address_street' => $order->billing['street_address'],
                          'address_city' => $order->billing['city'],
                          'address_state' => $order->billing['state'],
                          'address_zip' => $order->billing['postcode'],
                          'address_country' => $this->pdtData['residence_country'], // $order->billing['country']
                          'address_status' => $this->pdtData['address_status'],
                          'payer_email' => $this->pdtData['payer_email'],
                          'payer_id' => $this->pdtData['payer_id'],
                          'payer_status' => $this->pdtData['payer_status'],
                          'payment_date' => datetime_to_sql_format($this->pdtData['payment_date']),
                          'business' => $this->pdtData['business'],
                          'receiver_email' => $this->pdtData['receiver_email'],
                          'receiver_id' => $this->pdtData['receiver_id'],
                          'txn_id' => $this->pdtData['txn_id'],
                          'parent_txn_id' => $this->pdtData['parent_txn_id'],
                          'num_cart_items' => (float)$this->pdtData['num_cart_items'],
                          'mc_gross' => (float)$this->pdtData['mc_gross'],
                          'mc_fee' => (float)$this->pdtData['mc_fee'],
                          'mc_currency' => $this->pdtData['mc_currency'],
                          'settle_amount' => (float)$this->pdtData['settle_amount'],
                          'settle_currency' => $this->pdtData['settle_currency'],
                          'exchange_rate' => ($this->pdtData['exchange_rate'] > 0 ? $this->pdtData['exchange_rate'] : 1.0),
                          'notify_version' => (float)$this->pdtData['notify_version'],
                          'verify_sign' => $this->pdtData['verify_sign'],
                          'date_added' => 'now()',
                          'memo' => '{Successful PDT Confirmation - Record auto-generated by payment module}'
                         );
//TODO: $db->perform vs zen_db_perform
      zen_db_perform(TABLE_PAYPAL, $sql_data_array);
      ipn_debug_email('PDT NOTICE :: paypal table updated: ' . print_r($sql_data_array, true));
    }
  }