Exemplo n.º 1
0
 public static function fromDict($rsp, $txnType, $returnType = 'HpsVoid')
 {
     $void = parent::fromDict($rsp, $txnType, $returnType);
     $void->responseCode = '00';
     $void->responseText = '';
     return $void;
 }
 public static function fromDict($rsp, $txnType, $returnType = 'HpsOfflineAuthorization')
 {
     $offlineAuth = parent::fromDict($rsp, $txnType, $returnType);
     $offlineAuth->responseCode = '00';
     $offlineAuth->responseText = '';
     return $offlineAuth;
 }
Exemplo n.º 3
0
 /**
  * @param \SimpleXMLElement $rsp
  * @param null   $txnType
  * @param string $returnType
  *
  * @return HpsManageTokensResponse
  */
 public static function fromDict($rsp, $txnType = null, $returnType = 'HpsManageTokensResponse')
 {
     $transaction = parent::fromDict($rsp, $txnType, $returnType);
     $transaction->responseCode = '00';
     $transaction->responseText = '';
     return $transaction;
 }
Exemplo n.º 4
0
 public static function fromDict($rsp, $txnType, $returnType = 'HpsCPCEdit')
 {
     $cpcEdit = parent::fromDict($rsp, $txnType, $returnType);
     $cpcEdit->responseCode = '00';
     $cpcEdit->responseText = '';
     return $cpcEdit;
 }
Exemplo n.º 5
0
 public static function fromDict($rsp, $txnType, $returnType = 'HpsRefund')
 {
     $refund = parent::fromDict($rsp, $txnType, $returnType);
     $refund->responseCode = '00';
     $refund->responseText = '';
     return $refund;
 }
Exemplo n.º 6
0
 public static function fromDict($rsp, $txnType, $returnType = 'HpsReversal')
 {
     $reverseResponse = $rsp->Transaction->{$txnType};
     $reverse = parent::fromDict($rsp, $txnType, $returnType);
     $reverse->avsResultCode = isset($reverseResponse->AVSRsltCode) ? $reverseResponse->AVSRsltCode : null;
     $reverse->avsResultText = isset($reverseResponse->AVSRsltText) ? $reverseResponse->AVSRsltText : null;
     $reverse->ccpIndicator = isset($reverseResponse->CPCInd) ? $reverseResponse->CPCInd : null;
     $reverse->cvvResultCode = isset($reverseResponse->CVVRsltCode) ? $reverseResponse->CVVRsltCode : null;
     $reverse->cvvResultText = isset($reverseResponse->CVVRsltText) ? $reverseResponse->CVVRsltText : null;
     return $reverse;
 }
Exemplo n.º 7
0
 /**
  * @param \SimpleXMLElement $rsp
  * @param null $txnType
  * @param string $returnType
  *
  * @return HpsAttachment
  */
 public static function fromDict($rsp, $txnType, $returnType = 'HpsAttachment')
 {
     $attResponse = $rsp->Transaction->{$txnType}->Details;
     $transaction = parent::fromDict($rsp, $txnType, $returnType);
     foreach (get_object_vars($attResponse) as $key => $prop) {
         if (property_exists($transaction, lcfirst($key))) {
             $transaction->__set(lcfirst($key), $prop);
         }
     }
     return $transaction;
 }
