Get the status from the last payment.

@param array $response

@return string
183668
protected function getPaymentStatus($response)
    {
        $lastPayment = Arr::last($response['payments']);

        // approved, in_process, pending, rejected, cancelled
        // on testing at least, payments may be empty
        return $lastPayment ? Arr::get($lastPayment, 'status', 'other') : 'no_payment';
    }
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;
    }
360581
protected function getResponseTransfer(array $response): ComputopApiInquireResponseTransfer
    {
        $computopApiResponseTransfer = new ComputopApiInquireResponseTransfer();
        $computopApiResponseTransfer->fromArray($response, true);
        $computopApiResponseTransfer->setHeader(
            $this->computopApiService->extractResponseHeader($response, $this->config->getInquireMethodName())
        );
        $computopApiResponseTransfer->setAmountAuth($this->computopApiService->getResponseValue($response, ComputopApiConfig::AMOUNT_AUTH));
        $computopApiResponseTransfer->setAmountCap($this->computopApiService->getResponseValue($response, ComputopApiConfig::AMOUNT_CAP));
        $computopApiResponseTransfer->setAmountCred($this->computopApiService->getResponseValue($response, ComputopApiConfig::AMOUNT_CRED));
        $computopApiResponseTransfer->setLastStatus($this->computopApiService->getResponseValue($response, ComputopApiConfig::LAST_STATUS));
        //set custom options
        $computopApiResponseTransfer->setIsAuthLast($this->isAuthLast($computopApiResponseTransfer));
        $computopApiResponseTransfer->setIsCapLast($this->isCapLast($computopApiResponseTransfer));
        $computopApiResponseTransfer->setIsCredLast($this->isCredLast($computopApiResponseTransfer));

        return $computopApiResponseTransfer;
    }
214299
protected function getType($response)
    {
        if (!$response) {
            return;
        }

        if (array_key_exists('intent', $response)) {
            // 'sale' for payment request / execute
            return $response['intent'];
        }

        if (array_key_exists('url', $response) && array_key_exists('event_types', $response)) {
            return 'webhook';
        }
    }
1091223
public function after($response)
	{
		// Make sure the $response is a Response object
		if ( ! $response instanceof Response)
		{
			$response = \Response::forge($response, $this->response_status);
		}

		return $response;
	}
67666
public function parseResponse($response)
    {
        // Parse the response and set the last response and headers.
        $info = curl_getinfo($this->ch);
        $this->__last_response_headers = substr(
            $response,
            0,
            $info['header_size']
        );
        $this->__last_response = substr($response, $info['header_size']);
    }
204151
protected function getOrderPaymentStatusFinal()
    {
        $status = null;
        if ($this->isOrderPaymentStatusFinal()) {
            $status = $this->getOrder()->getPaymentStatus();
        }

        return $status;
    }
71163
public function getTransactionStatus(): string
    {
        // If the user cancelled in the terminal window, then we need to detect that.
        if ($this->hasError()) {
            $error = $this->getError();
            if (
                !empty($error['operation']) && $error['operation'] === 'Terminal' &&
                !empty($error['responseCode']) && $error['responseCode'] === '17' &&
                !empty($error['responseSource']) && ($error['responseSource'] === 'Terminal' || $error['responseSource'] === '05') &&
                !empty($error['responseText']) && $error['responseText'] === 'Cancelled by customer.'
            ) {
                return QueryInterface::STATUS_CANCELLED;
            }

            return QueryInterface::STATUS_FAILED;
        }

        $summary = $this->getSummary();

        // If the cancelled flag is set, then it can no longer be considered to be authed, captured or credited.
        if ($summary['cancelled']) {
            return QueryInterface::STATUS_CANCELLED;
        }

        // If there's an amount present in the amountCredited field, it's because it's not a request for payment.
        if ($summary['amountCredited']) {
            return QueryInterface::STATUS_CREDITED;
        }

        // If it's not cancelled, not credited, but is authed and not captured, then it must just be authed.
        if ($summary['authorized'] && !$summary['amountCaptured']) {
            return QueryInterface::STATUS_AUTHORIZED;
        }

        // If it's not cancelled, not credited, not authed, and not captured, then it's either pending, (Netaxept's
        // 'registered' state) or rejected.
        if (!$summary['authorized'] && !$summary['amountCaptured']) {
            return QueryInterface::STATUS_PENDING;
        }

        // The only other option is that it's been captured.
        return QueryInterface::STATUS_CAPTURED;
    }
