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

Source for file LinkPoint.php

Documentation is available at LinkPoint.php

  1. <?php
  2. require_once 'Payment/Process2/Result.php';
  3. require_once 'Payment/Process2/Result/Driver.php';
  4.  
  5. /**
  6.  * Payment_Process2_Result_LinkPoint
  7.  *
  8.  * LinkPoint result class
  9.  *
  10.  * @author Joe Stump <joe@joestump.net>
  11.  * @package Payment_Process2
  12.  */
  13. class Payment_Process2_Result_LinkPoint extends Payment_Process2_Result implements Payment_Process2_Result_Driver
  14. {
  15.  
  16.     var $_statusCodeMap = array('APPROVED' => Payment_Process2::RESULT_APPROVED,
  17.                                 'DECLINED' => Payment_Process2::RESULT_DECLINED,
  18.                                 'FRAUD' => Payment_Process2::RESULT_FRAUD);
  19.  
  20.     /**
  21.      * LinkPoint status codes
  22.      *
  23.      * This array holds many of the common response codes. There are over 200
  24.      * response codes - so check the LinkPoint manual if you get a status
  25.      * code that does not match (see "Response Reason Codes & Response
  26.      * Reason Text" in the AIM manual).
  27.      *
  28.      * @see getStatusText()
  29.      * @access private
  30.      */
  31.     var $_statusCodeMessages = array(
  32.         'APPROVED' => 'This transaction has been approved.',
  33.         'DECLINED' => 'This transaction has been declined.',
  34.         'FRAUD' => 'This transaction has been determined to be fraud.');
  35.  
  36.     var $_avsCodeMap = array(
  37.         'YY' => Payment_Process2::AVS_MATCH,
  38.         'YN' => Payment_Process2::AVS_MISMATCH,
  39.         'YX' => Payment_Process2::AVS_ERROR,
  40.         'NY' => Payment_Process2::AVS_MISMATCH,
  41.         'XY' => Payment_Process2::AVS_MISMATCH,
  42.         'NN' => Payment_Process2::AVS_MISMATCH,
  43.         'NX' => Payment_Process2::AVS_MISMATCH,
  44.         'XN' => Payment_Process2::AVS_MISMATCH,
  45.         'XX' => Payment_Process2::AVS_ERROR
  46.     );
  47.  
  48.     var $_avsCodeMessages = array(
  49.         'YY' => 'Address matches, zip code matches',
  50.         'YN' => 'Address matches, zip code does not match',
  51.         'YX' => 'Address matches, zip code comparison not available',
  52.         'NY' => 'Address does not match, zip code matches',
  53.         'XY' => 'Address comparison not available, zip code matches',
  54.         'NN' => 'Address comparison does not match, zip code does not match',
  55.         'NX' => 'Address does not match, zip code comparison not available',
  56.         'XN' => 'Address comparison not available, zip code does not match',
  57.         'XX' => 'Address comparison not available, zip code comparison not available'
  58.     );
  59.  
  60.     var $_cvvCodeMap = array('M' => Payment_Process2::CVV_MATCH,
  61.                              'N' => Payment_Process2::CVV_MISMATCH,
  62.                              'P' => Payment_Process2::CVV_ERROR,
  63.                              'S' => Payment_Process2::CVV_ERROR,
  64.                              'U' => Payment_Process2::CVV_ERROR,
  65.                              'X' => Payment_Process2::CVV_ERROR
  66.     );
  67.  
  68.     var $_cvvCodeMessages = array(
  69.         'M' => 'Card Code Match',
  70.         'N' => 'Card code does not match',
  71.         'P' => 'Not processed',
  72.         'S' => 'Merchant has indicated that the card code is not present on the card',
  73.         'U' => 'Issuer is not certified and/or has not proivded encryption keys',
  74.         'X' => 'No response from the credit card association was received'
  75.     );
  76.  
  77.     var $_fieldMap = array('r_approved'  => 'code',
  78.                            'r_error'  => 'message',
  79.                            'r_code'  => 'approvalCode',
  80.                            'r_ordernum'  => 'transactionId'
  81.     );
  82.  
  83.     /**
  84.     * parse
  85.     *
  86.     * @author Joe Stump <joe@joestump.net>
  87.     * @access public
  88.     * @return void 
  89.     */
  90.     function parse()
  91.     {
  92.         $xml =  new Payment_Process2_LinkPoint_XML_Parser();
  93.         $xml->parseString('<response>'.$this->_rawResponse.'</response>');
  94.         if (is_array($xml->response&& count($xml->response)) {
  95.             $this->avsCode = substr($xml->response['r_avs'],0,2);
  96.             $this->cvvCode = substr($xml->response['r_avs'],2,1);
  97.             $this->customerId = $this->_request->customerId;
  98.             $this->invoiceNumber = $this->_request->invoiceNumber;
  99.             $this->_mapFields($xml->response);
  100.  
  101.             // switch to DECLINED since a duplicate isn't *really* fraud
  102.             if (preg_match('/duplicate/i',$this->message)) {
  103.                 $this->messageCode = 'DECLINED';
  104.             }
  105.         }
  106.     }
  107. }
  108.  
  109.  
  110.  
  111. require_once 'XML/Parser.php';
  112.  
  113. /**
  114.  * Payment_Process2_LinkPoint_XML_Parser
  115.  *
  116.  * XML Parser for the LinkPoint response
  117.  *
  118.  * @todo    Split out to own class
  119.  * @author Joe Stump <joe@joestump.net>
  120.  * @package Payment_Process2
  121.  */
  122. class Payment_Process2_LinkPoint_XML_Parser extends XML_Parser
  123. {
  124.     /**
  125.      * $response
  126.      *
  127.      * @var array $response Raw response as an array
  128.      * @access public
  129.      */
  130.     var $response = array();
  131.  
  132.     /**
  133.      * $log
  134.      *
  135.      * @var string $tag Current tag
  136.      * @access private
  137.      */
  138.     var $tag = null;
  139.  
  140.     /**
  141.      * startHandler
  142.      *
  143.      * @author Joe Stump <joe@joestump.net>
  144.      * @access public
  145.      * @param resource $xp XML processor handler
  146.      * @param string $elem Name of XML entity
  147.      * @return void 
  148.      */
  149.     function startHandler($xp$elem$attribs)
  150.     {
  151.         $this->tag $elem;
  152.     }
  153.  
  154.     /**
  155.      * endHandler
  156.      *
  157.      * @author Joe Stump <joe@joestump.net>
  158.      * @access public
  159.      * @param resource $xp XML processor handler
  160.      * @param string $elem Name of XML entity
  161.      * @return void 
  162.      */
  163.     function endHandler($xp$elem)
  164.     {
  165.  
  166.     }
  167.  
  168.     /**
  169.      * defaultHandler
  170.      *
  171.      * @author Joe Stump <joe@joestump.net>
  172.      * @access public
  173.      * @param resource $xp XML processor handler
  174.      * @param string $data 
  175.      * @return void 
  176.      */
  177.     function defaultHandler($xp,$data)
  178.     {
  179.         $this->response[strtolower($this->tag)$data;
  180.     }
  181. }

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