Exemplo n.º 8
0
 public static function fromDict($rsp, $txnType, $returnType = 'HpsTransactionStatus')
 {
     $statusResponse = $rsp->Transaction->{$txnType};
     $status = parent::fromDict($rsp, $txnType, $returnType);
     $status->authorizationCode = isset($statusResponse->TransactionStatus->AuthCode) ? (string) $statusResponse->TransactionStatus->AuthCode : null;
     $status->originalGatewayResponseCode = isset($statusResponse->TransactionStatus->GatewayRspCode) ? (string) $statusResponse->TransactionStatus->GatewayRspCode : null;
     $status->originalGatewayResponseText = isset($statusResponse->TransactionStatus->GatewayRspMsg) ? (string) $statusResponse->TransactionStatus->GatewayRspMsg : null;
     $status->originalResponseCode = isset($statusResponse->TransactionStatus->RspCode) ? (string) $statusResponse->TransactionStatus->RspCode : null;
     $status->originalResponseText = isset($statusResponse->TransactionStatus->RspText) ? (string) $statusResponse->TransactionStatus->RspText : null;
     $status->transactionStatus = isset($statusResponse->TransactionStatus->TxnStatus) ? (string) $statusResponse->TransactionStatus->TxnStatus : null;
     $status->originalTransactionId = isset($statusResponse->TransactionStatus->GatewayTxnId) ? (string) $statusResponse->TransactionStatus->GatewayTxnId : null;
     $status->altPayment = isset($statusResponse->TransactionStatus->AltPayment) ? $statusResponse->TransactionStatus->AltPayment : null;
     $status->timezoneConversion = isset($statusResponse->TzConversion) ? (string) $statusResponse->TzConversion : null;
     return $status;
 }
 public static function fromDict($rsp, $txnType, $filterBy = null, $returnType = 'HpsReportTransactionSummary')
 {
     $transactions = array();
     if ((string) $rsp->Transaction->ReportActivity->Header->TxnCnt == "0") {
         return $transactions;
     }
     if ($filterBy != null && is_string($filterBy)) {
         $filterBy = HpsTransaction::serviceNameToTransactionType($filterBy);
     }
     $summary = null;
     $serviceName = isset($filterBy) ? HpsTransaction::transactionTypeToServiceName($filterBy) : null;
     foreach ($rsp->Transaction->ReportActivity->Details as $charge) {
         if (isset($serviceName) && $serviceName != (string) $charge->ServiceName) {
             continue;
         }
         $summary = new HpsReportTransactionSummary();
         // Hydrate the header
         $summary->_header = new HpsTransactionHeader();
         $summary->_header->gatewayResponseCode = (string) $charge->GatewayRspCode;
         $summary->_header->gatewayResponseMessage = (string) $charge->GatewayRspMsg;
         $summary->transactionId = (string) $charge->GatewayTxnId;
         $summary->originalTransactionId = isset($charge->OriginalGatewayTxnId) ? (string) $charge->OriginalGatewayTxnId : null;
         $summary->maskedCardNumber = isset($charge->MaskedCardNbr) ? (string) $charge->MaskedCardNbr : null;
         $summary->responseCode = isset($charge->IssuerRspCode) ? (string) $charge->IssuerRspCode : null;
         $summary->responseText = isset($charge->IssuerRspText) ? (string) $charge->IssuerRspText : null;
         $summary->amount = isset($charge->Amt) ? (string) $charge->Amt : null;
         $summary->settlementAmount = isset($charge->SettlementAmt) ? (string) $charge->SettlementAmt : null;
         $summary->transactionType = isset($charge->ServiceName) ? HpsTransaction::serviceNameToTransactionType((string) $charge->ServiceName) : null;
         $summary->transactionUTCDate = isset($charge->TxnUtcDT) ? (string) $charge->TxnUtcDT : null;
         $gwResponseCode = isset($charge->GatewayRspCode) ? (string) $charge->GatewayRspCode : null;
         $issuerResponseCode = isset($charge->IssuerRspCode) ? (string) $charge->IssuerRspCode : null;
         if ($gwResponseCode != "0" || $issuerResponseCode != "00") {
             $exceptions = new HpsChargeExceptions();
             if ($gwResponseCode != "0") {
                 $message = (string) $charge->GatewayRspMsg;
                 $exceptions->hpsException = HpsGatewayResponseValidation::getException((string) $charge->GatewayTxnId, $gwResponseCode, $message);
             }
             if ($issuerResponseCode != "00") {
                 $message = (string) $charge->IssuerRspText;
                 $exceptions->cardException = HpsIssuerResponseValidation::getException((string) $charge->GatewayTxnId, $issuerResponseCode, $message);
             }
             $summary->exceptions = $exceptions;
         }
         $transactions[] = $summary;
     }
     return $transactions;
 }
 public static function fromDict($rsp, $txnType, $returnType = 'HpsCheckResponse')
 {
     $response = $rsp->Transaction->{$txnType};
     $sale = parent::fromDict($rsp, $txnType, $returnType);
     $sale->responseCode = isset($response->RspCode) ? $response->RspCode : null;
     $sale->responseText = isset($response->RspMessage) ? $response->RspMessage : null;
     $sale->authorizationCode = isset($response->AuthCode) ? $response->AuthCode : null;
     if ($response->CheckRspInfo) {
         $sale->details = array();
         if (count($response->CheckRspInfo) > 1) {
             foreach ($response->CheckRspInfo as $key => $details) {
                 $sale->details[] = self::_hydrateRspDetails($details);
             }
         } else {
             $sale->details = self::_hydrateRspDetails($response->CheckRspInfo);
         }
     }
     return $sale;
 }
 public static function fromDict($rsp, $txnType, $filterBy = null, $returnType = 'HpsReportTransactionSummary')
 {
     $transactions = array();
     if ($rsp->Transaction->ReportActivity->Header->TxnCnt == "0") {
         return $transactions;
     }
     $summary = null;
     $serviceName = isset($filterBy) ? HpsTransaction::transactionTypeToServiceName($filterBy) : null;
     foreach ($rsp->Transaction->ReportActivity->Details as $charge) {
         if ($filterBy == null || $charge->ServiceName != $serviceName) {
             $summary = parent::fromDict($rsp, $txnType, $returnType);
             $summary->originalTransactionId = isset($charge->OriginalGatewayTxnId) ? $charge->OriginalGatewayTxnId : null;
             $summary->maskedCardNumber = isset($charge->MaskedCardNbr) ? $charge->MaskedCardNbr : null;
             $summary->responseCode = isset($charge->IssuerRspCode) ? $charge->IssuerRspCode : null;
             $summary->responseText = isset($charge->IssuerRspText) ? $charge->IssuerRspText : null;
             $summary->amount = isset($charge->Amt) ? $charge->Amt : null;
             $summary->settlementAmount = isset($charge->SettlementAmt) ? $charge->SettlementAmt : null;
             $summary->transactionType = isset($charge->ServiceName) ? HpsTransaction::serviceNameToTransactionType($charge->ServiceName) : null;
             $summary->transactionUTCDate = isset($charge->TxnUtcDT) ? $charge->TxnUtcDT : null;
             if ($filterBy != null) {
                 $summary->transactionType = $filterBy;
             }
             $gwResponseCode = isset($charge->GatewayRspCode) ? $charge->GatewayRspCode : null;
             $issuerResponseCode = isset($charge->IssuerRspCode) ? $charge->IssuerRspCode : null;
             if ($gwResponseCode != "0" || $issuerResponseCode != "00") {
                 $exceptions = new HpsChargeExceptions();
                 if ($gwResponseCode != "0") {
                     $message = $charge->GatewayRspMsg;
                     $exceptions->gatewayException = HpsGatewayResponseValidation::getException($charge->GatewayTxnId, $gwResponseCode, $message);
                 }
                 if ($issuerResponseCode != "00") {
                     $message = $charge->IssuerRspText;
                     $exceptions->issuerException = HpsIssuerResponseValidation::getException($charge->GatewayTxnId, $issuerResponseCode, $message);
                 }
                 $summary->exceptions = $exceptions;
             }
         }
         $transactions[] = $summary;
     }
     return $transactions;
 }
 public static function fromDict($rsp, $txnType, $returnType = 'HpsAuthorization')
 {
     $authResponse = $rsp->Transaction->{$txnType};
     $auth = parent::fromDict($rsp, $txnType, $returnType);
     $auth->authorizationCode = isset($authResponse->AuthCode) ? $authResponse->AuthCode : null;
     $auth->avsResultCode = isset($authResponse->AVSRsltCode) ? $authResponse->AVSRsltCode : null;
     $auth->avsResultText = isset($authResponse->AVSRsltText) ? $authResponse->AVSRsltText : null;
     $auth->cvvResultCode = isset($authResponse->CVVRsltCode) ? $authResponse->CVVRsltCode : null;
     $auth->cvvResultText = isset($authResponse->CVVRsltText) ? $authResponse->CVVRsltText : null;
     $auth->authorizedAmount = isset($authResponse->AuthAmt) ? $authResponse->AuthAmt : null;
     $auth->cardType = isset($authResponse->CardType) ? $authResponse->CardType : null;
     $auth->descriptor = isset($authResponse->TxnDescriptor) ? $authResponse->TxnDescriptor : null;
     $auth->cpcIndicator = isset($authResponse->CPCInd) ? $authResponse->CPCInd : null;
     if (isset($rsp->Header->TokenData)) {
         $auth->tokenData = new HpsTokenData();
         $auth->tokenData->responseCode = isset($rsp->Header->TokenData->TokenRspCode) ? $rsp->Header->TokenData->TokenRspCode : null;
         $auth->tokenData->responseMessage = isset($rsp->Header->TokenData->TokenRspMsg) ? $rsp->Header->TokenData->TokenRspMsg : null;
         $auth->tokenData->tokenValue = isset($rsp->Header->TokenData->TokenValue) ? $rsp->Header->TokenData->TokenValue : null;
     }
     return $auth;
 }
 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;
     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->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);
     }
     return $details;
 }
 public function listTransactions($startDate, $endDate, $filterBy = null)
 {
     date_default_timezone_set("UTC");
     $dateFormat = 'Y-m-d\\TH:i:s.00\\Z';
     $current = new DateTime();
     $currentTime = $current->format($dateFormat);
     if ($startDate > $currentTime) {
         throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidStartDate);
     } else {
         if ($endDate > $currentTime) {
             throw $this->exceptionMapper->map_sdk_exception(HpsSdkCodes::$invalidEndDate);
         }
     }
     $xml = new DOMDocument();
     $hpsTransaction = $xml->createElement('hps:Transaction');
     $hpsReportActivity = $xml->createElement('hps:ReportActivity');
     $hpsReportActivity->appendChild($xml->createElement('hps:RptStartUtcDT', $startDate));
     $hpsReportActivity->appendChild($xml->createElement('hps:RptEndUtcDT', $endDate));
     $hpsTransaction->appendChild($hpsReportActivity);
     $response = $this->doTransaction($hpsTransaction);
     // Gateway Exception
     if ($response->Header->GatewayRspCode != 0) {
         $transactionId = $response->Header->GatewayTxnId;
         $responseCode = $response->Header->GatewayRspCode;
         $responseMessage = $response->Header->GatewayRspMessage;
         throw $this->exceptionMapper->map_gateway_exception($transactionId, $responseCode, $responseMessage);
     }
     $result = array();
     if ($response->Transaction->ReportActivity->Header->TxnCnt == "0") {
         return $result;
     }
     foreach ($response->Transaction->ReportActivity->Details as $charge) {
         if ($filterBy != null && $charge->ServiceName != HpsTransaction::transactionTypeToServiceName($filterBy)) {
             continue;
         } else {
             $summary = new HpsReportTransactionSummary();
             $summary->transactionId = isset($charge->GatewayTxnId) ? $charge->GatewayTxnId : null;
             $summary->originalTransactionId = isset($charge->OriginalGatewayTxnId) ? $charge->OriginalGatewayTxnId : null;
             $summary->maskedCardNumber = isset($charge->MaskedCardNbr) ? $charge->MaskedCardNbr : null;
             $summary->responseCode = isset($charge->IssuerRspCode) ? $charge->IssuerRspCode : null;
             $summary->responseText = isset($charge->IssuerRspText) ? $charge->IssuerRspText : null;
             if ($filterBy != null) {
                 $summary->transactionType = isset($charge->ServiceName) ? HpsTransaction::transactionTypeToServiceName($charge->ServiceName) : null;
             }
             $gwResponseCode = isset($charge->GatewayRspCode) ? $charge->GatewayRspCode : null;
             $issuerResponseCode = isset($charge->IssuerRspCode) ? $charge->IssuerRspCode : null;
             if ($gwResponseCode != "0" || $issuerResponseCode != "00") {
                 $exceptions = new HpsChargeExceptions();
                 if ($gwResponseCode != "0") {
                     $message = $charge->GatewayRspMsg;
                     $exceptions->hpsException = $this->exceptionMapper->map_gateway_exception($charge->GatewayTxnId, $gwResponseCode, $message);
                 }
                 if ($issuerResponseCode != "00") {
                     $message = $charge->IssuerRspText;
                     $exceptions->cardException = $this->exceptionMapper->map_issuer_exception($charge->GatewayTxnId, $issuerResponseCode, $message);
                 }
                 $summary->exceptions = $exceptions;
             }
         }
         $result = $summary;
     }
     return $result;
 }
Exemplo n.º 15
0
 public function __construct($header)
 {
     parent::__construct($header);
 }
Exemplo n.º 16
0
 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;
 }