Payment_Process2
[ class tree: Payment_Process2 ] [ index: Payment_Process2 ] [ all elements ]

Source for file TrustCommerce.php

Documentation is available at TrustCommerce.php

  1. <?php
  2. require_once 'Payment/Process2/Result.php';
  3. require_once 'Payment/Process2/Result/Driver.php';
  4.  
  5. class Payment_Process2_Result_TrustCommerce extends Payment_Process2_Result implements Payment_Process2_Result_Driver
  6. {
  7.  
  8.     var $_statusCodeMap = array('approved' => Payment_Process2::RESULT_APPROVED,
  9.                                 'accepted' => Payment_Process2::RESULT_APPROVED,
  10.                                 'declined' => Payment_Process2::RESULT_DECLINED,
  11.                                 'baddata' => Payment_Process2::RESULT_OTHER,
  12.                                 'error' => Payment_Process2::RESULT_OTHER);
  13.  
  14.     /**
  15.      * TrustCommerce status codes
  16.      *
  17.      * This array holds response codes.
  18.      *
  19.      * @see getStatusText()
  20.      * @access private
  21.      */
  22.     var $_statusCodeMessages = array(
  23.         'approved' => 'The transaction was successfully authorized.',
  24.         'accepted' => 'The transaction has been successfully accepted into the system.',
  25.         'decline' => 'The transaction was declined, see declinetype for further details.',
  26.         'baddata' => 'Invalid parameters passed, see error for further details.',
  27.         'error' => 'System error when processing the transaction, see errortype for details.',
  28.     );
  29.  
  30.     var $_avsCodeMap = array(
  31.         'N' => Payment_Process2::AVS_MISMATCH,
  32.         'U' => Payment_Process2::AVS_NOAPPLY,
  33.         'G' => Payment_Process2::AVS_NOAPPLY,
  34.         'R' => Payment_Process2::AVS_ERROR,
  35.         'E' => Payment_Process2::AVS_ERROR,
  36.         'S' => Payment_Process2::AVS_ERROR,
  37.         'O' => Payment_Process2::AVS_ERROR
  38.     );
  39.  
  40.     var $_avsCodeMessages = array(
  41.          'X' => 'Exact match, 9 digit zipcode.',
  42.          'Y' => 'Exact match, 5 digit zipcode.',
  43.          'A' => 'Street address match only.',
  44.          'W' => '9 digit zipcode match only.',
  45.          'Z' => '5 digit zipcode match only.',
  46.          'N' => 'No mtach on street address or zipcode.',
  47.          'U' => 'AVS unavailable on this card.',
  48.          'G' => 'Non-US card issuer, AVS unavailable.',
  49.          'R' => 'Card issuer system currently down, try again later.',
  50.          'E' => 'Error, ineligible - not a mail/phone order.',
  51.          'S' => 'Service not supported.',
  52.          'O' => 'General decline or other error'
  53.     );
  54.  
  55.     var $_cvvCodeMap = array('cvv' => Payment_Process2::CVV_MISMATCH
  56.     );
  57.  
  58.     var $_cvvCodeMessages = array'cvv' => 'The CVV number is not valid.'
  59.     );
  60.  
  61.     var $_fieldMap = array('status'  => 'code',
  62.                            'avs'  => 'avsCode',
  63.                            'transid'  => 'transactionId'
  64.     );
  65.  
  66.     /**
  67.      * @todo Good unit test coverage!
  68.      */
  69.     function parse()
  70.     {
  71.         $responseArray = array();
  72.      
  73.         parse_str(str_replace(array("\r""\n")"&"$this->_rawResponse)$responseArray);
  74.  
  75.         if (isset($responseArray['status'])) {
  76.             $this->code = trim($responseArray['status']);
  77.         }
  78.  
  79.         if (isset($responseArray['avs'])) {
  80.             $this->avsCode = trim($responseArray['avs']);
  81.         }
  82.  
  83.         if (isset($responseArray['transid'])) {
  84.             $this->transactionId = trim($responseArray['transid']);
  85.         }
  86.  
  87.         if (!isset($this->_statusCodeMessages[$this->messageCode])) {
  88.  
  89.             $message !empty($responseArray['status']$this->_statusCodeMessages[trim($responseArray['status'])"";
  90.             if (!empty($responseArray['error'])) {
  91.                 $message .= "\nError type: ".$responseArray['error'].'.';
  92.         }
  93.  
  94.             if (!empty($responseArray['offenders'])) {
  95.                 $message .= "\nOffending fields: ".$responseArray['offenders'].'.';
  96.             }
  97.  
  98.             $this->_statusCodeMessages[$this->messageCode$message;
  99.         }
  100.     }
  101.  
  102. }

Documentation generated on Mon, 11 Mar 2019 15:40:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.