@param bool $bRefresh

@throws TPkgShopOrderStatusException_OrderStatusCodeNotFound

@return TdbShopOrderStatusCode
187779
public function getShopOrderStatusCodeObject($bRefresh = false)
    {
        if (true === $bRefresh) {
            $this->shopOrderStatusCodeObject = null;
        }
        if (null === $this->shopOrderStatusCodeObject) {
            $this->shopOrderStatusCodeObject = TdbShopOrderStatusCode::GetNewInstance();
            $aFilter = array(
                'shop_id' => $this->getOrder()->fieldShopId,
                'system_name' => $this->getShopOrderStatusCode(),
            );
            if (false === $this->shopOrderStatusCodeObject->LoadFromFields($aFilter)) {
                $shopId = $this->getOrder()->fieldShopId;
                $e = new TPkgShopOrderStatusException_OrderStatusCodeNotFound(
                    "no order status code in shop [{$shopId}] with system_name [{$this->getShopOrderStatusCode()}]",
                    array('orderStatus' => $this)
                );
                $e->setStatusCode($this->getShopOrderStatusCode())
                    ->setShopId($this->getOrder()->fieldShopId);
                throw $e;
            }
        }

        return $this->shopOrderStatusCodeObject;
    }
205615
public function getRefreshToken($refresh_token)
    {
        return isset($this->refreshTokens[$refresh_token]) ? $this->refreshTokens[$refresh_token] : false;
    }
909196
public static function &GetLastCreatedOrder($bResetValue = false)
    {
        $oOrder = null;
        if (array_key_exists(self::SESSION_KEY_LAST_CREATED_ORDER_ID, $_SESSION)) {
            $oOrder = TdbShopOrder::GetNewInstance();
            /** @var $oOrder TdbShopOrder */
            if ($oOrder->Load($_SESSION[self::SESSION_KEY_LAST_CREATED_ORDER_ID])) {
                // now we want to make sure that the current user is the owner of that order. this is
                // the case if: the user is logged in and the user id in the order matches, or the user is
                // not logged in and the order has no user id
                $oUser = TdbDataExtranetUser::GetInstance();
                $isOwner = ($oUser->IsLoggedIn() && $oOrder->fieldDataExtranetUserId == $oUser->id);
                $isOwner = ($isOwner || (!$oUser->IsLoggedIn() && $oOrder->fieldDataExtranetUserId < 1));
                if (!$isOwner) {
                    $oOrder = null;
                }
            } else {
                $oOrder = null;
            }
            if ($bResetValue) {
                unset($_SESSION[self::SESSION_KEY_LAST_CREATED_ORDER_ID]);
            }
        }

        return $oOrder;
    }
1283735
public static function statusUpdate($orderStatusUpdate)
    {
        if (empty($orderStatusUpdate)) {
            throw new OpenPayU_Exception('Empty order status data');
        }

        try {
            $authType = self::getAuth();
        } catch (OpenPayU_Exception $e) {
            throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
        }

        $data = OpenPayU_Util::buildJsonFromArray($orderStatusUpdate);
        $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderStatusUpdate['orderId'] . '/status';

        $result = self::verifyResponse(OpenPayU_Http::doPut($pathUrl, $data, $authType), 'OrderStatusUpdateResponse');

        return $result;
    }
492850
public function getRefreshToken($refresh_token)
    {
        $token = $this->collection('refresh_token_table')->findOne(array(
            'refresh_token' => $refresh_token
        ));
        return is_null($token) ? false : $token;
    }
709934
protected function getShippingAddress(TdbShopOrder $order, $cachingEnabled, IMapperCacheTriggerRestricted $cacheTriggerManager)
    {
        if ($order->fieldAdrShippingUseBilling) {
            return $this->getBillingAddress($order, $cachingEnabled, $cacheTriggerManager);
        }
        $salutation = $order->GetFieldAdrShippingSalutation();
        if ($salutation && $cachingEnabled) {
            $cacheTriggerManager->addTrigger($salutation->table, $salutation->id);
        }
        $address = '';
        $address .= (null !== $salutation) ? $salutation->GetName().' ' : '';
        $address .= $this->getValueOrDefault($order->fieldAdrShippingFirstname, ' ');
        $address .= $this->getValueOrDefault($order->fieldAdrShippingLastname, ', ');
        $address .= $this->getValueOrDefault($order->fieldAdrShippingAdditionalInfo, ', ');
        $address .= $this->getValueOrDefault($order->fieldAdrShippingStreet, ' ');
        $address .= $this->getValueOrDefault($order->fieldAdrShippingStreetnr, ', ');
        $address .= $this->getValueOrDefault($order->fieldAdrShippingPostalcode, ' ');
        $address .= $this->getValueOrDefault($order->fieldAdrShippingCity);

        return $address;
    }
