| // +----------------------------------------------------------------------+ // // $Id: Dummy.php,v 1.6 2004/03/22 20:35:58 ieure Exp $ require_once 'Payment/Process/Common.php'; /** * Payment_PAYMENT_PROCESS_Dummy * * A dummy processor for offline testing. It can be made to return different * result codes and messages for testing purposes. * * @package Payment_Process * @category Payment * @author Ian Eure * @version @version@ */ class Payment_Process_Dummy extends Payment_Process_Common { /** * Default options for this class. * * @access private * @type array * @see Payment_Process::setOptions() */ var $_defaultOptions = array( 'randomResult' => true, 'returnCode' => PAYMENT_PROCESS_RESULT_APPROVED, 'returnMessage' => "Dummy payment approved" ); var $_returnValues = array( array( 'code' => PAYMENT_PROCESS_RESULT_APPROVED, 'message' => "Approved" ), array( 'code' => PAYMENT_PROCESS_RESULT_DECLINED, 'message' => "Declined" ), array( 'code' => PAYMENT_PROCESS_RESULT_OTHER, 'message' => "System error" ) ); /** * Process the (dummy) transaction * * @return mixed Payment_Process_Result instance or PEAR_Error */ function &process() { // Sanity check if (PEAR::isError($res = $this->validate())) { return($res); } if ($this->_options['randomResult']) { srand(microtime()); $n = rand(0, count($this->_returnValues) - 1); $code = &$this->_returnValues[$n]['code']; $message = &$this->_returnValues[$n]['message']; } else { $code = &$this->_options['returnCode']; $message = &$this->_options['returnMessage']; } return Payment_Process_Result::factory('Dummy'); } } class Payment_Process_Result_Dummy extends Payment_Process_Result { function __construct() { } } ?>