790425
protected function getPaymentStatus($response)
    {
        switch ($status = Arr::get($response, 'payment_status', 'paid')) {
            case 'Completed':
            case 'Processed':
                return new Status('paid');
            case 'Created':
            case 'Pending':
                return new Status('pending');
            case 'Canceled_Reversal':
                return new Status('canceled');
            case 'Failed':
            case 'Denied':
                return new Status('failed');
            case 'Declined':
                return new Status('declined');
            case 'Expired':
                return new Status('expired');
            case 'Refunded':
                return new Status('refunded');
            case 'Reversed':
                return new Status('charged_back');
            case 'Voided':
                return new Status('voided');
        }
    }
576450
protected function getStatusByAction($action)
    {
        $status = null;
        switch ($action) {
            case 'void':
                $status = $this->getSuggestStatusOnVoid();
                break;
            case 'refund_partial':
            case 'reauthorize':
                $status = $this->getOrder()->getPaymentStatus();
                break;
            case 'refund':
            case 'capture':
            case 'capture_partial':
                $status = 'completed';
                break;
            default:
                $status = 'completed';
        }

        return $status;
    }
715178
public function parse_meta_response( $response ) {
		if ( $this->validate_response( $response ) ) {
			return $response;
		}
		$arr      = [];
		$response = [ $response ];

		array_filter(
			$response,
			function ( $e ) use ( &$arr ) {
				$arr['private']      = $e->private;
				$arr['last_updated'] = $e->pushed_at;
				$arr['watchers']     = $e->watchers;
				$arr['forks']        = $e->forks;
				$arr['open_issues']  = $e->open_issues;
			}
		);

		return $arr;
	}
297012
protected function getOrderPaymentStatusPaymentValid()
    {
        $status = null;
        $orderPayment = $this->getOrderPayment();
        if (isset($orderPayment) && !$orderPayment->getIsValid()) {
            $status = 'failed';
        }

        return $status;
    }
766793
protected function getPaymentDateOrder()
    {
        // Take date of last payment as payment date.
        $paymentDate = null;
        foreach ($this->source->getStatusHistoryCollection() as $statusChange) {
            /** @var \Mage_Sales_Model_Order_Status_History $statusChange */
            if (!$paymentDate || $this->isPaidStatus($statusChange->getStatus())) {
                $createdAt = substr($statusChange->getCreatedAt(), 0, strlen('yyyy-mm-dd'));
                if (!$paymentDate || $createdAt < $paymentDate) {
                    $paymentDate = $createdAt;
                }
            }
        }
        return $paymentDate;
    }
534094
private function _createSubscription(array $response)
    {
        $model = new Subscription();
        $model->setId($response['id']);
        $model->setOffer($this->_convertResponseToModel($response['offer'], 'offer'));
        $model->setLivemode($response['livemode']);
        $model->setTrialStart($response['trial_start']);
        $model->setTrialEnd($response['trial_end']);
        $model->setPeriodOfValidity($response['period_of_validity']);
        $model->setEndOfPeriod($response['end_of_period']);
        $model->setNextCaptureAt($response['next_capture_at']);
        $model->setCreatedAt($response['created_at']);
        $model->setUpdatedAt($response['updated_at']);
        $model->setCanceledAt($response['canceled_at']);
        $model->setPayment($this->_convertResponseToModel($response['payment'], "payment"));
        $model->setClient($this->_convertResponseToModel($response['client'], "client"));
        $model->setAppId($response['app_id']);
        $model->setIsCanceled($response['is_canceled']);
        $model->setIsDeleted($response['is_deleted']);
        $model->setStatus($response['status']);
        $model->setAmount($response['amount']);
        $model->setTempAmount($response['temp_amount']);
        return $model;
    }
391687
public function parse_meta_response( $response ) {
		if ( $this->validate_response( $response ) ) {
			return $response;
		}
		$arr      = [];
		$response = [ $response ];

		array_filter(
			$response,
			function ( $e ) use ( &$arr ) {
				$arr['private']      = ! $e->public;
				$arr['last_updated'] = null;
				$arr['watchers']     = 0;
				$arr['forks']        = 0;
				$arr['open_issues']  = 0;
			}
		);

		return $arr;
	}
1039264
public function parseData(array $response)
    {
        $key = str_replace('.', '_', $this->getMethod()) . '_response';
        return array_key_exists($key, $response) ? $response[$key] : null;
    }
116187
private function resolveResponseArray(array $response)
    {
        if ($count = count($response)) {
            if ($count === 1) {
                $response = $response[0];
            }
        }
        $this->firing[] = $response;

        return $response;
    }