|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Omnipay\SmartPay\Message; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
|
6
|
|
|
use Omnipay\Common\Message\AbstractRequest; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Omnipay Bank Muscat Purchase Request |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
class PurchaseRequest extends AbstractRequest { |
|
13
|
|
|
|
|
14
|
|
|
const EP_HOST_TEST = 'https://spayuattrns.bmtest.om/transaction.do?command=initiateTransaction'; |
|
15
|
|
|
const EP_HOST_LIVE = 'https://smartpaytrns.bankmuscat.com/transaction.do?command=initiateTransaction'; |
|
16
|
|
|
|
|
17
|
|
|
public function initialize(array $parameters = []) |
|
18
|
|
|
{ |
|
19
|
|
|
return parent::initialize($parameters); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function getMerchantId() |
|
23
|
|
|
{ |
|
24
|
|
|
return $this->getParameter('merchantId'); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function setMerchantId($merchantId) |
|
28
|
|
|
{ |
|
29
|
|
|
return $this->setParameter('merchantId', $merchantId); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getAccessCode() |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->getParameter('accessCode'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function setAccessCode($accessCode) |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->setParameter('accessCode', $accessCode); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getWorkingKey() |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->getParameter('workingKey'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function setWorkingKey($workingKey) |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->setParameter('workingKey', $workingKey); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function getOrderId() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->getParameter('orderId'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function setOrderId($orderId) |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->setParameter('orderId', $orderId); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getMerchantParameter1() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->getParameter('merchantParameter1'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function setMerchantParameter1($parameter) |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->setParameter('merchantParameter1', $parameter); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getMerchantParameter2() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->getParameter('merchantParameter2'); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function setMerchantParameter2($parameter) |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->setParameter('merchantParameter2', $parameter); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getMerchantParameter3() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->getParameter('merchantParameter3'); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function setMerchantParameter3($parameter) |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->setParameter('merchantParameter3', $parameter); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function getMerchantParameter4() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->getParameter('merchantParameter4'); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function setMerchantParameter4($parameter) |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->setParameter('merchantParameter4', $parameter); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function getMerchantParameter5() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->getParameter('merchantParameter5'); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function setMerchantParameter5($parameter) |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->setParameter('merchantParameter5', $parameter); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function setBillingName($billingName) |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->setParameter('billingName', $billingName); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function getBillingName() |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->getParameter('billingName'); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function setBillingAddress($billingAddress) |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->setParameter('billingAddress', $billingAddress); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function getBillingAddress() |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->getParameter('billingAddress'); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function setBillingCity($billingCity) |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->setParameter('billingCity', $billingCity); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function getBillingCity() |
|
138
|
|
|
{ |
|
139
|
|
|
return $this->getParameter('billingCity'); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function setBillingState($billingState) |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->setParameter('billingState', $billingState); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function getBillingState() |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->getParameter('billingState'); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function setBillingZip($billingZip) |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->setParameter('billingZip', $billingZip); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function getBillingZip() |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->getParameter('billingZip'); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
public function setBillingCountry($billingCountry) |
|
163
|
|
|
{ |
|
164
|
|
|
return $this->setParameter('billingCountry', $billingCountry); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
public function getBillingCountry() |
|
168
|
|
|
{ |
|
169
|
|
|
return $this->getParameter('billingCountry'); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function setBillingEmail($billingEmail) |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->setParameter('billingEmail', $billingEmail); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function getBillingEmail() |
|
178
|
|
|
{ |
|
179
|
|
|
return $this->getParameter('billingEmail'); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
public function setBillingTel($billingTel) |
|
183
|
|
|
{ |
|
184
|
|
|
return $this->setParameter('billingTel', $billingTel); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function getBillingTel() |
|
188
|
|
|
{ |
|
189
|
|
|
return $this->getParameter('billingTel'); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Get data |
|
194
|
|
|
* |
|
195
|
|
|
* @access public |
|
196
|
|
|
* @return array |
|
197
|
|
|
*/ |
|
198
|
|
|
public function getData() |
|
199
|
|
|
{ |
|
200
|
|
|
$this->validate( |
|
201
|
|
|
'merchantId', 'accessCode', 'workingKey', |
|
202
|
|
|
'amount', 'currency', 'returnUrl', 'cancelUrl' |
|
203
|
|
|
); |
|
204
|
|
|
|
|
205
|
|
|
$data = []; |
|
206
|
|
|
|
|
207
|
|
|
$data['merchant_id'] = $this->getMerchantId(); |
|
208
|
|
|
$data['access_code'] = $this->getAccessCode(); |
|
209
|
|
|
$data['amount'] = $this->getAmount(); |
|
210
|
|
|
$data['currency'] = $this->getCurrency(); |
|
211
|
|
|
$data['order_id'] = $this->getTransactionId(); |
|
212
|
|
|
$data['redirect_url'] = $this->getReturnUrl(); |
|
213
|
|
|
$data['cancel_url'] = $this->getCancelUrl(); |
|
214
|
|
|
$data['merchant_param1'] = $this->getMerchantParameter1(); |
|
215
|
|
|
$data['merchant_param2'] = $this->getMerchantParameter2(); |
|
216
|
|
|
$data['merchant_param3'] = $this->getMerchantParameter3(); |
|
217
|
|
|
$data['merchant_param4'] = $this->getMerchantParameter4(); |
|
218
|
|
|
$data['merchant_param5'] = $this->getMerchantParameter5(); |
|
219
|
|
|
$data['billing_name'] = $this->getBillingName(); |
|
220
|
|
|
$data['billing_address'] = $this->getBillingAddress(); |
|
221
|
|
|
$data['billing_city'] = $this->getBillingCity(); |
|
222
|
|
|
$data['billing_state'] = $this->getBillingState(); |
|
223
|
|
|
$data['billing_zip'] = $this->getBillingZip(); |
|
224
|
|
|
$data['billing_country'] = $this->getBillingCountry(); |
|
225
|
|
|
$data['billing_email'] = $this->getBillingEmail(); |
|
226
|
|
|
$data['billing_tel'] = $this->getBillingTel(); |
|
227
|
|
|
$data['customer_email'] = '[email protected]'; |
|
228
|
|
|
|
|
229
|
|
|
if ( $this->getCard() ) { |
|
230
|
|
|
$data['card_number'] = $this->getCard()->getNumber(); |
|
231
|
|
|
$data['expiry_month'] = $this->getCard()->getExpiryMonth(); |
|
232
|
|
|
$data['expiry_year'] = $this->getCard()->getExpiryYear(); |
|
233
|
|
|
$data['cvv_number'] = $this->getCard()->getCvv(); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
return $data; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* Send data |
|
241
|
|
|
* |
|
242
|
|
|
* @param array $data Data |
|
243
|
|
|
* |
|
244
|
|
|
* @access public |
|
245
|
|
|
* @return PurchaseResponse |
|
246
|
|
|
*/ |
|
247
|
|
|
public function sendData($data) |
|
248
|
|
|
{ |
|
249
|
|
|
$merchant_data = []; |
|
250
|
|
|
|
|
251
|
|
|
foreach ( $this->getData() as $k => $v ) { |
|
252
|
|
|
if ( !empty($v) ) { |
|
253
|
|
|
$merchant_data[$k] = urlencode($v); |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
$merchant_data['redirect_url'] = $this->getReturnUrl(); |
|
258
|
|
|
$merchant_data['cancel_url'] = $this->getCancelUrl(); |
|
259
|
|
|
|
|
260
|
|
|
$cryto = new Crypto(); |
|
261
|
|
|
|
|
262
|
|
|
$encrypted_data = $cryto->encrypt(http_build_query($merchant_data), $this->getWorkingKey()); |
|
263
|
|
|
|
|
264
|
|
|
$url = $this->getEndpoint() . '&encRequest=' . $encrypted_data . '&access_code=' . $this->getAccessCode(); |
|
265
|
|
|
|
|
266
|
|
|
return $this->response = new PurchaseResponse($this, [ |
|
267
|
|
|
'url' => $url, |
|
268
|
|
|
'endpoint' => $this->getEndpoint(), |
|
269
|
|
|
'enc_request' => $encrypted_data, |
|
270
|
|
|
'access_code' => $this->getAccessCode(), |
|
271
|
|
|
'merchant_data' => $merchant_data |
|
272
|
|
|
]); |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* Get endpoint |
|
277
|
|
|
* |
|
278
|
|
|
* Returns endpoint depending on test mode |
|
279
|
|
|
* |
|
280
|
|
|
* @access protected |
|
281
|
|
|
* @return string |
|
282
|
|
|
*/ |
|
283
|
|
|
protected function getEndpoint() |
|
284
|
|
|
{ |
|
285
|
|
|
return ($this->getTestMode() ? self::EP_HOST_TEST : self::EP_HOST_LIVE); |
|
286
|
|
|
} |
|
287
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths