コード例 #1
0
 /**
  * Parse the response from the server
  *
  * @param	array
  * @return	object 
  */
 protected function _parse_response($xml)
 {
     //If it failed when being parsed as XML, go ahead and return it
     if (isset($xml->status) && $xml->status == 'failure') {
         return $xml;
     }
     $details = (object) array();
     $as_array = Payment_Utility::arrayize_object($xml);
     $result = $as_array['messages']['resultCode'];
     if (isset($as_array['transactionResponse'])) {
         $identifier = $as_array['transactionResponse']['transId'];
     }
     if (isset($as_array['subscriptionId'])) {
         $identifier = $as_array['subscriptionId'];
     }
     $timestamp = gmdate('c');
     $details->timestamp = $timestamp;
     $details->gateway_response = $as_array;
     if (isset($identifier) and strlen($identifier) > 1) {
         $details->identifier = $identifier;
     }
     if ($result == 'Ok') {
         return Payment_Response::instance()->gateway_response('Success', $this->_lib_method . '_success', $details);
     }
     if ($result == 'Error') {
         if (isset($as_array['transactionResponse']['errors']['error']['errorText'])) {
             $message = $as_array['transactionResponse']['errors']['error']['errorText'];
         }
         if (isset($as_array['messages']['message']['text'])) {
             $message = $as_array['messages']['message']['text'];
         }
         if (isset($message)) {
             $details->reason = $message;
         }
         return Payment_Response::instance()->gateway_response('Failure', $this->_lib_method . '_gateway_failure', $details);
     }
 }
コード例 #2
0
 /**
  * Parse the response from the server
  *
  * @param	array
  * @return	object
  */
 private function _parse_response($response)
 {
     $details = (object) array();
     if (is_object($response)) {
         if ($response->code == '1') {
             return Payment_Response::instance()->gateway_response('Success', $this->_lib_method . '_success', $details);
         } else {
             $details->reason = $response->message;
             return Payment_Response::instance()->gateway_response('Failure', $this->_lib_method . '_gateway_failure', $details);
         }
     } elseif (strstr($response, '<response>')) {
         $response = Payment_Utility::parse_xml($response);
         $response = Payment_Utility::arrayize_object($response);
         $details->gateway_response = $response;
         if ($response['code'] == '1') {
             return Payment_Response::instance()->gateway_response('Success', $this->_lib_method . '_success', $details);
         } else {
             $details->reason = $response['message'];
             return Payment_Response::instance()->gateway_response('Failure', $this->_lib_method . '_gateway_failure', $details);
         }
     } else {
         $results = explode('&', urldecode($response));
         foreach ($results as $result) {
             list($key, $value) = explode('=', $result);
             $gateway_response[$key] = $value;
         }
         $details->gateway_response = $gateway_response;
         $details->timestamp = isset($gateway_response['trnDate']) ? $gateway_response['trnDate'] : gmdate('c');
         if (isset($gateway_response['trnApproved']) && $gateway_response['trnApproved'] == '1') {
             $details->identifier = isset($gateway_response['trnId']) ? $gateway_response['trnId'] : null;
             if (isset($gateway_response['rbAccountId'])) {
                 $details->identifier = $gateway_response['rbAccountId'];
             }
             return Payment_Response::instance()->gateway_response('success', $this->_lib_method . '_success', $details);
         } else {
             $details->reason = isset($gateway_response['messageText']) ? $gateway_response['messageText'] : null;
             return Payment_Response::instance()->gateway_response('failure', $this->_lib_method . '_gateway_failure', $details);
         }
     }
 }
