Performs a check there is an empty required param for the passed transaction type

@param string $transactionType
@param string $customRequiredParam
@param array $txnParameters

@throws \Genesis\Exceptions\ErrorParameter
429410
protected function checkEmptyRequiredParamsFor(
        $transactionType,
        $customRequiredParam,
        $txnParameters = []
    ) {
        if (CommonUtils::isArrayKeyExists($customRequiredParam, $txnParameters) &&
            !empty($txnParameters[$customRequiredParam])
        ) {
            return;
        }

        foreach ($txnParameters as $parameter) {
            if (CommonUtils::isArrayKeyExists($customRequiredParam, $parameter) &&
                !empty($parameter[$customRequiredParam])
            ) {
                return;
            }
        }

        throw new \Genesis\Exceptions\ErrorParameter(
            sprintf(
                'Empty (null) required parameter: %s for transaction type %s',
                $customRequiredParam,
                $transactionType
            )
        );
    }
453664
public function execute(TransactionData $transactionData, $argument = null)
    {
        $this->requestsStorage->addRequest($transactionData->getRequest());
    }
421157
protected function buildParams(Transaction $transaction, array $options = array())
    {
        $credentials = $transaction->getCredentials();

        $params = array(
            'type' => $this->getNmiType($transaction),
            'username' => $credentials->getCredential('username'),
            'password' => $credentials->getCredential('password'),
        );

        if (in_array($transaction->getType()->getValue(), array(
            Transaction\TransactionType::REFUND))
        ) {
            $params = array_merge($params, array(
                'transactionid' => $transaction->getParent()->getResult()->getExternalId(),
            ));
        } else {
            $account = $transaction->getAccount();

            $names = explode(' ', $account->getName(), 2);
            $firstName = isset($names[0]) ? $names[0] : '';
            $lastName = isset($names[1]) ? $names[1] : '';

            $params = array_merge($params, array(
                'firstname' => $firstName,
                'lastname' => $lastName,
                'address' => $account->getAddress(),
                'city' => $account->getCity(),
                'state' => $account->getRegion(),
                'zip' => $account->getPostalCode(),
                'country' => $account->getCountry(),
                'ipaddress' => $account->getIpAddress(),
                'payment' => 'check',
                'sec_code' => $credentials->getCredential('secCode') ?: 'WEB',
                'account_holder_type' => in_array($account->getAccountType()->getValue(), array(
                    AccountType::PERSONAL_SAVINGS,
                    AccountType::PERSONAL_CHECKING
                )) ? 'personal' : 'business',
                'account_type' => in_array($transaction->getAccount()->getAccountType()->getValue(), array(
                    AccountType::PERSONAL_SAVINGS,
                    AccountType::BUSINESS_SAVINGS
                )) ? 'savings' : 'checking',
                'amount' => $transaction->getAmount(),
                'checkname' => $account->getName(),
                'checkaba' => $account->getRoutingNumber(),
                'checkaccount' => $account->getAccountNumber()
            ));
        }

        return $params;
    }
1185138
public function execute(TransactionData $transactionData, $argument = null)
    {
        if ($argument instanceof ClassArgumentObject) {
            $middleware = $argument->getInstance();

            $transactionData->setResponse(
                $middleware(
                    $transactionData->getRequest(),
                    $transactionData->getResponse(),
                    $argument->getArgument()
                )
            );
        }
    }
1256485
public static function getException($transactionId, $responseCode, $responseText, $type)
    {
        $acceptedCodes = array('00', '0');
        $map = array();

        switch ($type) {
        case 'credit':
            $acceptedCodes = array_merge($acceptedCodes, array('85', '10'));
            $map = self::$_issuerCodeToCreditExceptionCode;
            break;
        case 'gift':
            $acceptedCodes = array_merge($acceptedCodes, array('13'));
            $map = self::$_issuerCodeToGiftExceptionCode;
            break;
        }

        if (in_array($responseCode, $acceptedCodes)) {
            return null;
        }

        $code = null;
        if (array_key_exists($responseCode, $map)) {
            $code = $map[$responseCode];
        }

        if ($code == null) {
            return new HpsCreditException(
                $transactionId,
                HpsExceptionCodes::UNKNOWN_CREDIT_ERROR,
                self::$_creditExceptionCodeToMessage[HpsExceptionCodes::UNKNOWN_CREDIT_ERROR],
                $responseCode,
                $responseText
            );
        }

        $message = null;
        if (array_key_exists($code, self::$_creditExceptionCodeToMessage)) {
            $message = self::$_creditExceptionCodeToMessage[$code];
        } else {
            $message = 'Unknown issuer error';
        }

        return new HpsCreditException($transactionId, $code, $message, $responseCode, $responseText);
    }
