private function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
 {
     try {
         $response = $this->doTransaction($transaction, $clientTxnId);
     } catch (HpsException $e) {
         if ($e->innerException != null && $e->innerException->getMessage() == "gateway_time-out") {
             if ($txnType == 'CreditSale' || $txnType == 'CreditAuth') {
                 try {
                     $this->reverse($cardData, $this->_amount, $this->_currency);
                 } catch (Exception $e) {
                     throw new HpsGatewayException('0', HpsExceptionCodes::GatewayTimeoutReversalError);
                 }
             }
             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;
     if ($txnType == 'ReportTxnDetail') {
         $rvalue = HpsReportTransactionDetails::fromDict($response, $txnType);
     } elseif ($txnType == 'ReportActivity') {
         $rvalue = HpsReportTransactionSummary::fromDict($response, $txnType, $this->_filterBy);
     } elseif ($txnType == 'CreditSale') {
         $rvalue = HpsCharge::fromDict($response, $txnType);
     } elseif ($txnType == 'CreditAccountVerify') {
         $rvalue = HpsAccountVerify::fromDict($response, $txnType);
     } elseif ($txnType == 'CreditAuth') {
         $rvalue = HpsAuthorization::fromDict($response, $txnType);
     } elseif ($txnType == 'CreditReturn') {
         $rvalue = HpsRefund::fromDict($response, $txnType);
     } elseif ($txnType == 'CreditReversal') {
         $rvalue = HpsReversal::fromDict($response, $txnType);
     } elseif ($txnType == 'CreditVoid') {
         $rvalue = HpsVoid::fromDict($response, $txnType);
     }
     return $rvalue;
 }
 public function _submitTransaction($transaction, $txnType, $clientTxnId = null, $cardData = null)
 {
     try {
         $response = $this->doRequest($transaction, $clientTxnId);
     } 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 'CreditAdditionalAuth':
             $rvalue = HpsAuthorization::fromDict($response, $txnType);
             break;
         case 'PrePaidBalanceInquiry':
             $rvalue = HpsAuthorization::fromDict($response, $txnType);
             break;
         case 'PrePaidAddValue':
             $rvalue = HpsAuthorization::fromDict($response, $txnType);
             break;
         case 'CreditOfflineAuth':
             $rvalue = HpsOfflineAuthorization::fromDict($response, $txnType);
             break;
         case 'CreditOfflineAuth':
             $rvalue = HpsOfflineAuthorization::fromDict($response, $txnType);
             break;
         case 'ManageTokens':
             $rvalue = HpsManageTokensResponse::fromDict($response, $txnType);
             break;
         default:
             break;
     }
     return $rvalue;
 }