255089
public function refundOrder($orderCode = false, $amount = null)
    {
        if (empty($orderCode) || !is_string($orderCode)) {
            Error::throwError('ip', Error::$errors['refund']['ordercode']);
        }
        OrderService::refundOrder($orderCode, $amount);
    }
210699
public function getAPITicket($refresh = false)
    {
        $key = $this->getTicketCacheKey();

        $ticket = $this->getCache()->fetch($key);

        if (!$ticket || $refresh) {
            $result = $this->parseJSON('get', [self::API_GET_CARD_TICKET, ['type' => 'wx_card']]);

            $this->getCache()->save($key, $result['ticket'], $result['expires_in'] - 500);

            return $result['ticket'];
        }

        return $ticket;
    }
603982
public function getRefundedAmount($orderIndex = 0)
    {
        $paymentAmountInfo = $this->getPaymentAmountInfo($orderIndex);
        return array_key_exists('refundedAmount', $paymentAmountInfo) ? $paymentAmountInfo['refundedAmount'] : null;
    }
612950
public function getTokens($refresh = false)
    {
        if (! $this->_tokens || $refresh) {
            if ($refresh) {
                $this->_firstToken = null;
            }
            $this->_tokens       = array();
            $this->_activeTokens = array();
            $tokenSelect = $this->tracker->getTokenSelect();
            $tokenSelect->andReceptionCodes()
                ->forRespondentTrack($this->_respTrackId);

            $tokenRows = $tokenSelect->fetchAll();
            $prevToken = null;
            foreach ($tokenRows as $tokenData) {

                $token = $this->tracker->getToken($tokenData);

                $this->_tokens[$token->getTokenId()] = $token;

                // While we are busy, set this
                if ($token->hasSuccesCode()) {
                    $this->_activeTokens[$token->getRoundId()] = $token;
                }

                // Link the tokens
                if ($prevToken) {
                    $prevToken->setNextToken($token);
                }
                $prevToken = $token;
            }
        }

        return $this->_tokens;
    }
37708
public function getText($refresh = false)
	{
		if ($refresh) { // We want to query the API
			// Specify relevant page properties to retrieve
			$data = array(
				'titles' => $this->title,
				'prop' => 'info|revisions',
				'rvprop' => 'content', // Need to get page text
				'intoken' => 'edit',
			);

			$r = $this->wikimate->query($data); // Run the query

			// Check for errors
			if (isset($r['error'])) {
				$this->error = $r['error']; // Set the error if there was one
				return null;
			} else {
				$this->error = null; // Reset the error status
			}

			// Get the page (there should only be one)
			$page = array_pop($r['query']['pages']);
			unset($r, $data);

			// Abort if invalid page title
			if (isset($page['invalid'])) {
				$this->invalid = true;
				return null;
			}

			$this->edittoken      = $page['edittoken'];
			$this->starttimestamp = $page['starttimestamp'];

			if (!isset($page['missing'])) {
				// Update the existence if the page is there
				$this->exists = true;
				// Put the content into text
				$this->text   = $page['revisions'][0]['*'];
			}
			unset($page);

			// Now we need to get the section headers, if any
			preg_match_all('/(={1,6}).*?\1 *(?:\n|$)/', $this->text, $matches);

			// Set the intro section (between title and first section)
			$this->sections->byIndex[0]['offset']      = 0;
			$this->sections->byName['intro']['offset'] = 0;

			// Check for section header matches
			if (empty($matches[0])) {
				// Define lengths for page consisting only of intro section
				$this->sections->byIndex[0]['length']      = strlen($this->text);
				$this->sections->byName['intro']['length'] = strlen($this->text);
			} else {
				// Array of section header matches
				$sections = $matches[0];

				// Set up the current section
				$currIndex = 0;
				$currName  = 'intro';

				// Collect offsets and lengths from section header matches
				foreach ($sections as $section) {
					// Get the current offset
					$currOffset = strpos($this->text, $section, $this->sections->byIndex[$currIndex]['offset']);

					// Are we still on the first section?
					if ($currIndex == 0) {
						$this->sections->byIndex[$currIndex]['length'] = $currOffset;
						$this->sections->byIndex[$currIndex]['depth']  = 0;
						$this->sections->byName[$currName]['length']   = $currOffset;
						$this->sections->byName[$currName]['depth']    = 0;
					}

					// Get the current name and index
					$currName = trim(str_replace('=', '', $section));
					$currIndex++;

					// Search for existing name and create unique one
					$cName = $currName;
					for ($seq = 2; array_key_exists($cName, $this->sections->byName); $seq++) {
						$cName = $currName . '_' . $seq;
					}
					if ($seq > 2) {
						$currName = $cName;
					}

					// Set the offset and depth (from the matched ='s) for the current section
					$this->sections->byIndex[$currIndex]['offset'] = $currOffset;
					$this->sections->byIndex[$currIndex]['depth']  = strlen($matches[1][$currIndex-1]);
					$this->sections->byName[$currName]['offset']   = $currOffset;
					$this->sections->byName[$currName]['depth']    = strlen($matches[1][$currIndex-1]);

					// If there is a section after this, set the length of this one
					if (isset($sections[$currIndex])) {
						// Get the offset of the next section
						$nextOffset = strpos($this->text, $sections[$currIndex], $currOffset);
						// Calculate the length of this one
						$length     = $nextOffset - $currOffset;

						// Set the length of this section
						$this->sections->byIndex[$currIndex]['length'] = $length;
						$this->sections->byName[$currName]['length']   = $length;
					}
					else {
						// Set the length of last section
						$this->sections->byIndex[$currIndex]['length'] = strlen($this->text) - $currOffset;
						$this->sections->byName[$currName]['length']   = strlen($this->text) - $currOffset;
					}
				}
			}
		}

		return $this->text; // Return the text in any case
	}
