1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* InterKassa driver for the Omnipay PHP payment processing library |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/omnipay-interkassa |
7
|
|
|
* @package omnipay-interkassa |
8
|
|
|
* @license MIT |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Omnipay\InterKassa\Message; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* InterKassa Abstract Request. |
16
|
|
|
*/ |
17
|
|
|
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* {@inheritdoc} |
21
|
|
|
*/ |
22
|
|
|
protected $zeroAmountAllowed = false; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $endpoint = 'https://sci.interkassa.com/'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Get the unified purse. |
31
|
|
|
* |
32
|
|
|
* @return string merchant purse |
33
|
|
|
*/ |
34
|
6 |
|
public function getPurse() |
35
|
|
|
{ |
36
|
6 |
|
return $this->getCheckoutId(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Set the unified purse. |
41
|
|
|
* |
42
|
|
|
* @param $value |
43
|
|
|
* @return self |
44
|
|
|
*/ |
45
|
19 |
|
public function setPurse($value) |
46
|
|
|
{ |
47
|
19 |
|
return $this->setCheckoutId($value); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get the merchant purse. |
52
|
|
|
* |
53
|
|
|
* @return string merchant purse |
54
|
|
|
*/ |
55
|
9 |
|
public function getCheckoutId() |
56
|
|
|
{ |
57
|
9 |
|
return $this->getParameter('checkoutId'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Set the merchant purse. |
62
|
|
|
* |
63
|
|
|
* @param string $purse merchant purse |
64
|
|
|
* |
65
|
|
|
* @return self |
66
|
|
|
*/ |
67
|
19 |
|
public function setCheckoutId($purse) |
68
|
|
|
{ |
69
|
19 |
|
return $this->setParameter('checkoutId', $purse); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get the secret. |
74
|
|
|
* |
75
|
|
|
* @return string secret key |
76
|
|
|
*/ |
77
|
15 |
|
public function getSecret() |
78
|
|
|
{ |
79
|
15 |
|
return $this->getParameter('secret'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set the secret. |
84
|
|
|
* |
85
|
|
|
* @param string $key secret key |
86
|
|
|
* |
87
|
|
|
* @return self |
88
|
|
|
*/ |
89
|
25 |
|
public function setSecret($key) |
90
|
|
|
{ |
91
|
25 |
|
return $this->setParameter('secret', $key); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Get the method for success return. |
96
|
|
|
* |
97
|
|
|
* @return mixed |
98
|
|
|
*/ |
99
|
3 |
|
public function getReturnMethod() |
100
|
|
|
{ |
101
|
3 |
|
return $this->getParameter('returnMethod'); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Sets the method for success return. |
106
|
|
|
* |
107
|
|
|
* @param $returnMethod |
108
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
109
|
|
|
*/ |
110
|
1 |
|
public function setReturnMethod($returnMethod) |
111
|
|
|
{ |
112
|
1 |
|
return $this->setParameter('returnMethod', $returnMethod); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get the method for canceled payment return. |
117
|
|
|
* |
118
|
|
|
* @return mixed |
119
|
|
|
*/ |
120
|
3 |
|
public function getCancelMethod() |
121
|
|
|
{ |
122
|
3 |
|
return $this->getParameter('returnMethod'); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Sets the method for canceled payment return. |
127
|
|
|
* |
128
|
|
|
* @param $cancelMethod |
129
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
130
|
|
|
*/ |
131
|
1 |
|
public function setCancelMethod($cancelMethod) |
132
|
|
|
{ |
133
|
1 |
|
return $this->setParameter('cancelMethod', $cancelMethod); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Get the method for request notify. |
138
|
|
|
* |
139
|
|
|
* @return mixed |
140
|
|
|
*/ |
141
|
3 |
|
public function getNotifyMethod() |
142
|
|
|
{ |
143
|
3 |
|
return $this->getParameter('notifyMethod'); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Sets the method for request notify. |
148
|
|
|
* |
149
|
|
|
* @param $notifyMethod |
150
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
151
|
|
|
*/ |
152
|
1 |
|
public function setNotifyMethod($notifyMethod) |
153
|
|
|
{ |
154
|
1 |
|
return $this->setParameter('notifyMethod', $notifyMethod); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Calculates sign for the $data. |
159
|
|
|
* |
160
|
|
|
* @param array $data |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
5 |
View Code Duplication |
public function calculateSign($data) |
|
|
|
|
164
|
|
|
{ |
165
|
5 |
|
unset($data['ik_sign']); |
166
|
5 |
|
ksort($data, SORT_STRING); |
167
|
5 |
|
array_push($data, $this->getSecret()); |
168
|
5 |
|
$signString = implode(':', $data); |
169
|
5 |
|
$sign = base64_encode(hash('sha256', $signString, true)); |
170
|
5 |
|
return $sign; |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.