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

Source for file Transfirst.php

Documentation is available at Transfirst.php

  1. <?php
  2. require_once 'Payment/Process2/Result.php';
  3. require_once 'Payment/Process2/Result/Driver.php';
  4.  
  5. class Payment_Process2_Result_Transfirst extends Payment_Process2_Result implements Payment_Process2_Result_Driver
  6. {
  7.  
  8.     /**
  9.      * Transfirst status codes.
  10.      *
  11.      * This array holds every possible status returned by the Transfirst gateway.
  12.      *
  13.      * See the Transfirst documentation for more details on each response.
  14.      *
  15.      * @see getStatusText()
  16.      * @access private
  17.      */
  18.     var $_statusCodeMessages = array(
  19.         '00' => "Approved",
  20.         '01' => "Refer to issuer",
  21.         '02' => "Refer to issuer - Special condition",
  22.         '03' => "Invalid merchant ID",
  23.         '04' => "Pick up card",
  24.         '05' => "Declined",
  25.         '06' => "General error",
  26.         '07' => "Pick up card - Special condition",
  27.         '13' => "Invalid amount",
  28.         '14' => "Invalid card number",
  29.         '15' => "No such issuer",
  30.         '19' => "Re-enter transaction",
  31.         '21' => "Unable to back out transaction",
  32.         '28' => "File is temporarily unavailable",
  33.         '39' => "No credit account",
  34.         '41' => "Pick up card - Lost",
  35.         '43' => "Pick up card - Stolen",
  36.         '51' => "Insufficient funds",
  37.         '54' => "Expired card",
  38.         '57' => "Transaction not permitted - Card",
  39.         '61' => "Amount exceeds withdrawal limit",
  40.         '62' => "Invalid service code, restricted",
  41.         '65' => "Activity limit exceeded",
  42.         '76' => "Unable to locate, no match",
  43.         '77' => "Inconsistent data, rev. or repeat",
  44.         '78' => "No account",
  45.         '80' => "Invalid date",
  46.         '85' => "Card OK",
  47.         '91' => "Issuer or switch is unavailable",
  48.         '93' => "Violation, cannot complete",
  49.         '96' => "System malfunction",
  50.         '98' => "No matching transaction to void",
  51.         '99' => "System timeout",
  52.         'L0' => "General System Error - Contact Transfirst Account Exec.",
  53.         'L1' => "Invalid or missing account number",
  54.         'L2' => "Invalid or missing password",
  55.         'L3' => "Expiration Date is not formatted correctly",
  56.         'L4' => "Reference number not found",
  57.         'L6' => "Order number is required but missing",
  58.         'L7' => "Wrong transaction code",
  59.         'L8' => "Network timeout",
  60.         'L14' => "Invalid card number",
  61.         'S5' => "Already settled",
  62.         'S6' => "Not authorized",
  63.         'S7' => "Declined",
  64.         'V6' => "Invalid transaction type",
  65.         'V7' => "Declined",
  66.         'V8' => "Already voided",
  67.         'V9' => "Already posted"
  68.     );
  69.  
  70.     var $_avsCodeMap = array(
  71.         'A' => "Address match",
  72.         'E' => "Ineligible",
  73.         'N' => "No match",
  74.         'R' => "Retry",
  75.         'S' => "Service unavailable",
  76.         'U' => "Address information unavailable",
  77.         'W' => "9-digit zip match",
  78.         'X' => "Address and 9-digit zip match",
  79.         'Y' => "Address and 5-digit zip match",
  80.         'Z' => "5-digit zip match"
  81.     );
  82.  
  83.     /**
  84.      * Status code map
  85.      *
  86.      * This contains a map from the Processor-specific result codes to the generic
  87.      * P_P codes. Anything not defined here is treated as a DECLINED result by
  88.      * validate()
  89.      *
  90.      * @type array
  91.      * @access private
  92.      */
  93.     var $_statusCodeMap = array(
  94.         '00' => Payment_Process2::RESULT_APPROVED,
  95.         '05' => Payment_Process2::RESULT_DECLINED,
  96.         'V7' => Payment_Process2::RESULT_DECLINED
  97.     );
  98.  
  99.     var $_aciCodes = array(
  100.         'A' => "CPS Qualified",
  101.         'E' => "CPS Qualified  -  Card Acceptor Data was submitted in the authorization  request.",
  102.         'M' => "Reserved - The card was not present and no AVS request for International transactions",
  103.         'N' => "Not CPS Qualified",
  104.         'V' => "CPS Qualified ? Included an address verification request in the authorization request."
  105.     );
  106.  
  107.     var $_authSourceCodes = array(
  108.         ' ' => "Terminal doesn't support",
  109.         '0' => "Exception File",
  110.         '1' => "Stand in Processing, time-out response",
  111.         '2' => "Loss Control System (LCS) response provided",
  112.         '3' => "STIP, response provided, issuer suppress inquiry mode",
  113.         '4' => "STIP, response provided, issuer is down",
  114.         '5' => "Response provided by issuer",
  115.         '9' => "Automated referral service (ARS) stand-in"
  116.     );
  117.  
  118.     var $_fieldMap = array(
  119.         0  => '_null',                    // TF Internal Message Format
  120.         1  => '_acctNo',                  // TF Account number
  121.         2  => '_transactionCode',         // The transaction code from the request message passed by the original request.
  122.         3  => 'transactionId',            // Assigned by TF used to uniquely identify transaction.
  123.         4  => '_mailOrder',               // Mail Order Identifier
  124.         5  => '_ccAcctNo',                // The credit card account number passed by the original request.
  125.         6  => '_ccExpDate',               // The Expiration Date passed by the original request. The field is formatted YYMM (Year, Month)
  126.         7  => '_authAmount',              // An eight-digit value, which denotes the dollar amount passed to TF, without a decimal. ( DDDDDDCC )
  127.         8  => '_authDate',                // A six-digit value, which denotes the date the authorization, was attempted.  The field is formatted YYMMDD. (Year, Month, Date)
  128.         9  => '_authTime',                // A six-digit value, which denotes the time the authorization, was attempted.  The field is formatted HHMMSS.  (Hour, Minute, Second)
  129.         10 => 'messageCode',              // A two-digit value, which indicates the result of the authorization request.  Used to determine if the card was authorized, declined or timed out.
  130.         11 => 'customerId',               // The Customer Number passed by the original request
  131.         12 => 'invoiceNumber',            // The Order Number passed by the original request.
  132.         13 => '_urn',                     // A number that uniquely identifies an individual transaction.  Assigned by TF and can be used when referencing a specific transaction.
  133.         14 => '_authResponse',            // A number provided by the issuing bank indicating the authorization is valid and funds have been reserved for transfer to the merchants account at a later time.
  134.         15 => '_authSource',              // A code that defines the source where an authorization was captured.
  135.         16 => '_authCharacteristic',      // A code that defines the qualification level for the authorized transaction.
  136.         17 => 'approvalCode',             // Assigned by Visa or MasterCard, used to uniquely identify and link together all related information and used to authorize and clear a transaction.
  137.         18 => '_validationCode',          // Assigned by V.I.P. System that is used to determine the accuracy of the authorization data.
  138.         19 => '_sicCatCode',              // A merchants industry classification.  Example - Mail Order/Phone Order Merchants (Direct Market) = 5969.
  139.         20 => '_currencyCode',            // 840 indicate US Currency to date this is the only valid value.
  140.         21 => 'avsCode',                  // A value that indicates the level of Address Verification that was validated.
  141.         22 => '_merchantStoreNo',         // Identifies the specific terminal used at a location  1-4 Merchant store #, 5-8 specific terminal at store.
  142.         23 => 'cvvCode'                   // A two-digit value, indicating the result of the card verification based on the CVV2 code provided by the cardholder.
  143.     );
  144.  
  145.     /**
  146.      * Constructor.
  147.      *
  148.      * @param  string  $rawResponse  The raw response from the gateway
  149.      * @return mixed boolean true on success, PEAR_Error on failure
  150.      */
  151.     function __construct($rawResponse,  Payment_Process2_Common $request)
  152.     {
  153.         $this->_validateResponse($rawResponse);
  154.  
  155.  
  156.         parent::__construct($rawResponse$request);
  157.         $res $this->parse(); /** @todo This is Wrong WRONG WRONGGGG! Constructors do no work! */
  158.     }
  159.  
  160.     function getAuthSource()
  161.     {
  162.         return @$this->_authSourceCodes[$this->_authSource];
  163.     }
  164.  
  165.     function getAuthCharacteristic()
  166.     {
  167.         return @$this->_aciCodes[$this->_authChar];
  168.     }
  169.  
  170.     function getCode()
  171.     {
  172.         return $this->_statusCodeMap[$this->messageCode];
  173.     }
  174.  
  175.     /**
  176.      * Parse Transfirst (DPILink) R1 response string.
  177.      *
  178.      * This function parses the response the gateway sends back, which is in
  179.      * pipe-delimited format.
  180.      *
  181.      * @return void 
  182.      */
  183.     function parse()
  184.     {
  185.         $this->_mapFields(explode('|'$this->_rawResponse));
  186.     }
  187.  
  188.     /**
  189.      * Validate a R1 response.
  190.      *
  191.      * @return boolean 
  192.      */
  193.     function _validateResponse($resp)
  194.     {
  195.         if (strlen($resp> 160{
  196.             throw new Payment_Process2_Exception("Response too short, appears invalid");
  197.         }
  198.  
  199.         // FIXME - add more tests
  200.  
  201.         return true;
  202.     }
  203. }

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