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

Source for file PayPal.php

Documentation is available at PayPal.php

  1. <?php
  2. require_once 'Payment/Process2/Result.php';
  3. require_once 'Payment/Process2/Result/Driver.php';
  4.  
  5. class Payment_Process2_Result_PayPal extends Payment_Process2_Result implements Payment_Process2_Result_Driver
  6. {
  7.  
  8.     var $_statusCodeMap = array('1' => Payment_Process2::RESULT_APPROVED,
  9.                                 '2' => Payment_Process2::RESULT_DECLINED,
  10.                                 '3' => Payment_Process2::RESULT_OTHER,
  11.                                 '4' => Payment_Process2::RESULT_REVIEW,
  12.                                 );
  13.     /**
  14.      * PayPal error codes
  15.      *
  16.      * This array holds many of the common response codes. There are over 200
  17.      * response codes - so check the PayPal manual if you get a status
  18.      * code that does not match (see "Error Reference Message" in the NVAPI
  19.      * Developer Guide).
  20.      *
  21.      * @see getStatusText()
  22.      * @access private
  23.      */
  24.     var $_statusCodeMessages = array();
  25.  
  26.     var $_avsCodeMap = array(
  27.         '0' => Payment_Process2::AVS_MATCH,
  28.         '1' => Payment_Process2::AVS_MISMATCH,
  29.         '2' => Payment_Process2::AVS_MISMATCH,
  30.         '3' => Payment_Process2::AVS_NOAPPLY,
  31.         '4' => Payment_Process2::AVS_ERROR,
  32.         'A' => Payment_Process2::AVS_MISMATCH,
  33.         'B' => Payment_Process2::AVS_MISMATCH,
  34.         'C' => Payment_Process2::AVS_MISMATCH,
  35.         'D' => Payment_Process2::AVS_MATCH,
  36.         'E' => Payment_Process2::AVS_NOAPPLY,
  37.         'F' => Payment_Process2::AVS_MATCH,
  38.         'G' => Payment_Process2::AVS_NOAPPLY,
  39.         'I' => Payment_Process2::AVS_NOAPPLY,
  40.         'N' => Payment_Process2::AVS_MISMATCH,
  41.         'P' => Payment_Process2::AVS_MISMATCH,
  42.         'R' => Payment_Process2::AVS_ERROR,
  43.         'S' => Payment_Process2::AVS_ERROR,
  44.         'U' => Payment_Process2::AVS_ERROR,
  45.         'W' => Payment_Process2::AVS_MISMATCH,
  46.         'X' => Payment_Process2::AVS_MATCH,
  47.         'Y' => Payment_Process2::AVS_MATCH,
  48.         'Z' => Payment_Process2::AVS_MISMATCH,
  49.     );
  50.  
  51.     var $_avsCodeMessages = array(
  52.         '0' => 'Address and postal code match',
  53.         '1' => 'No match on street address nor postal code',
  54.         '2' => 'Only part of your address information matches',
  55.         '3' => 'Address information unavailable',
  56.         '4' => 'System unavailable or timeout',
  57.         'A' => 'Address matches, postal code does not',
  58.         'B' => 'Address matches, postal code does not',
  59.         'C' => 'No match on street address nor postal code',
  60.         'D' => 'Address and full postal code match',
  61.         'E' => 'Address verification not allowed from Internet/phone',
  62.         'F' => 'Address and full postal code match',
  63.         'G' => 'International Card Issuing Bank',
  64.         'I' => 'International Card Issuing Bank',
  65.         'N' => 'No match on street address nor postal code',
  66.         'P' => 'Postal code matches, street address does not',
  67.         'R' => 'Retry - System unavailable or timeout',
  68.         'S' => 'Service not supported by issuer',
  69.         'U' => 'Address information unavailable',
  70.         'W' => 'Full postal code matches, street address does not',
  71.         'X' => 'Address and full postal code match',
  72.         'Y' => 'Address and postal code match',
  73.         'Z' => 'Postal code matches, street address does not',
  74.     );
  75.  
  76.     var $_cvvCodeMap = array(
  77.         '0' => Payment_Process2::CVV_MATCH,
  78.         '1' => Payment_Process2::CVV_MISMATCH,
  79.         '2' => Payment_Process2::CVV_NOAPPLY,
  80.         '3' => Payment_Process2::CVV_NOAPPLY,
  81.         '4' => Payment_Process2::CVV_ERROR,
  82.         'M' => Payment_Process2::CVV_MATCH,
  83.         'N' => Payment_Process2::CVV_MISMATCH,
  84.         'P' => Payment_Process2::CVV_ERROR,
  85.         'S' => Payment_Process2::CVV_NOAPPLY,
  86.         'U' => Payment_Process2::CVV_ERROR,
  87.         'X' => Payment_Process2::CVV_ERROR,
  88.     );
  89.  
  90.     var $_cvvCodeMessages = array(
  91.         '0' => 'Security code matches',
  92.         '1' => 'Security code does not match',
  93.         '2' => 'Security code verification not supported',
  94.         '3' => 'Card does not have security code',
  95.         '4' => 'Issuer unable to process request',
  96.         'M' => 'Security code matches',
  97.         'N' => 'Security code does not match',
  98.         'P' => 'Security code was not processed',
  99.         'S' => 'Security code verification not supported',
  100.         'U' => 'Issuer unable to process request',
  101.         'X' => 'Security could not be verified',
  102.     );
  103.  
  104.     var $_fieldMap = array('0'  => 'code',
  105.                            '2'  => 'messageCode',
  106.                            '3'  => 'message',
  107.                            '4'  => 'approvalCode',
  108.                            '5'  => 'avsCode',
  109.                            '6'  => 'transactionId',
  110.                            '7'  => 'invoiceNumber',
  111.                            '8'  => 'description',
  112.                            '9'  => 'amount',
  113.                            '12' => 'customerId',
  114.                            '38' => 'cvvCode',
  115.     );
  116.  
  117.     /**
  118.      * Parses the data received from the payment gateway
  119.      *
  120.      * @access public
  121.      */
  122.     function parse()
  123.     {
  124.         $responseArray = array();
  125.  
  126.         parse_str($this->_rawResponse$responseArray);
  127.  
  128.         $this->_mapFields($responseArray);
  129.  
  130.         // Adjust result code/message if needed based on raw code
  131.         switch ($this->messageCode{
  132.             case 33:
  133.                 // Something is missing so we send the raw message back
  134.                 $this->_statusCodeMessages[33$this->message;
  135.                 break;
  136.             case 11:
  137.                 // Duplicate transactions
  138.                 $this->code = Payment_Process2::RESULT_DUPLICATE;
  139.                 break;
  140.             case 4:
  141.             case 41:
  142.             case 250:
  143.             case 251:
  144.                 // Fraud detected
  145.                 $this->code = Payment_Process2::RESULT_FRAUD;
  146.                 break;
  147.         }
  148.     }
  149.  
  150.     /**
  151.      * Parses the data received from the payment gateway callback
  152.      *
  153.      * @access public
  154.      * @todo Implement support for PayPal's IPN?
  155.      */
  156.     function parseCallback()
  157.     {
  158.         return parent::parseCallback();
  159.     }
  160.  
  161.     /**
  162.      * Validates the legitimacy of the response
  163.      *
  164.      * @return mixed TRUE if response is legitimate, FALSE if not, PEAR_Error on error
  165.      * @access public
  166.      * @todo Implement support for PayPal's IPN?
  167.      */
  168.     function isLegitimate()
  169.     {
  170.         return true;
  171.     }
  172. }

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