It is used for Capture Reverse Transaction
@param string $hostlogkey
@param string $authcode
@return bool
330238
function DoCaptReverseTran($hostlogkey,
                               $authcode) {

        $posnetRequest = new PosnetRequest();

        $posnetRequest->hostlogkey = $hostlogkey;
        $posnetRequest->authcode = $authcode;

        return $this->DoTran($posnetRequest, "captrev");
    }
1133033
public function requestAccessToken($authorizationCode)
    {
        $parameters = [
            'client_id' => $this->getClientId(),
            'client_secret' => $this->getClientSecret(),
            'code' => $authorizationCode,
            'grant_type' => 'authorization_code',
            'redirect_uri' => $this->getRedirectUri(),
        ];

        $response = $this->request->account('POST', '/api/token', $parameters, []);
        $response = $response['body'];

        if (isset($response->refresh_token) && isset($response->access_token)) {
            $this->refreshToken = $response->refresh_token;
            $this->accessToken = $response->access_token;
            $this->expirationTime = time() + $response->expires_in;
            $this->scope = isset($response->scope) ? $response->scope : $this->scope;

            return true;
        }

        return false;
    }
608581
protected function checkSessionDatabase($authCookie)
    {
        $userIp = $this->cookieOptions['remoteaddr'] ? $this->getClientIp() : null;
        $userAgent = $this->cookieOptions['browseragent'] ? $this->getClientUserAgent() : null;

        try {
            if (!$authTokenEntity = $this->getRepositoryAuthtoken()->getToken($authCookie, $userIp, $userAgent)) {
                return false;
            }

            if (!$databaseUser = $this->getRepositoryUsers()->getUser($authTokenEntity->getUserId())) {
                return false;
            }
        } catch (TableNotFoundException $e) {
            return false;
        }

        // Update session data
        $sessionAuth = new Token\Token($databaseUser, $authTokenEntity);
        $this->session->set('authentication', $sessionAuth);

        // Check if user is _still_ allowed to log on.
        if (!$this->permissions->isAllowed('login', $sessionAuth->getUser()->toArray(), null) || !$sessionAuth->isEnabled()) {
            $this->systemLogger->error('User ' . $sessionAuth->getUser()->getUsername() . ' has been disabled and can not login.', ['event' => 'authentication']);

            return false;
        }

        return $this->checkSessionKeys($sessionAuth);
    }
421509
protected function generateLocationAuth(string $authTicket, float $latitude, float $longitude, float $altitude = 0.0)
    {
        $seed = hexdec(xxhash32($authTicket, 0x1B845238));
        return (int)hexdec(xxhash32($this->getLocationBytes($latitude, $longitude, $altitude), (int)$seed));
    }
1247517
public function queryAuth($authCode)
    {
        return $this->auth(function () use ($authCode) {
            return $this->callHttp([
                'url' => 'api_query_auth?component_access_token=' . $this->accessToken,
                'data' => [
                    'component_appid' => $this->getAppId(),
                    'authorization_code' => $authCode,
                ],
            ]);
        });
    }
623645
public function clearLog($logKey = null)
    {
        $ret=true;
        if ($logKey==null) {
            foreach ($this->_logFiles as $key => $logFile) {
                $ret = $ret && $this->write("", $logFile);
            }
            return $ret;
        } else {
            $arrayKey=strtolower($logKey);
            if (isset($this->_logFiles[$arrayKey])) {
                return $this->write("", $this->_logFiles[$arrayKey]);
            } else {
                return 0;
            }
        }
    }
444142
public function authenticate($authorizationCode)
    {
        $tokens = $this->client->requestTokens(
            $authorizationCode,
            $this->clientId,
            $this->clientSecret,
            $this->redirectUrl
        );

        $this->accessToken = $tokens->access_token;
        $this->refreshToken = $tokens->refresh_token;
        $this->expires = $tokens->expires_at;

        $this->client->authenticate($this->accessToken);
    }
1248138
public function user($authCode = null)
    {
        if ($this->hasInvalidState()) {
            throw new InvalidStateException();
        }

        $params = [
            'auth_code' => $authCode ?: $this->request->get('auth_code'),
        ];

        return $this->parseJSON('json', [self::API_GET_LOGIN_INFO, $params]);
    }
1283116
public function handleAuthorize(string $authCode = null)
    {
        $params = [
            'component_appid' => $this->app['config']['app_id'],
            'authorization_code' => $authCode ?? $this->app['request']->get('auth_code'),
        ];

        return $this->httpPostJson('cgi-bin/component/api_query_auth', $params);
    }