398427
protected function validateTransaction(Transaction $transaction)
    {
        if (!$transaction->getParent() && in_array($transaction->getType()->getValue(), array(Transaction\TransactionType::CAPTURE, Transaction\TransactionType::REFUND, Transaction\TransactionType::VOID))) {
            throw ValidationException::parentTransactionRequired();
        }

        $credentials = $transaction->getCredentials();

        if (!$credentials) {
            throw ValidationException::missingCredentials();
        } elseif (null === $credentials->getCredential('username') || null === $credentials->getCredential('password')) {
            throw ValidationException::missingRequiredParameter('username or password');
        }

        $account = $transaction->getAccount();

        if (!$account) {
            throw ValidationException::missingAccountInformation();
        }

        if ((!($account instanceof CardAccount) && !($account instanceof SwipedCardAccount))
            || (!($account instanceof SwipedCardAccount) && $transaction->getNetwork() == Transaction\NetworkType::SWIPED)
        ) {
            throw ValidationException::invalidAccountType($account);
        }

        if (!$account instanceof SwipedCardAccount) {
            if (null === $account->getAccountNumber()) {
                throw ValidationException::missingRequiredParameter('account number');
            } elseif (null === $account->getExpMonth() || null === $account->getExpYear()) {
                throw ValidationException::missingRequiredParameter('card expiration');
            }
        }
    }
182285
def transaction_type(self, value):
        """"""
        if value is not None:
            if value not in self.ALLOWED_TRANSACTION_TYPES:
                raise AttributeError('%s transaction_type element must be one of %s not %s' % (
                    self.__class__.__name__, ','.join(self.ALLOWED_TRANSACTION_TYPES), value,))
        self._transaction_type = value
1087239
public function _submitTransaction($transaction, $txnType, $clientTxnId = null)
    {
        $response = $this->doRequest($transaction, $clientTxnId);

        HpsGatewayResponseValidation::checkResponse($response, $txnType);
        HpsIssuerResponseValidation::checkResponse(
            $response->Header->GatewayTxnId,
            $response->Transaction->$txnType->RspCode,
            $response->Transaction->$txnType->RspText,
            'gift'
        );

        $rvalue = '';
        switch ($txnType) {
            case 'GiftCardActivate':
                $rvalue = HpsGiftCardActivate::fromDict($response, $txnType, 'HpsGiftCardActivate');
                break;
            case 'GiftCardAddValue':
                $rvalue = HpsGiftCardAddValue::fromDict($response, $txnType, 'HpsGiftCardAddValue');
                break;
            case 'GiftCardAlias':
                $rvalue = HpsGiftCardAlias::fromDict($response, $txnType, 'HpsGiftCardAlias');
                break;
            case 'GiftCardBalance':
                $rvalue = HpsGiftCardBalance::fromDict($response, $txnType, 'HpsGiftCardBalance');
                break;
            case 'GiftCardDeactivate':
                $rvalue = HpsGiftCardDeactivate::fromDict($response, $txnType, 'HpsGiftCardDeactivate');
                break;
            case 'GiftCardReplace':
                $rvalue = HpsGiftCardReplace::fromDict($response, $txnType, 'HpsGiftCardReplace');
                break;
            case 'GiftCardReward':
                $rvalue = HpsGiftCardReward::fromDict($response, $txnType, 'HpsGiftCardReward');
                break;
            case 'GiftCardSale':
                $rvalue = HpsGiftCardSale::fromDict($response, $txnType, 'HpsGiftCardSale');
                break;
            case 'GiftCardVoid':
                $rvalue = HpsGiftCardVoid::fromDict($response, $txnType, 'HpsGiftCardVoid');
                break;
            case 'GiftCardReversal':
                $rvalue = HpsGiftCardReversal::fromDict($response, $txnType, 'HpsGiftCardReversal');
                break;
            default:
                break;
        }

        return $rvalue;
    }
160008
private Transaction createTransaction(long writePointer, TransactionType type) {
    // For holding the first in progress short transaction Id (with timeout >= 0).
    long firstShortTx = Transaction.NO_TX_IN_PROGRESS;
    LongArrayList inProgressIds = new LongArrayList(inProgress.size());
    for (Map.Entry<Long, InProgressTx> entry : inProgress.entrySet()) {
      long txId = entry.getKey();
      inProgressIds.add(txId);
      // add any checkpointed write pointers to the in-progress list
      LongArrayList childIds = entry.getValue().getCheckpointWritePointers();
      if (childIds != null) {
        for (int i = 0; i < childIds.size(); i++) {
          inProgressIds.add(childIds.get(i));
        }
      }
      if (firstShortTx == Transaction.NO_TX_IN_PROGRESS && !entry.getValue().isLongRunning()) {
        firstShortTx = txId;
      }
    }

    return new Transaction(readPointer, writePointer, invalidArray, inProgressIds.toLongArray(), firstShortTx, type);
  }
421201
public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentCreateSession')
    {
        $createSession = $rsp->Transaction->$txnType;

        $session = parent::fromDict($rsp, $txnType, $returnType);
        if (isset($createSession->Session)) {
            $pairs = self::nvpToArray($createSession->Session);
        }

        $session->sessionId = isset($pairs['SessionId']) ? $pairs['SessionId'] : null;
        $session->redirectUrl = isset($pairs['RedirectUrl']) ? $pairs['RedirectUrl'] : null;

        return $session;
    }
