@param $transactionId
@param $responseCode
@param $responseText
@param $item

@throws \HpsProcessorException
@throws null
327400
public static function checkResponse($transactionId, $responseCode, $responseText, $item)
    {
        $e = self::getException($transactionId, $responseCode, $responseText, $item);

        if ($e != null) {
            throw $e;
        }
    }
199746
public function addItem(
        $itemData,
        $locale,
        $userId,
        OrderEntity $order,
        ItemInterface $lastProcessedProductItem = null
    ) {
        $item = $this->itemManager->save(
            $itemData,
            $locale,
            $userId,
            null,
            null,
            $order->getCustomerContact(),
            $lastProcessedProductItem
        );

        $order->addItem($item->getEntity());

        return $item;
    }
83071
public static function getException($responseCode, $responseText, $response)
    {
        $e = null;

        switch ($responseCode) {
            case '0':
                break;
            case '-2':
                $e = new HpsAuthenticationException(
                    HpsExceptionCodes::AUTHENTICATION_ERROR,
                    'Authentication Error. Please double check your service configuration'
                );
                break;
            case '3':
                $e = new HpsGatewayException(
                    HpsExceptionCodes::INVALID_ORIGINAL_TRANSACTION,
                    $responseText,
                    $responseCode,
                    $responseText
                );
                break;
            case '5':
                $e = new HpsGatewayException(
                    HpsExceptionCodes::NO_OPEN_BATCH,
                    $responseText,
                    $responseCode,
                    $responseText
                );
                break;
            case '12':
                $e = new HpsGatewayException(
                    HpsExceptionCodes::INVALID_CPC_DATA,
                    'Invalid CPC data',
                    $responseCode,
                    $responseText
                );
                break;
            case '27':
            case '34':
            case '26':
            case '13':
                $e = new HpsGatewayException(
                    HpsExceptionCodes::INVALID_CARD_DATA,
                    'Invalid card data',
                    $responseCode,
                    $responseText
                );
                break;
            case '14':
                $e = new HpsGatewayException(
                    HpsExceptionCodes::INVALID_NUMBER,
                    'The card number is not valid',
                    $responseCode,
                    $responseText
                );
                break;
            case '30':
                $e = new HpsGatewayException(
                    HpsExceptionCodes::GATEWAY_ERROR,
                    'Gateway timed out',
                    $responseCode,
                    $responseText
                );
                break;
            case '1':
            default:
                $e = new HpsGatewayException(
                    HpsExceptionCodes::UNKNOWN_GATEWAY_ERROR,
                    $responseText,
                    $responseCode,
                    $responseText
                );
        }

        return $e;
    }
775593
public static function fromDict($rsp, $txnType, $returnType = 'HpsGiftCardSale')
    {
        $item = $rsp->Transaction;

        $sale = parent::fromDict($rsp, $txnType, $returnType);
        $sale->splitTenderCardAmount = (isset($item->SplitTenderCardAmt) ? (string)$item->SplitTenderCardAmt : null);
        $sale->splitTenderBalanceDue = (isset($item->SplitTenderBalanceDueAmt) ? (string)$item->SplitTenderBalanceDueAmt : null);

        return $sale;
    }
569007
public function loadByTransactionId($transactionId)
    {
        $db = $this->getDb();
        $data = $db->getRow('SELECT * FROM `oepaypal_orderpayments` WHERE `oepaypal_transactionid` = ' . $db->quote($transactionId));

        return $data;
    }
453664
public function execute(TransactionData $transactionData, $argument = null)
    {
        $this->requestsStorage->addRequest($transactionData->getRequest());
    }
647034
private function processResponse($response, $item, $websiteId)
    {
        if (isset($response->message)) {
            $item->setImportStatus(self::FAILED)
                ->setMessage($response->message);
        } else {
            if ($response->status == 'Finished') {
                $item = $this->processFinishedItem($item, $websiteId);
            } elseif (in_array($response->status, $this->importStatuses)) {
                $item->setImportStatus(self::FAILED)
                    ->setMessage('Import failed with status ' . $response->status);
            } else {
                //Not finished
                $this->totalItems += 1;
            }
        }
        //Save item
        $this->saveItem($item);
    }
142573
public function execute(TransactionData $transactionData, $argument = null)
    {
        $this->logger->debug('Adding expectation');
        $transactionData->setResponse(
            $this->processAndGetResponse(
                $transactionData,
                function (TransactionData $transaction, Expectation $expectation) {
                    $this->validateExpectationOrThrowException($expectation, $this->logger);
                    $this->storage->addExpectation($expectation);

                    return $this->constructResponse([], $transaction->getResponse());
                }
            )
        );
    }
1039883
void commitTransaction(HotRodHeader header, Subject subject, XidImpl xid) {
      CommitTransactionOperation operation = new CommitTransactionOperation(header, server, subject, xid,
            this::writeTransactionResponse);
      executor.execute(operation);
   }
