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

Source for file Dummy.php

Documentation is available at Dummy.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at                              |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Ian Eure <ieure@php.net>                                    |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Dummy.php,v 1.6 2004/03/22 20:35:58 ieure Exp $
  20.  
  21. require_once 'Payment/Process/Common.php';
  22.  
  23. /**
  24.  * Payment_PAYMENT_PROCESS_Dummy
  25.  *
  26.  * A dummy processor for offline testing. It can be made to return different
  27.  * result codes and messages for testing purposes.
  28.  *
  29.  * @package Payment_Process
  30.  * @category Payment
  31.  * @author Ian Eure <ieure@php.net>
  32.  * @version @version@
  33.  */
  34.     /**
  35.      * Default options for this class.
  36.      *
  37.      * @access private
  38.      * @type array
  39.      * @see Payment_Process::setOptions()
  40.      */
  41.     var $_defaultOptions = array(
  42.         'randomResult' => true,
  43.         'returnCode' => PAYMENT_PROCESS_RESULT_APPROVED,
  44.         'returnMessage' => "Dummy payment approved"
  45.     );
  46.  
  47.     var $_returnValues = array(
  48.         array(
  49.             'code' => PAYMENT_PROCESS_RESULT_APPROVED,
  50.             'message' => "Approved"
  51.         ),
  52.         array(
  53.             'code' => PAYMENT_PROCESS_RESULT_DECLINED,
  54.             'message' => "Declined"
  55.         ),
  56.         array(
  57.             'code' => PAYMENT_PROCESS_RESULT_OTHER,
  58.             'message' => "System error"
  59.         )
  60.     );
  61.  
  62.     /**
  63.      * Process the (dummy) transaction
  64.      *
  65.      * @return mixed  Payment_Process_Result instance or PEAR_Error
  66.      */
  67.     function &process()
  68.     {
  69.         // Sanity check
  70.         if (PEAR::isError($res $this->validate())) {
  71.             return($res);
  72.         }
  73.  
  74.         if ($this->_options['randomResult']{
  75.             srand(microtime());
  76.             $n rand(0count($this->_returnValues- 1);
  77.             $code &$this->_returnValues[$n]['code'];
  78.             $message &$this->_returnValues[$n]['message'];
  79.         else {
  80.             $code &$this->_options['returnCode'];
  81.             $message &$this->_options['returnMessage'];
  82.         }
  83.  
  84.         return Payment_Process_Result::factory('Dummy');
  85.     }
  86. }
  87.  
  88.     function Payment_Process_Result_Dummy()
  89.     {
  90.     }
  91. }
  92. ?>

Documentation generated on Mon, 11 Mar 2019 14:00:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.