Check if the payment call to IPayment was succesfully done
by parameter ret_status and hash check.

deprecated

@param string $response if empty function get parameter from post

@return bool $bPaymentOk
14455
protected function IsSuccessResponse($response = '')
    {
        $bPaymentOk = false;
        $oGlobal = TGlobal::instance();
        if (empty($response)) {
            $aResult = $this->GetNeedeResponsePostParameterForSecurityCheck();
            $aResult['ret_status'] = $oGlobal->GetUserData('ret_status');
        } else {
            $aResult = $this->GetResultFormResponse($response);
        }

        if (count($aResult) > 0 && array_key_exists('ret_status', $aResult) && 'SUCCESS' == $aResult['ret_status']) {
            $bPaymentOk = true;
        }
        if ($bPaymentOk) {
            $bPaymentOk = $this->IsSecurityCheckOk($aResult['trxuser_id'], $aResult['trx_amount'], $aResult['trx_currency'], $aResult['ret_authcode'], $aResult['ret_trx_number'], $aResult['ret_param_checksum']);
        }

        return $bPaymentOk;
    }
955048
public function processResponse($response)
    {
        // SOAP, JSON, HTTP POST
        $storeId = null;

        $this->_debugData['processResponse begin'] = 'Begin to process Notification';

        if (empty($response)) {
            $this->_debugData['error'] = 'Response is empty, please check your webserver that the result url accepts parameters';
            $this->_debug($storeId);
            return array('response' => '401');
        }

        // Log the results in log file and adyen_debug table
        $this->_debugData['response'] = $response;
        Mage::getResourceModel('adyen/adyen_debug')->assignData($response);

//      $params = new Varien_Object($response);
        // Create Varien_Object from response (soap compatible)
        $params = new Varien_Object();
        foreach ($response as $code => $value) {
            $params->setData($code, $value);
        }

        $actionName = $this->_getRequest()->getActionName();

        // authenticate result url
        $authStatus = Mage::getModel('adyen/authenticate')->authenticate($actionName, $params);
        if (!$authStatus['authentication']) {
            $this->_debugData['error'] = 'Autentication failure please check your notification username and password. This must be the same in Magento as in the Adyen platform';
            $this->_debug($storeId);
            return array('response' => '401', 'message' => $authStatus['message']);
        }

        // skip notification if notification is REPORT_AVAILABLE
        $eventCode = trim($params->getData('eventCode'));
        if ($eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_REPORT_AVAILABLE) {
            $this->_debugData['processResponse info'] = 'Skip notification REPORT_AVAILABLE';
            $this->_debug($storeId);
            return;
        }

        $this->_declareCommonVariables($params);
        $isInvalidKcp = $this->_isInvalidKcp($this->_paymentMethod, $this->_value);
        if ($isInvalidKcp) {
            $this->_debugData['processResponse info'] = 'Skip notification for KCP and 0 amount';
            $this->_debug($storeId);
            return;
        }

        // check if notification is not duplicate
        if (!$this->_isDuplicate($params)) {
            $incrementId = $params->getData('merchantReference');

            if ($incrementId) {
                $this->_debugData['info'] = 'Add this notification with Order increment_id to queue: ' . $incrementId;
                $this->_addNotificationToQueue($params);
            } else {
                $this->_debugData['error'] = 'Empty merchantReference';
            }
        } else {
            $this->_debugData['processResponse info'] = 'Skipping duplicate notification';
        }

        $this->_debug($storeId);
    }
13852
public static function parseResponse(Response $response)
    {
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
        if (
            (isset($jsonData['errCode']) && 0 === $jsonData['errCode'])
            || (isset($jsonData['retcode']) && 0 === $jsonData['retcode'])
        ) {
            return true;
        }
        if (isset($jsonData['retcode']) && 103 === $jsonData['retcode']) {
            throw new Code103ResponseException($response);
        }

        return false;
    }