コード例 #3
0
 /**
  * Parse the response from the server
  *
  * @param	array
  * @return	object
  */
 protected function _parse_response($xml)
 {
     $details = (object) array();
     $as_array = Payment_Utility::arrayize_object($xml);
     $signon = isset($as_array['SignonMsgsRs']) ? $as_array['SignonMsgsRs'] : '';
     $response = isset($as_array['QBMSXMLMsgsRs']) ? $as_array['QBMSXMLMsgsRs'] : '';
     $result = '';
     $message = '';
     $identifier = '';
     if (isset($response['CustomerCreditCardChargeRs'])) {
         $result = $response['CustomerCreditCardChargeRs']['@attributes']['statusCode'];
         $message = $response['CustomerCreditCardChargeRs']['@attributes']['statusMessage'];
         $identifier = $response['CustomerCreditCardChargeRs']['CreditCardTransID'];
     }
     if (isset($response['CustomerCreditCardAuthRs'])) {
         $result = $response['CustomerCreditCardAuthRs']['@attributes']['statusCode'];
         $message = $response['CustomerCreditCardAuthRs']['@attributes']['statusMessage'];
         $identifier = $response['CustomerCreditCardAuthRs']['CreditCardTransID'];
     }
     if (isset($response['CustomerCreditCardCaptureRs'])) {
         $result = $response['CustomerCreditCardCaptureRs']['@attributes']['statusCode'];
         $message = $response['CustomerCreditCardCaptureRs']['@attributes']['statusMessage'];
         $identifier = $response['CustomerCreditCardCaptureRs']['CreditCardTransID'];
     }
     if (isset($response['CustomerCreditCardTxnVoidRs'])) {
         $result = $response['CustomerCreditCardTxnVoidRs']['@attributes']['statusCode'];
         $message = $response['CustomerCreditCardTxnVoidRs']['@attributes']['statusMessage'];
         $identifier = $response['CustomerCreditCardTxnVoidRs']['CreditCardTransID'];
     }
     if (isset($response['CustomerCreditCardTxnVoidOrRefundRs'])) {
         $result = $response['CustomerCreditCardTxnVoidOrRefundRs']['@attributes']['statusCode'];
         $message = $response['CustomerCreditCardTxnVoidOrRefundRs']['@attributes']['statusMessage'];
         if (isset($response['CustomerCreditCardTxnVoidOrRefundRs']['CreditCardTransID'])) {
             $identifier = $response['CustomerCreditCardTxnVoidOrRefundRs']['CreditCardTransID'];
         }
     }
     $details->gateway_response = $as_array;
     if ($result === '0') {
         //Transaction was successful
         $details->identifier = $identifier;
         $details->timestamp = isset($signon['ServerDateTime']) ? $signon['ServerDateTime'] : '';
         return Payment_Response::instance()->gateway_response('Success', $this->_lib_method . '_success', $details);
     } else {
         //Transaction failed
         $details->reason = $message;
         return Payment_Response::instance()->gateway_response('Failure', $this->_lib_method . '_gateway_failure', $details);
     }
 }
コード例 #4
0
 /**
  * Parse the response from the server
  *
  * @param	array
  * @return	object
  */
 protected function _parse_response($xml)
 {
     $details = (object) array();
     $as_array = Payment_Utility::arrayize_object($xml);
     $result = $as_array['Approved'];
     if (isset($as_array['OrderID']) && !empty($as_array['OrderID'])) {
         $identifier = $as_array['OrderID'];
     }
     if (isset($as_array['TransRefNumber'])) {
         $identifier2 = $as_array['TransRefNumber'];
     }
     $details->timestamp = $as_array['TransTime'];
     $details->gateway_response = $as_array;
     if (isset($identifier)) {
         $identifier = (string) $identifier;
         if (strlen($identifier) > 1) {
             $details->identifier = $identifier;
         }
     }
     if (isset($identifier2)) {
         $identifier2 = (string) $identifier2;
         if (strlen($identifier2) > 1) {
             $details->identifier2 = $identifier2;
         }
     }
     if ($result == 'APPROVED') {
         return Payment_Response::instance()->gateway_response('Success', $this->_lib_method . '_success', $details);
     }
     if ($result == 'ERROR' or $result == 'DECLINED') {
         if (isset($as_array['ErrMsg'])) {
             $message = $as_array['ErrMsg'];
             $message = explode(':', $message);
             $message = $message[1];
         }
         if (isset($message)) {
             $details->reason = $message;
         }
         return Payment_Response::instance()->gateway_response('Failure', $this->_lib_method . '_gateway_failure', $details);
     }
 }