@param \Orkestra\Transactor\Entity\Transaction $transaction
@param array                                   $options

@return array
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;
    }
430533
public function transact(Transaction $transaction, array $options = array())
    {
        if ($transaction->isTransacted()) {
            throw TransactorException::transactionAlreadyProcessed();
        } elseif (!$this->supportsType($transaction->getType())) {
            throw TransactorException::unsupportedTransactionType($transaction->getType());
        } elseif (!$this->supportsNetwork($transaction->getNetwork())) {
            throw TransactorException::unsupportedTransactionNetwork($transaction->getNetwork());
        }

        $result = $transaction->getResult();
        $result->setTransactor($this);

        try {
            $options = $this->getResolver()->resolve($options);

            $this->doTransact($transaction, $options);
        } catch (\Exception $e) {
            $result->setStatus(new ResultStatus(ResultStatus::ERROR));
            $result->setMessage('An internal error occurred while processing the transaction.');
            $result->setData('message', $e->getMessage());
            $result->setData('trace', $e->getTraceAsString());
        }

        return $this->filterResult($result);
    }
642551
private function getDb($transaction, $object)
    {
        if($object instanceof \Imi\Model\Model)
        {
            $db = Db::getInstance(ModelManager::getDbPoolName($object));
        }
        else
        {
            $db = Db::getInstance($transaction->dbPoolName);
        }
        return $db;
    }
1331526
public function handleType(int $assetOffset, Transaction $transaction): Transaction
    {
        $deserializer = $this->deserializers[$transaction->type];

        return (new $deserializer($this->buffer, $assetOffset, $transaction))->deserialize();
    }
675346
public function queryAssoc($query, $options = array())
    {
        $statement = $this->_runQuery($query, $options);
        return $statement->fetch(\PDO::FETCH_ASSOC);
    }
451091
public function doRequest($request, $options = null)
    {
        $request = array_merge($request, array(
            'Version'        => $this->_config->version,
            'ProcessorId'    => $this->_config->processorId,
            'MerchantId'     => $this->_config->merchantId,
            'TransactionPwd' => $this->_config->transactionPwd,
        ));

        $xml = new DOMDocument('1.0', 'utf-8');
        $envelope = $xml->createElement('CardinalMPI');
        foreach ($request as $k => $v) {
            $envelope->appendChild($xml->createElement($k, $v));
        }
        $xml->appendChild($envelope);

        $url = $this->_config->serviceUri();
        $xmlData = $xml->saveXML();
        $data = 'cmpi_msg=' . urlencode($xmlData);
        $header = array(
            'Content-type: application/x-www-form-urlencoded;charset="utf-8"',
            'Accept: text/xml',
            'Content-length: '.strlen($data),
        );
        // error_log($xmlData);

        return $this->submitRequest($url, $header, $data);
    }
536318
protected function updateTransaction($query, $update, $options)
    {
        return $this->transaction_collection->updateOne($query, $update, $options);
    }
15569
protected function handleQueryResponse(Transaction $transaction, $data)
    {
        $result = $transaction->getResult();
        $parentResult = $transaction->getParent()->getResult();
        $eventResult = null;

        foreach ($data->Results as $event) {
            if ($event->TransAct_ReferenceID === $parentResult->getExternalId()) {
                $eventResult = $event;

                // We don't break in case the transaction has multiple events in the same query-- we want the latest
            }
        }

        $resultType = $parentResult->getStatus()->getValue();

        if (null !== $eventResult) {
            switch ($eventResult->ResultingStatus) {
                case 'Scheduled':
                    $resultType = Result\ResultStatus::PENDING;
                    break;

                case 'Cancelled':
                    $resultType = Result\ResultStatus::CANCELLED;
                    break;

                case 'In-Process':
                    $resultType = Result\ResultStatus::PROCESSED;
                    break;

                case 'Cleared':
                    $resultType = Result\ResultStatus::APPROVED;
                    break;

                case 'Failed Verification':
                case 'Returned-NSF':
                case 'Returned-Other':
                    $resultType = Result\ResultStatus::DECLINED;
                    break;

                case 'Charged Back':
                    $resultType = Result\ResultStatus::CHARGED_BACK;
                    break;

                case 'Merchant Hold':
                case 'Processor Hold':
                    $resultType = Result\ResultStatus::HOLD;
                    break;
            }
        }

        $result->setStatus(new Result\ResultStatus($resultType));
    }
944224
public function addTransaction(Transaction $transaction)
    {
        $transaction->setAgreement($this);
        $this->transactions->add($transaction);

        return $this;
    }
161597
public static function get_last_by_transaction(Transaction $transaction) {
		$db = Database::Get();
		$id = $db->get_one('SELECT id FROM transaction_log WHERE transaction_id=? ORDER BY created DESC LIMIT 1', [ $transaction->id ]);
		if ($id === null) {
			throw new \Exception('No transaction_log yet');
		}

		return self::get_by_id($id);;
	}
715407
def get_bank_transactions(options = {})
      request_params = {}
      request_params[:BankTransactionID]  = options[:bank_transaction_id] if options[:bank_transaction_id]
      request_params[:ModifiedAfter]      = options[:modified_since] if options[:modified_since]
      request_params[:order]              = options[:order] if options[:order]
      request_params[:where]              = options[:where] if options[:where]
      request_params[:page]               = options[:page] if options[:page]

      response_xml = http_get(@client, "#{@xero_url}/BankTransactions", request_params)

      parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/BankTransactions'})
    end
1192433
public function transAlterTable($table, $options, $advanced_options)
    {
        $this->transInitTable($table);
        $this->schemaUpdateTransaction[$table]['alteredOptions'] = $options;
        $this->schemaUpdateTransaction[$table]['advancedOptions'] = $advanced_options;
    }
1095557
public function handleVersionTwo(Transaction $transaction): Transaction
    {
        $transaction->id = Hash::sha256($transaction->serialize())->getHex();

        return $transaction;
    }
1366454
public function query(array $where, array $options = []) {
        $options += [
            'order' => $this->getDefaultOrder(),
            'limit' => $this->getDefaultLimit(),
            Db::OPTION_FETCH_MODE => $this->getFetchArgs()
        ];

        $stmt = $this->db->get($this->name, $where, $options);
        return $stmt;
    }
723569
public function trackTransaction($id, array $options = [])
	{
		$options['id'] = $id;
		$this->trackEcommerce(self::ECOMMERCE_TRANSACTION, $options);
	}
399270
protected function initTransaction(array $options = [])
    {
        if (!isset($options['transactionId'])) {
            $this->transactionId = IdGenerator::generateId();
            $this->getClient()->sendFrame(
                $this->getProtocol()->getBeginFrame($this->transactionId)
            );
        } else {
            $this->transactionId = $options['transactionId'];
        }
    }
1296902
private function extractSales($transactions) {
		$out = [];
		
		foreach ($transactions as $trx) {
			foreach ($trx->related_resources as $src) {
				if (isset($src->sale)) {
					$out[] = $src->sale;
				}
			}
		}
		
		return $out;
	}