634183
protected function validateResponse($response)
    {
        if ('Failure' == $response['ACK']) {
            /**
             * @var \OxidEsales\PayPalModule\Core\Exception\PayPalResponseException $exception
             */
            $exception = oxNew(\OxidEsales\PayPalModule\Core\Exception\PayPalResponseException::class, $response['L_LONGMESSAGE0'], $response['L_ERRORCODE0']);
            throw $exception;
        }
    }
946984
public static function decodeHttpResponse($response) {
    $code = $response->getResponseHttpCode();
    $body = $response->getResponseBody();
    $decoded = null;
    
    if ((intVal($code)) >= 300) {
      $decoded = json_decode($body, true);
      $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
      if ($decoded != null && isset($decoded['error']['message'])  && isset($decoded['error']['code'])) {
        // if we're getting a json encoded error definition, use that instead of the raw response
        // body for improved readability
        $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
      } else {
        $err .= ": ($code) $body";
      }

      throw new ServiceException($err, $code, null, $decoded['error']['errors']);
    }
    
    // Only attempt to decode the response, if the response code wasn't (204) 'no content'
    if ($code != '204') {
      $decoded = json_decode($body, true);
      if ($decoded === null || $decoded === "") {
        throw new ServiceException("Invalid json in service response: $body");
      }
    }
    return $decoded;
  }
1005691
protected function validate_response($response) {

        $response = $this->decode_response($response);

        if (empty($response)) {
            throw new checker_exception('err_response_empty');
        }

        if (empty($response['status']) or $response['status'] !== 'OK') {
            throw new checker_exception('err_response_status', $response['status']);
        }

        if (empty($response['apiver']) or $response['apiver'] !== '1.3') {
            throw new checker_exception('err_response_format_version', $response['apiver']);
        }

        if (empty($response['forbranch']) or $response['forbranch'] !== moodle_major_version(true)) {
            throw new checker_exception('err_response_target_version', $response['forbranch']);
        }
    }
877236
protected function GetResultFormResponse($response)
    {
        $aNeededResponseParameterToCheck = array('ret_status' => '', 'ret_errormsg' => '', 'trxuser_id' => '', 'trx_amount' => '', 'trx_currency' => '', 'ret_authcode' => '', 'ret_trx_number' => '', 'ret_param_checksum' => '');
        preg_match('/<a href=".*'.self::URL_PARAMETER_NAME.'\\/(success|error)\?(.*)">/', $response, $aMatch);
        if (count($aMatch) > 2) {
            $aResponseParts = explode('&', $aMatch[2]);
            foreach ($aResponseParts as $sRepsponsePart) {
                $aResponseKeyValue = explode('=', $sRepsponsePart);
                if (2 == count($aResponseKeyValue) && array_key_exists($aResponseKeyValue[0], $aNeededResponseParameterToCheck)) {
                    $aNeededResponseParameterToCheck[$aResponseKeyValue[0]] = $aResponseKeyValue[1];
                }
            }
        }

        return $aNeededResponseParameterToCheck;
    }
187222
protected function respond($response)
    {
        $success = Arr::get($response, 'success');

        return $this->mapResponse($success, $response);
    }
1230521
private function formatResponse($response)
    {
        $this->last_response = $response;

        if (!empty($response['body'])) {
            return json_decode($response['body'], true);
        }

        return false;
    }