843692
public function getIPNURL(TdbCmsPortal $portal, TdbShopOrder $order)
    {
        $identifier = $this->getIPNIdentifierFromOrder($order);
        if (null === $identifier) {
            throw new TPkgShopPaymentIPNException_OrderHasNoPaymentGroup($order->id, 'failed to generate an IPN URL because the payment handler of the order is not assigned to any payment handler group');
        }

        $language = null;
        if (property_exists($order, 'fieldCmsLanguageId')) {
            $language = $this->getLanguageService()->getLanguage($order->fieldCmsLanguageId);
        }
        $url = $this->getPageService()->getLinkToPortalHomePageAbsolute(array(), $portal, $language, true);

        $url .= '/'.self::URL_IPN_IDENTIFIER.$identifier.'__'.$order->sqlData['cmsident'];

        return $url;
    }
539075
public function status($transactionReference)
	{
		$request = Request::createFromClient($this, FALSE);

		$request->setTransactionType(Request::TRANSACTION_TYPE_STATUS)
		        ->setTransactionReference($transactionReference);

		return $request;
	}
871548
public static function initServices($refresh = false)
    {
        // Define full definition file path
        $path = sprintf('%s%sxac-services-v%d.conf'
            , ! empty(self::$logPath) ? self::$logPath : sys_get_temp_dir()
            , DIRECTORY_SEPARATOR
            , self::$apiVersion
            );
        
        if ($refresh === true || ! file_exists($path)) {
            self::log(sprintf("Refresh services definition on-demand for v%d API", self::$apiVersion));
            $res = self::getInstance()->call('endpoints');
            $res['_timestamp'] = time();
            file_put_contents($path, serialize($res));
            chmod($path, 0777);
            self::$services = $res;
        } else {
            self::$services = unserialize(file_get_contents($path));
            // Check that content is not expired
            if (time() - self::$services['_timestamp'] > self::$ttl) {
                self::log(sprintf("Refresh outdated services definition for v%d API", self::$apiVersion));
                self::initServices(true);
            }
        }
    }
622870
public function postSelectPaymentHook(TdbShop $oShop, TShopBasket $oBasket, TdbDataExtranetUser $oUser, $sMessageConsumer)
    {
        return $this->GetFieldShopPaymentHandler()->PostSelectPaymentHook($sMessageConsumer);
    }
1312731
public function &GetValidPaymentMethods($bRefresh = false)
    {
        if (is_null($this->oValidPaymentMethods) || $bRefresh) {
            $this->oValidPaymentMethods = &TdbShopPaymentMethodList::GetAvailableMethods($this->id);
            $this->oValidPaymentMethods->bAllowItemCache = true;
        }
        if (!is_null($this->oValidPaymentMethods)) {
            $this->oValidPaymentMethods->GoToStart();
        }

        return $this->oValidPaymentMethods;
    }
1197524
public function getToken($refresh = false)
    {
        if ($this->token === null || $refresh)
        {
            $salt = $this->_createSalt(12);
            $name = session_name();

            $this->token = sha1($salt.$name);
        }

        return $this->token;
    }