625411
public function canDisplay(Exception $original, Exception $transformed, int $code)
    {
        return $transformed instanceof TooManyRequestsHttpException && $this->request->is('auth*');
    }
1008635
public function getDetailsTransaction($transactionCode)
    {
        $this->_detailsTransactionByCode = $this->getTransactionsByCode($transactionCode);

        if(!empty($this->_detailsTransactionByCode)){
            $order = $this->decryptOrderById($this->_detailsTransactionByCode);

            if ($this->getStoreReference() == $this->decryptReference($this->_detailsTransactionByCode)) {
                if ($this->_detailsTransactionByCode->getStatus() == $this->getKeyFromOrderStatus($order->getStatus())) {
                    $this->_detailsTransactionByCode = $this->buildDetailsTransaction();
                    $this->_needConciliate = false;
                }
            }
        }
    }
563926
private function onAuthenticateHandler($authMethod, $authMethodInfo, Realm $realm, Session $session, AuthenticateMessage $msg)
    {

        $onAuthenticateSuccess = function ($res) use ($realm, $session) {

            if (count($res) < 1) {
                $session->abort(new \stdClass(), 'thruway.error.authentication_failure');

                return;
            }

            // we should figure out a way to have the router send the welcome
            // message so that the roles and extras that go along with it can be
            // filled in
            if ($res[0] === 'SUCCESS') {
                $this->sendWelcomeMessage($session, $res[1]);
            } elseif (isset($res[0]) && $res[0] === 'FAILURE') {
                $this->abortSessionUsingResponse($session, $res);
            } else {
                $session->abort(new \stdClass(), 'thruway.error.authentication_failure');
            }
        };

        $onAuthenticateError = function () use ($session) {
            Logger::error($this, 'onauthenticate rejected the promise');
            $session->abort(new \stdClass(), 'thruway.error.unknown');
        };

        $extra                    = new \stdClass();
        $extra->challenge_details = $session->getAuthenticationDetails()->getChallengeDetails();

        $arguments                = new \stdClass();
        $arguments->extra         = $extra;
        $arguments->authid        = $session->getAuthenticationDetails()->getAuthId();
        $arguments->challenge     = $session->getAuthenticationDetails()->getChallenge();
        $arguments->signature     = $msg->getSignature();
        $arguments->authmethod    = $authMethod;
        $arguments->hello_message = $session->getHelloMessage();

        // now we send our authenticate information to the RPC
        $onAuthenticateHandler = $authMethodInfo['handlers']->onauthenticate;

        $this->session->call($onAuthenticateHandler, [$arguments])
            ->then($onAuthenticateSuccess, $onAuthenticateError);

    }
814465
function DoCaptTran($hostlogkey,
                        $authcode,
                        $amount,
                        $currency,
                        $instnumber,
                        $multpoint = "00",
                        $extpoint = "000000") {

        $posnetRequest = new PosnetRequest();

        $posnetRequest->hostlogkey = $hostlogkey;
        $posnetRequest->authcode = $authcode;
        $posnetRequest->amount = $amount;
        $posnetRequest->currency = $currency;
        $posnetRequest->instnumber = $instnumber;
        $posnetRequest->multiplepoint = $multpoint;
        $posnetRequest->extrapoint = $extpoint;

        return $this->DoTran($posnetRequest, "capt");
    }
234088
public function apply($code)
    {
        if (!auth()->check()) {
            throw new UnauthenticatedException;
        }

        try {
            if ($promocode = $this->check($code)) {
                if ($this->isSecondUsageAttempt($promocode)) {
                    throw new AlreadyUsedException;
                }

                $promocode->users()->attach(auth()->id(), [
                    'promocode_id' => $promocode->id,
                    'used_at' => Carbon::now(),
                ]);

                return $promocode->load('users');
            }
        } catch (InvalidPromocodeException $exception) {
            //
        }

        return false;
    }
990336
public function cancelTransaction($transactionCode)
    {
        return $this->sendTransaction([
            'email'           => $this->email,
            'token'           => $this->token,
            'transactionCode' => $transactionCode,
        ], $this->url['cancelTransaction']);
    }
1113386
public function getAuthorization(string $authCorpId, string $permanentCode)
    {
        $params = [
            'auth_corpid' => $authCorpId,
            'permanent_code' => $permanentCode,
        ];

        return $this->httpPostJson('cgi-bin/service/get_auth_info', $params);
    }
1240459
public function cancelAuthorizedOrder($orderCode = false)
    {
        if (empty($orderCode) || !is_string($orderCode)) {
            Error::throwError('ip', Error::$errors['capture']['ordercode']);
        }
        OrderService::cancelAuthorizedOrder($orderCode);
    }