1120897
private function getTransactionTypeObject($sTransactionType)
    {
        static $aTypeCache = array();
        if (false === isset($aTypeCache[$sTransactionType])) {
            $oTransactionType = TdbPkgShopPaymentTransactionType::GetNewInstance();
            if (false === $oTransactionType->LoadFromField('system_name', $sTransactionType)) {
                $sMessage = "transaction type {$sTransactionType} does not exists in DB";
                throw new TPkgShopPaymentTransactionException_InvalidTransactionType(
                    self::MESSAGE_ERROR, array('sMessage' => $sMessage),
                    $sMessage,
                    array(
                        'order' => $this->order->sqlData,
                        'type' => $sTransactionType,
                    ),
                    1,
                    self::LOG
                );
            }
            $aTypeCache[$sTransactionType] = $oTransactionType;
        }

        return $aTypeCache[$sTransactionType];
    }
318199
public function execute(TransactionData $transactionData, $argument = null)
    {
        $transactionData->setResponse(
            $this->processAndGetResponse(
                $transactionData,
                function (TransactionData $transaction, Expectation $expectation) {
                    $this->validateRequestOrThrowException($expectation, $this->logger);
                    $executions = $this->searchForExecutionsCount($expectation);
                    $this->logger->debug('Listed ' . \count($executions) . ' request matching the expectation');

                    return $transaction->getResponse()
                        ->withStatus(200)
                        ->withHeader('Content-Type', 'application/json')
                        ->withBody(new StringStream(json_encode($executions)));
                }
            )
        );
    }
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;
    }
977174
public static function fromDict($rsp, $txnType, $returnType = 'HpsAltPaymentResponse')
    {
        $response = $rsp->Transaction->$txnType;

        $altPayment = parent::fromDict($rsp, $txnType, $returnType);

        if ($response->RspCode != 0) {
            $error = self::nvpToArray($response->Processor->Response);
            $altPayment->error = new HpsProcessorError();
            $altPayment->error->code = isset($error['Code']) ? $error['Code'] : null;
            $altPayment->error->message = isset($error['Message']) ? $error['Message'] : null;
            $altPayment->error->type = isset($error['Type']) ? $error['Type'] : null;
        }

        return $altPayment;
    }
1215398
public function registerTransaction(array $transactionData): RegisterInterface
    {
        $uri = $this->getUri('register', $this->getParameters($transactionData));
        /** @var RegisterInterface $response */
        $response = $this->performRequest((string) $uri);

        Assert::isInstanceOf($response, RegisterInterface::class, 'Invalid response');

        return $response;
    }
368982
protected function validateTransaction(Transaction $transaction)
    {
        if (!$transaction->getParent() && in_array($transaction->getType()->getValue(), array(
            Transaction\TransactionType::CAPTURE,
            Transaction\TransactionType::REFUND,
            Transaction\TransactionType::VOID,
            Transaction\TransactionType::QUERY,
            Transaction\TransactionType::UPDATE))
        ) {
            throw ValidationException::parentTransactionRequired();
        }

        $credentials = $transaction->getCredentials();

        if (!$credentials) {
            throw ValidationException::missingCredentials();
        } elseif (null === $credentials->getCredential('providerId')) {
            throw ValidationException::missingRequiredParameter('Provider ID');
        } elseif (null === $credentials->getCredential('providerGateId')) {
            throw ValidationException::missingRequiredParameter('Provider Gate ID');
        } elseif (null === $credentials->getCredential('providerGateKey')) {
            throw ValidationException::missingRequiredParameter('Provider Gate Key');
        } elseif (null === $credentials->getCredential('merchantId')) {
            throw ValidationException::missingRequiredParameter('Merchant ID');
        } elseif (null === $credentials->getCredential('merchantGateId')) {
            throw ValidationException::missingRequiredParameter('Merchant Gate ID');
        } elseif (null === $credentials->getCredential('merchantGateKey')) {
            throw ValidationException::missingRequiredParameter('Merchant Gate Key');
        }

        $account = $transaction->getAccount();

        if (!$account || !$account instanceof BankAccount) {
            throw ValidationException::missingAccountInformation();
        }

        if (null === $account->getAccountNumber()) {
            throw ValidationException::missingRequiredParameter('account number');
        } elseif (null === $account->getRoutingNumber()) {
            throw ValidationException::missingRequiredParameter('routing number');
        } elseif (null === $account->getIpAddress()) {
            throw ValidationException::missingRequiredParameter('IP address');
        } elseif (null === $account->getAccountType()) {
            throw ValidationException::missingRequiredParameter('account type');
        }
    }
408992
protected function _validateTransaction(Transaction $transaction)
    {
        if (!$transaction->getParent() && in_array($transaction->getType()->getValue(), array(
            Transaction\TransactionType::CAPTURE,
            Transaction\TransactionType::REFUND
        ))) {
            throw ValidationException::parentTransactionRequired();
        }
    }