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. class Payment_Process_Dummy extends Payment_Process_Common {
  35.     /**
  36.      * Default options for this class.
  37.      *
  38.      * @access private
  39.      * @type array
  40.      * @see Payment_Process::setOptions()
  41.      */
  42.     var $_defaultOptions = array(
  43.         'randomResult' => true,
  44.         'returnCode' => PAYMENT_PROCESS_RESULT_APPROVED,
  45.         'returnMessage' => "Dummy payment approved"
  46.     );
  47.  
  48.     var $_returnValues = array(
  49.         array(
  50.             'code' => PAYMENT_PROCESS_RESULT_APPROVED,
  51.             'message' => "Approved"
  52.         ),
  53.         array(
  54.             'code' => PAYMENT_PROCESS_RESULT_DECLINED,
  55.             'message' => "Declined"
  56.         ),
  57.         array(
  58.             'code' => PAYMENT_PROCESS_RESULT_OTHER,
  59.             'message' => "System error"
  60.         )
  61.     );
  62.  
  63.     /**
  64.      * Process the (dummy) transaction
  65.      *
  66.      * @return mixed  Payment_Process_Result instance or PEAR_Error
  67.      */
  68.     function &process()
  69.     {
  70.         // Sanity check
  71.         if (PEAR::isError($res $this->validate())) {
  72.             return($res);
  73.         }
  74.  
  75.         if ($this->_options['randomResult']{
  76.             srand(microtime());
  77.             $n rand(0count($this->_returnValues- 1);
  78.             $code &$this->_returnValues[$n]['code'];
  79.             $message &$this->_returnValues[$n]['message'];
  80.         else {
  81.             $code &$this->_options['returnCode'];
  82.             $message &$this->_options['returnMessage'];
  83.         }
  84.  
  85.         return Payment_Process_Result::factory('Dummy');
  86.     }
  87. }
  88.  
  89.     function Payment_Process_Result_Dummy()
  90.     {
  91.     }
  92. }
  93. ?>

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