1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* InterKassa driver for the Omnipay PHP payment processing library |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/ange007/omnipay-interkassa |
7
|
|
|
* @package omnipay-interkassa |
8
|
|
|
* @license MIT |
9
|
|
|
* @copyright Copyright (c) 2017, ange007 ( original author: HiQDev - http://hiqdev.com/ ) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Omnipay\InterKassa; |
13
|
|
|
|
14
|
|
|
use Omnipay\Common\AbstractGateway; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Gateway for InterKassa Shop Cart Interface. |
18
|
|
|
* http://interkassa.com/. |
19
|
|
|
*/ |
20
|
|
|
class Gateway extends AbstractGateway |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
public function getName( ) |
27
|
|
|
{ |
28
|
|
|
return 'InterKassa'; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
|
|
public function getDefaultParameters( ) |
35
|
|
|
{ |
36
|
|
|
return [ |
37
|
|
|
'checkoutId' => '', |
38
|
|
|
'signAlgorithm' => 'md5', |
39
|
|
|
'signKey' => '', |
40
|
|
|
'testKey' => '', |
41
|
|
|
'testMode' => false, |
42
|
|
|
]; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Get the unified purse. |
47
|
|
|
* |
48
|
|
|
* @return string merchant purse |
49
|
|
|
*/ |
50
|
|
|
public function getPurse( ) |
51
|
|
|
{ |
52
|
|
|
return $this->getCheckoutId( ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Set the unified purse. |
57
|
|
|
* |
58
|
|
|
* @param $value |
59
|
|
|
* @return self |
60
|
|
|
*/ |
61
|
|
|
public function setPurse( $value ) |
62
|
|
|
{ |
63
|
|
|
return $this->setCheckoutId( $value ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get the unified secret. |
68
|
|
|
* @return string merchant secret - sign key |
69
|
|
|
*/ |
70
|
|
|
public function getSecret( ) |
71
|
|
|
{ |
72
|
|
|
return $this->getSignKey( ); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Set the unified secret. |
77
|
|
|
* @param string $value merchant secret - sign key |
78
|
|
|
* @return self |
79
|
|
|
*/ |
80
|
|
|
public function setSecret( $value ) |
81
|
|
|
{ |
82
|
|
|
return $this->setSignKey( $value ); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get the merchant purse. |
87
|
|
|
* |
88
|
|
|
* @return string merchant purse |
89
|
|
|
*/ |
90
|
|
|
public function getCheckoutId( ) |
91
|
|
|
{ |
92
|
|
|
return $this->getParameter( 'checkoutId' ); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Set the merchant purse. |
97
|
|
|
* |
98
|
|
|
* @param string $value merchant purse |
99
|
|
|
* |
100
|
|
|
* @return self |
101
|
|
|
*/ |
102
|
|
|
public function setCheckoutId( $value ) |
103
|
|
|
{ |
104
|
|
|
return $this->setParameter( 'checkoutId', $value ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Get the sign algorithm. |
109
|
|
|
* |
110
|
|
|
* @return string sign algorithm |
111
|
|
|
*/ |
112
|
|
|
public function getSignAlgorithm( ) |
113
|
|
|
{ |
114
|
|
|
return $this->getParameter( 'signAlgorithm' ); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Set the sign algorithm. |
119
|
|
|
* |
120
|
|
|
* @param string $value sign algorithm |
121
|
|
|
* |
122
|
|
|
* @return self |
123
|
|
|
*/ |
124
|
|
|
public function setSignAlgorithm( $value ) |
125
|
|
|
{ |
126
|
|
|
return $this->setParameter( 'signAlgorithm', $value ); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Get the sign key. |
131
|
|
|
* |
132
|
|
|
* @return string sign key |
133
|
|
|
*/ |
134
|
|
|
public function getSignKey( ) |
135
|
|
|
{ |
136
|
|
|
return $this->getParameter( 'signKey' ); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set the sign key. |
141
|
|
|
* |
142
|
|
|
* @param string $value sign key |
143
|
|
|
* |
144
|
|
|
* @return self |
145
|
|
|
*/ |
146
|
|
|
public function setSignKey( $value ) |
147
|
|
|
{ |
148
|
|
|
return $this->setParameter( 'signKey', $value ); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Get the test key. |
153
|
|
|
* |
154
|
|
|
* @return string test key |
155
|
|
|
*/ |
156
|
|
|
public function getTestKey( ) |
157
|
|
|
{ |
158
|
|
|
return $this->getParameter( 'testKey' ); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Set the test key. |
163
|
|
|
* |
164
|
|
|
* @param string $value test key |
165
|
|
|
* |
166
|
|
|
* @return self |
167
|
|
|
*/ |
168
|
|
|
public function setTestKey( $value ) |
169
|
|
|
{ |
170
|
|
|
return $this->setParameter( 'testKey', $value ); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param array $parameters |
175
|
|
|
* |
176
|
|
|
* @return \Omnipay\InterKassa\Message\PurchaseReques |
177
|
|
|
*/ |
178
|
|
|
public function purchase( array $parameters = [] ) |
179
|
|
|
{ |
180
|
|
|
$requestClass = '\Omnipay\InterKassa\Message\PurchaseRequest'; |
181
|
|
|
|
182
|
|
|
return $this->createRequest( $requestClass, $parameters ); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param array $parameters |
187
|
|
|
* |
188
|
|
|
* @return \Omnipay\InterKassa\Message\CompletePurchaseRequest |
189
|
|
|
*/ |
190
|
|
|
public function completePurchase( array $parameters = [] ) |
191
|
|
|
{ |
192
|
|
|
$requestClass = '\Omnipay\InterKassa\Message\CompletePurchaseRequest'; |
193
|
|
|
|
194
|
|
|
return $this->createRequest( $requestClass, $parameters ); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @param array $parameters |
199
|
|
|
* |
200
|
|
|
* @return \Omnipay\InterKassa\Message\NotificationRequest |
201
|
|
|
*/ |
202
|
|
|
public function acceptNotification( array $parameters = [] ) |
203
|
|
|
{ |
204
|
|
|
$requestClass = '\Omnipay\InterKassa\Message\NotificationRequest'; |
205
|
|
|
|
206
|
|
|
return $this->createRequest( $requestClass, $parameters ); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
} |
210
|
|
|
|