297194
protected function getStatus(array $response)
    {
        $payments = Arr::get($response, 'payments');

        if (empty($payments)) {
            return new Status('pending');
        }

        $newResponse = $response;

        if (count($payments) > 1) {
            $totalPaid = 0;
            $totalRefund = 0;
            $total = $newResponse['shipping_cost'] + $newResponse['total_amount'];

            foreach ($payments as $payment) {
                if ($payment['status'] === 'approved') {
                    // Get the total paid amount, considering only approved incomings.
                    $totalPaid += $payment['total_paid_amount'] - $payment['amount_refunded'];
                } elseif ($payment['status'] === 'refunded') {
                    // Get the total refunded amount.
                    $totalRefund += $payment['amount_refunded'];
                }
            }

            if ($totalPaid >= $total) {
                $newResponse['status'] = 'approved';
            } elseif ($totalRefund >= $total) {
                $newResponse['status'] = 'refunded';
            } elseif ($totalRefund > 0) {
                $newResponse['status'] = 'partially_refunded';
            } else {
                $newResponse['status'] = 'pending';
            }

            return parent::getStatus($newResponse);
        }

        $newResponse['status'] = $payments[0]['amount_refunded'] > 0 ? 'partially_refunded' : $payments[0]['status'];

        return parent::getStatus($newResponse);
    }
637462
protected function getAuthorization($response)
    {
        $object = Arr::get($response, 'object');

        if ($object == 'customer') {
            return Arr::get($response, 'default_payment_source_id');
        } elseif ($object == 'payment_source') {
            return Arr::get($response, 'parent_id');
        } elseif ($object == 'payee') {
            return Arr::get($response, 'id');
        } elseif ($object == 'transfer') {
            return Arr::get($response, 'id');
        } elseif ($object == 'event') {
            return Arr::get($response, 'id');
        }

        if (isset($response['charges'])) {
            $charges = $response['charges']['data'];
            $charge = Arr::last($charges);
            $paymentMethod = $charge['payment_method'];

            if (isset($paymentMethod['auth_code'])) {
                return $paymentMethod['auth_code'];
            } elseif (isset($paymentMethod['reference'])) {
                return $paymentMethod['reference'];
            } elseif (isset($paymentMethod['clabe'])) {
                return $paymentMethod['clabe'];
            }
        }
    }
285238
public function isBearer($response)
	{	
     	if (!isset($response->token_type)) {
    		return false;
    	}

    	if ($response->token_type == 'bearer') {
    		return $response->access_token;
    	}
	}
459761
public function verifyResponse($response, $clientIp)
    {
        if (empty($response)) {
            return false;
        }

        $response = $this->sendVerifyRequest([
            'secret' => $this->secretKey,
            'remoteip' => $clientIp,
            'response' => $response
        ]);

        return isset($response['success']) && $response['success'] === true;
    }
502320
private function performResponse($response)
    {
        $data = false;
        if ($response instanceof ResponseInterface) {
            $data = json_decode($response->getBody()->getContents());
            $this->getValidationResponse()->validateResponseData($data);
        }

        return $data;
    }
478198
protected function respond($response)
    {
        if ($response === null) {
            return $this->mapResponse(true, []);
        }

        if (!empty($response) && !isset($response[0])) {
            $success = null === Arr::get($response, 'error_code');

            return $this->mapResponse($success, $response);
        }

        $responses = [];

        foreach ($response as $responseItem) {
            $success = null === Arr::get($responseItem, 'error_code');

            $responses[] = $this->mapResponse($success, $responseItem);
        }

        return $responses;
    }
431574
protected function isSuccess($response, $code)
    {
        if ($code !== 200 && $code !== 201) {
            return false;
        }

        if (isset($response['error'])) {
            return false;
        }

        if (!empty(Arr::get($response, 'payments'))) {
            return in_array($this->getPaymentStatus($response), $this->successPaymentStatuses);
        }

        return true;
    }
1248642
public function getUserFromTokenResponse($response)
    {
        $user = $this->mapUserToObject($this->getUserByToken(
            $token = $this->parseAccessToken($response)
        ));

        $this->credentialsResponseBody = $response;

        if ($user instanceof User) {
            $user->setAccessTokenResponseBody($this->credentialsResponseBody);
        }

        return $user->setToken($token)
            ->setRefreshToken($this->parseRefreshToken($response))
            ->setExpiresIn($this->parseExpiresIn($response));
    }