Source for file Result.php
Documentation is available at Result.php
require_once 'Payment/Process2/Exception.php';
require_once 'Payment/Process2/Common.php';
* Payment_Process2_Result
* The core result class that should be returned from each driver's process()
* function. This should be exte33nded as Payment_Process2_Result_DriverName and
* then have the appropriate fields mapped out accordingly.
* Take special care to appropriately create a parse() function in your result
* class. You can then call _mapFields() with a resultArray (ie. exploded
* result) to map your results from parse() into the member variables.
* Please note that this class keeps your original codes intact so they can
* be accessed directly and then uses the function wrappers to return uniform
* @package Payment_Process2
* @author Joe Stump <joe@joestump.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: @package_version@
* @link http://pear.php.net/package/Payment_Process2
* Processor instance which this result was instantiated from.
* This should contain a reference to the requesting Processor.
* @author Ian Eure <ieure@php.net>
* @author Joe Stump <joe@joestump.net>
* @var string $_rawResponse
* The approval/decline code
* The value returned by your gateway as approved/declined should be mapped
* into this variable. Valid results should then be mapped into the
* appropriate Payment_Process2::RESULT_* code using the $_statusCodeMap
* array. Values returned into $code should be mapped as keys in the map
* with Payment_Process2::RESULT_* as the values.
* @author Joe Stump <joe@joestump.net>
* @see Payment_Process2::RESULT_APPROVED, Payment_Process2::RESULT_DECLINED
* @see Payment_Process2::RESULT_OTHER, $_statusCodeMap
* Along with the response (yes/no) you usually get a response/message
* code that translates into why it was approved/declined. This is where
* you map that code into. Your $_statusCodeMessages would then be keyed by
* valid messageCode values.
* @author Joe Stump <joe@joestump.net>
* @var mixed $messageCode
* @see $_statusCodeMessages
* Map the textual message from the gateway into this variable. It is not
* currently returned or used (in favor of the $_statusCodeMessages map, but
* can be accessed directly for debugging purposes.
* @author Joe Stump <joe@joestump.net>
* @see $_statusCodeMessages
* Authorization/Approval code
* @author Joe Stump <joe@joestump.net>
* @var string $approvalCode
* Address verification code
* The AVS code returned from your gateway. This should then be mapped to
* the appropriate Payment_Process2::AVS_* code using $_avsCodeMap. This value
* should also be mapped to the appropriate textual message via the
* $_avsCodeMessages array.
* @author Joe Stump <joe@joestump.net>
* @see Payment_Process2::AVS_MISMATCH, Payment_Process2::AVS_ERROR
* @see Payment_Process2::AVS_MATCH, Payment_Process2::AVS_NOAPPLY, $_avsCodeMap
* This is the unique transaction ID, which is used by gateways to modify
* transactions (credit, update, etc.). Map the appropriate value into this
* @author Joe Stump <joe@joestump.net>
* @var string $transactionId
* Unique internal invoiceNumber (ie. your company's order/invoice number
* that you assign each order as it is processed). It is always a good idea
* to pass this to the gateway (which is usually then echo'd back).
* @author Joe Stump <joe@joestump.net>
* @var string $invoiceNumber
* Unique internal customer ID (ie. your company's customer ID used to
* track individual customers).
* @author Joe Stump <joe@joestump.net>
* @var string $customerId
* The CVV code is the 3-4 digit number on the back of most credit cards.
* This value should be mapped via the $_cvvCodeMap variable to the
* appropriate Payment_Process2::CVV_* values.
* @author Joe Stump <joe@joestump.net>
var $cvvCode = Payment_Process2 ::CVV_NOAPPLY;
* Your cvvCode value should be mapped to appropriate messages via the
* $_cvvCodeMessage array. This value is merely here to hold the value
* returned from the gateway (if any).
* @author Joe Stump <joe@joestump.net>
* @var string $cvvMessage
var $_avsCodeMap = array ();
var $_cvvCodeMap = array ();
* @param string $rawResponse Raw response
* @param Payment_Process2_Common $request Request
function __construct($rawResponse, Payment_Process2_Common $request)
$this->_request = $request;
* @param string $type Type
* @param string $rawResponse Raw response
* @param Payment_Process2_Common $request Request
* @return Payment_Process2_Result
* @throws Payment_Process2_Exception
* @author Joe Stump <joe@joestump.net>
* @author Ian Eure <ieure@php.net>
function factory($type, $rawResponse, Payment_Process2_Common $request)
$class = 'Payment_Process2_Result_'. $type;
$path = 'Payment/Process2/Result/'. $type. '.php';
$ret = new $class($rawResponse, $request);
throw new Payment_Process2_Exception ('Invalid response type: '. $type. '('. $class. ')');
* @author Joe Stump <joe@joestump.net>
$request = $this->_request;
$payment = $request->_payment;
if ($request->getOption ('avsCheck') === true ) {
throw new Payment_Process2_Exception ('AVS check failed',
if ($request->getOption ('cvvCheck') === true &&
throw new Payment_Process2_Exception ('CVV check failed',
throw new Payment_Process2_Exception ($this->getMessage(),
* @return integer one of Payment_Process2::RESULT_* constant
* @author Joe Stump <joe@joestump.net>
if (isset ($this->_statusCodeMap[$this->code])) {
return $this->_statusCodeMap[$this->code];
* Return the message from the code map, or return the raw message if
* there is one. Otherwise, return a worthless message.
* @author Joe Stump <joe@joestump.net>
if (isset ($this->_statusCodeMessages[$this->messageCode])) {
return 'No message reported';
* @return integer one of Payment_Process2::AVS_* constants
return isset ($this->_avsCodeMap[$this->avsCode]) ? $this->_avsCodeMap[$this->avsCode] : null;
* Returns the AVS message
return isset ($this->_avsCodeMessages[$this->avsCode]) ? $this->_avsCodeMessages[$this->avsCode] : null;
* Return the CVV match code
* @todo Think if this should raise exceptions for unknown cvvcode?
* @return integer One of Payment_Process2::CVV_* constants or null
return isset ($this->_cvvCodeMap[$this->cvvCode])? $this->_cvvCodeMap[$this->cvvCode] : null;
* Returns the CVV match message
return $this->_cvvCodeMessages[$this->cvvCode];
* @param mixed $responseArray Response array
* @author Joe Stump <joe@joestump.net>
function _mapFields ($responseArray)
foreach ($this->_fieldMap as $key => $val) {
* @param object $object Object to accept
* @return boolean TRUE if accepted, FALSE otherwise
if (is_a($object, 'Log')) {
* @param string $message Message to log
* @param string $priority Message priority
* @return mixed Return value of Log::log(), or false if no Log instance
function log($message, $priority = null )
if (isset ($this->_log) && is_object($this->_log)) {
return $this->_log->log ($message, $priority);
Documentation generated on Mon, 11 Mar 2019 15:40:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|