980582
function createTransactionResponse(response, body) {
  const transactionRes = {
    statusCode: response.statusCode,
    headers: Object.assign({}, response.headers),
  };
  if (Buffer.byteLength(body || '')) {
    transactionRes.bodyEncoding = detectBodyEncoding(body);
    transactionRes.body = body.toString(transactionRes.bodyEncoding);
  }
  return transactionRes;
}
823635
public function flush(DoplioDbTable $item)
    {
        try {
            $this->table->getConnection()->transaction(
                function () use ($item) {
                    $this->flushItem($item);
                }
            );
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage());
        }
    }
499026
public function execute(TransactionData $transactionData, $argument = null)
    {
        $list = json_encode($this->storage->listExpectations());

        $transactionData->setResponse(
            $transactionData->getResponse()
            ->withBody(new StringStream($list))
            ->withHeader('Content-type', 'application/json')
        );
    }
1277311
public static function fromDict($rsp, $txnType, $returnType = 'HpsReportTransactionDetails')
    {
        $reportResponse = $rsp->Transaction->$txnType;

        $details = parent::fromDict($rsp, $txnType, $returnType);
        $details->originalTransactionId = (isset($reportResponse->OriginalGatewayTxnId) ? (string)$reportResponse->OriginalGatewayTxnId : null);
        $details->authorizedAmount = (isset($reportResponse->Data->AuthAmt) ? (string)$reportResponse->Data->AuthAmt : null);
        $details->maskedCardNumber = (isset($reportResponse->Data->MaskedCardNbr) ? (string)$reportResponse->Data->MaskedCardNbr : null);
        $details->authorizationCode = (isset($reportResponse->Data->AuthCode) ? (string)$reportResponse->Data->AuthCode : null);
        $details->avsResultCode = (isset($reportResponse->Data->AVSRsltCode) ? (string)$reportResponse->Data->AVSRsltCode : null);
        $details->avsResultText = (isset($reportResponse->Data->AVSRsltText) ? (string)$reportResponse->Data->AVSRsltText : null);
        $details->cardType = (isset($reportResponse->Data->CardType) ? (string)$reportResponse->Data->CardType : null);
        $details->descriptor = (isset($reportResponse->Data->TxnDescriptor) ? (string)$reportResponse->Data->TxnDescriptor : null);
        $details->transactionType = (isset($reportResponse->ServiceName) ? HpsTransaction::serviceNameToTransactionType((string)$reportResponse->ServiceName) : null);
        $details->transactionUTCDate = (isset($reportResponse->RspUtcDT) ? (string)$reportResponse->RspUtcDT : null);
        $details->cpcIndicator = (isset($reportResponse->Data->CPCInd) ? (string)$reportResponse->Data->CPCInd : null);
        $details->cvvResultCode = (isset($reportResponse->Data->CVVRsltCode) ? (string)$reportResponse->Data->CVVRsltCode : null);
        $details->cvvResultText = (isset($reportResponse->Data->CVVRsltText) ? (string)$reportResponse->Data->CVVRsltText : null);
        $details->referenceNumber = (isset($reportResponse->Data->RefNbr) ? (string)$reportResponse->Data->RefNbr : null);
        $details->responseCode = (isset($reportResponse->Data->RspCode) ? (string)$reportResponse->Data->RspCode : null);
        $details->responseText = (isset($reportResponse->Data->RspText) ? (string)$reportResponse->Data->RspText : null);
        $details->transactionStatus = (isset($reportResponse->Data->TxnStatus) ? (string)$reportResponse->Data->TxnStatus : null);
        $details->gratuityAmount = (isset($reportResponse->Data->GratuityAmtInfo) ? (string)$reportResponse->Data->GratuityAmtInfo : null);
        $details->settlementAmount = (isset($reportResponse->Data->SettlementAmt) ? (string)$reportResponse->Data->SettlementAmt : null);
        $details->convenienceAmount = (isset($reportResponse->Data->ConvenienceAmtInfo) ? (string)$reportResponse->Data->ConvenienceAmtInfo : null);
        $details->shippingAmount = (isset($reportResponse->Data->ShippingAmtInfo) ? (string)$reportResponse->Data->ShippingAmtInfo : null);

        if (isset($reportResponse->Data->TokenizationMsg)) {
            $details->tokenData = new HpsTokenData();
            $details->tokenData->responseMessage = (string)$reportResponse->Data->TokenizationMsg;
        }

        if (isset($reportResponse->Data->AdditionalTxnFields)) {
            $additionalTxnFields = $reportResponse->Data->AdditionalTxnFields;
            $details->memo = (isset($additionalTxnFields->Description) ? (string)$additionalTxnFields->Description : null);
            $details->invoiceNumber = (isset($additionalTxnFields->InvoiceNbr) ? (string)$additionalTxnFields->InvoiceNbr : null);
            $details->customerId = (isset($additionalTxnFields->CustomerID) ? (string)$additionalTxnFields->CustomerID : null);
        }

        if ((string)$reportResponse->GatewayRspCode != '0' && (string)$reportResponse->Data->RspCode != '00') {
            if ($details->exceptions == null) {
                $details->exceptions = new HpsChargeExceptions();
            }

            $details->exceptions->issuerException = HpsIssuerResponseValidation::getException(
                (string)$rsp->Header->GatewayTxnId,
                (string)$reportResponse->Data->RspCode,
                (string)$reportResponse->Data->RspText,
                'credit'
            );
        }

        return $details;
    }
