-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinterkassa.php
More file actions
129 lines (112 loc) · 3.02 KB
/
interkassa.php
File metadata and controls
129 lines (112 loc) · 3.02 KB
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
<?php
/**
* Interkassa API for PHP
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT-style license
* @package Interkassa
* @author Anton Suprun <kpobococ@gmail.com>
* @author Odarchenko N.D. <odarchenko.n.d@gmail.com>
* @author Bohdan Yurov <bogdan@yurov.me>
* @author liberulo <odesskij1992@gmail.com>
* @author Oleksii Mylotskyi <spalaxinco@gmail.com>
* @version 1.0.0
*/
/**
* Interkassa base class
*
* This class is used to initialize the library and also contains several
* constants.
*
* @license MIT-style license
* @package Interkassa
* @author Anton Suprun <kpobococ@gmail.com>
* @version 1.0.0
*/
class Interkassa
{
/**#@+
* URL method constant
*
* @see Interkassa_Payment::setSuccessMethod()
* @see Interkassa_Payment::setFailMethod()
* @see Interkassa_Payment::setStatusMethod()
*/
const METHOD_GET = 'GET';
const METHOD_POST = 'POST';
const METHOD_LINK = 'LINK';
const METHOD_OFF = 'OFF';
/**#@-*/
/**#@+
* State constant
*
* @see Interkassa_Status::getState()
*/
const STATE_SUCCESS = 'success';
const STATE_FAIL = 'fail';
/**#@-*/
/**#@+
* Fees payer constant
*
* @see Interkassa_Status::getFeesPayer()
*/
const FEES_PAYER_SHOP = 0;
const FEES_PAYER_BUYER = 1;
const FEES_PAYER_EQUAL = 2;
/**#@-*/
/**#@+
* Payment action constant
*
* @see Interkassa_Payment::setAction()
*/
const ACTION_PROCESS = 'process';
const ACTION_PAYWAYS = 'payways';
const ACTION_PAYWAY = 'payway';
/**#@-*/
/**#@+
* Payment interface constant
*/
const INTERFACE_WEB = 'web';
const INTERFACE_JSON = 'json';
/**#@-*/
/**
* Registers library autoloader as an SPL autoloader.
*/
public static function register()
{
ini_set('unserialize_callback_func', 'spl_autoload_call');
spl_autoload_register(array('Interkassa', 'autoload'));
}
/**
* Autoload method.
*
* Handles autoloading of classes.
*
* @param string $class class name
*
* @return boolean true if class has been loaded, false otherwise
*/
public static function autoload($class)
{
if (class_exists($class, false) || interface_exists($class, false))
return true;
if (strpos($class, 'Interkassa_') !== 0)
return false;
$dir = dirname(__FILE__);
$bits = explode('_', $class);
if (!function_exists('lcfirst'))
foreach ($bits as $i => $bit)
$bits[$i] = strtolower($bit[0]) . substr($bit, 1);
else
$bits = array_map('lcfirst', $bits);
$file = $dir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $bits) . '.php';
if (file_exists($file))
{
require $file;
return class_exists($class, false) || interface_exists($class, false);
}
return false;
}
}