1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* RoboKassa driver for Omnipay PHP payment library. |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/omnipay-robokassa |
6
|
|
|
* @package omnipay-robokassa |
7
|
|
|
* @license MIT |
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Omnipay\RoboKassa\Message; |
12
|
|
|
|
13
|
|
|
use Omnipay\Common\Exception\InvalidRequestException; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* RoboKassa Abstract Request. |
17
|
|
|
*/ |
18
|
|
|
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest |
19
|
|
|
{ |
20
|
|
|
protected $zeroAmountAllowed = false; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Get the InvId |
24
|
|
|
* |
25
|
|
|
* @return integer invid. Defaults to 0 (zero) |
26
|
|
|
*/ |
27
|
|
|
public function getInvId() |
28
|
|
|
{ |
29
|
|
|
return $this->getParameter('InvId') ?? 0; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Set the InvId value. |
34
|
|
|
* |
35
|
|
|
* @param integer $invid invid |
36
|
|
|
* |
37
|
|
|
* @return self |
38
|
|
|
*/ |
39
|
|
|
public function setInvId($value) |
40
|
|
|
{ |
41
|
|
|
if (!is_numeric($value)) { |
42
|
|
|
throw new InvalidRequestException('Property InvId must be numeric'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return $this->setParameter('InvId', $value); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Get the purse. |
50
|
|
|
* |
51
|
|
|
* @return string purse |
52
|
|
|
*/ |
53
|
|
|
public function getPurse() |
54
|
|
|
{ |
55
|
|
|
return $this->getParameter('purse'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Set the purse. |
60
|
|
|
* |
61
|
|
|
* @param string $purse purse |
62
|
|
|
* |
63
|
|
|
* @return self |
64
|
|
|
*/ |
65
|
|
|
public function setPurse($value) |
66
|
|
|
{ |
67
|
|
|
return $this->setParameter('purse', $value); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getClient() |
74
|
|
|
{ |
75
|
|
|
return $this->getParameter('client'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param $value |
80
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
81
|
|
|
*/ |
82
|
|
|
public function setClient($value) |
83
|
|
|
{ |
84
|
|
|
return $this->setParameter('client', $value); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getReceipt() |
91
|
|
|
{ |
92
|
|
|
return rawurlencode($this->getParameter('receipt') ?? ''); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param $value |
97
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
98
|
|
|
*/ |
99
|
|
|
public function setReceipt($value) |
100
|
|
|
{ |
101
|
|
|
return $this->setParameter('receipt', $value); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getCurrency() |
105
|
|
|
{ |
106
|
|
|
$currency = $this->getParameter('currency'); |
107
|
|
|
if ($currency === 'RUB') { |
108
|
|
|
return ''; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
return $currency; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Get the payment currency label. |
116
|
|
|
* |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
|
|
public function getCurrencyLabel() |
120
|
|
|
{ |
121
|
|
|
return $this->getParameter('currencyLabel'); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param string $value |
126
|
|
|
* @return AbstractRequest |
127
|
|
|
*/ |
128
|
|
|
public function setCurrencyLabel($value) |
129
|
|
|
{ |
130
|
|
|
return $this->setParameter('currencyLabel', $value); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Get the secret key. |
135
|
|
|
* |
136
|
|
|
* @return string secret key |
137
|
|
|
*/ |
138
|
|
|
public function getSecretKey() |
139
|
|
|
{ |
140
|
|
|
return $this->getParameter('secretKey'); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Set the secret key. |
145
|
|
|
* |
146
|
|
|
* @param string $key secret key |
147
|
|
|
* |
148
|
|
|
* @return self |
149
|
|
|
*/ |
150
|
|
|
public function setSecretKey($value) |
151
|
|
|
{ |
152
|
|
|
return $this->setParameter('secretKey', $value); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Get the secret key for notification signing. |
157
|
|
|
* |
158
|
|
|
* @return string secret key |
159
|
|
|
*/ |
160
|
|
|
public function getSecretKey2() |
161
|
|
|
{ |
162
|
|
|
return $this->getParameter('secretKey2'); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Set the secret key for notification signing. |
167
|
|
|
* |
168
|
|
|
* @param string $value secret key |
169
|
|
|
* |
170
|
|
|
* @return self |
171
|
|
|
*/ |
172
|
|
|
public function setSecretKey2($value) |
173
|
|
|
{ |
174
|
|
|
return $this->setParameter('secretKey2', $value); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
} |
178
|
|
|
|