400638
private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
    {
        $options = array();
        if ($clientTxnId != null) {
            $options['clientTransactionId'] = $clientTxnId;
        }

        try {
            $response = $this->doRequest($transaction, $options);
        } catch (HpsException $e) {
            if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
                if (in_array($txnType, array('CreditSale', 'CreditAuth'))) {
                    try {
                        $this->reverse($cardData, $this->_amount, $this->_currency);
                    } catch (Exception $e) {
                        throw new HpsGatewayException('0', HpsExceptionCodes::GATEWAY_TIMEOUT_REVERSAL_ERROR);
                    }
                }
                throw new HpsException('An error occurred and the gateway has timed out', 'gateway_timeout', $e, 'gateway_timeout');
            }
            throw $e;
        }

        $this->_processChargeGatewayResponse($response, $txnType);
        $this->_processChargeIssuerResponse($response, $txnType);

        $rvalue = null;
        switch ($txnType) {
            case 'ReportTxnDetail':
                $rvalue = HpsReportTransactionDetails::fromDict($response, $txnType);
                break;
            case 'ReportActivity':
                $rvalue = HpsReportTransactionSummary::fromDict($response, $txnType, $this->_filterBy);
                break;
            case 'CreditSale':
                $rvalue = HpsCharge::fromDict($response, $txnType);
                break;
            case 'CreditAccountVerify':
                $rvalue = HpsAccountVerify::fromDict($response, $txnType);
                break;
            case 'CreditAuth':
                $rvalue = HpsAuthorization::fromDict($response, $txnType);
                break;
            case 'CreditReturn':
                $rvalue = HpsRefund::fromDict($response, $txnType);
                break;
            case 'CreditReversal':
                $rvalue = HpsReversal::fromDict($response, $txnType);
                break;
            case 'CreditVoid':
                $rvalue = HpsVoid::fromDict($response, $txnType);
                break;
            case 'CreditCPCEdit':
                $rvalue = HpsCPCEdit::fromDict($response, $txnType);
                break;
            case 'CreditTxnEdit':
                $rvalue = HpsTransaction::fromDict($response, $txnType);
                break;
            case 'RecurringBilling':
                $rvalue = HpsRecurringBilling::fromDict($response, $txnType);
                break;
            case 'ManageTokens':
                $rvalue = HpsManageTokensResponse::fromDict($response);
                break;
            default:
                break;
        }

        return $rvalue;
    }
1092411
public function post(
        ResponseInterface $response,
        string $transactionId,
        array $options = []
    ): CancellablePromiseInterface {
        if ($response->getBody() instanceof ReadableStreamInterface) {
            return resolve($response);
        }

        if (!isset($options[self::class]) &&
        strpos($response->getHeaderLine('Content-Type'), 'text/xml') !== 0) {
            return resolve($response);
        }

        if (isset($options[self::class][Options::CONTENT_TYPE]) &&
        $response->getHeaderLine('Content-Type') !== $options[self::class][Options::CONTENT_TYPE]) {
            return resolve($response);
        }

        $body = (string)$response->getBody();
        if ($body === '') {
            $stream = new BufferStream(0);
            $stream->write($body);

            return resolve($response->withBody($stream));
        }

        return $this->xmlDecodeService->decode($body)->then(function (array $xml) use ($response) {
            return resolve($response->withBody(new XmlStream($xml)));
        });
    }
1168412
public function processRedsysTransaction($ds_response, Transaction $transaction)
    {
        if ($ds_response > 99) {
            return false;
        }

        $transaction->setStatus(Transaction::STATUS_PAID);
        $pm = $this->manager->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('redsys');
        $transaction->setPaymentMethod($pm);

        $this->manager->persist($transaction);
        $this->manager->flush();

        return true;
    }
1255717
public function execute(TransactionData $transactionData, $argument = null)
    {
        $transactionData->setResponse(
            $this->processAndGetResponse(
                $transactionData,
                function (TransactionData $transaction, ScenarioState $state) {
                    $this->storage->setScenarioState($state->getScenarioName(), $state->getScenarioState());
                    $this->logger->debug(
                        'Scenario ' . $state->getScenarioName() . ' state is set to ' . $state->getScenarioState()
                    );

                    return $transaction->getResponse()
                        ->withStatus(200)
                        ->withHeader('Content-Type', 'application/json')
                        ->withBody(new StringStream(json_encode($state)));
                }
            )
        );
    }