-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
188 lines (88 loc) · 3.29 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Ian Eure <[email protected]> |
// +----------------------------------------------------------------------+
//
// $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 <[email protected]>
* @version @version@
*/
class Payment_Process_Dummy extends Payment_Process_Common {
/**
* Default options for this class group.
*
* @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",
'newtest' => "Pass"
),
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 Payment_Process_Result_Dummy()
{
}
}
?>