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_LIVE = 'https://mti.bankmuscat.com:6443/transaction.do?command=initiateTransaction'; |
15
|
|
|
const EP_HOST_TEST = '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
|
|
|
/** |
113
|
|
|
* Get data |
114
|
|
|
* |
115
|
|
|
* @access public |
116
|
|
|
* @return array |
117
|
|
|
*/ |
118
|
|
|
public function getData() |
119
|
|
|
{ |
120
|
|
|
$this->validate( |
121
|
|
|
'merchantId', 'accessCode', 'workingKey', |
122
|
|
|
'amount', 'currency', 'returnUrl', 'cancelUrl' |
123
|
|
|
); |
124
|
|
|
|
125
|
|
|
$data = []; |
126
|
|
|
|
127
|
|
|
$data['merchant_id'] = $this->getMerchantId(); |
128
|
|
|
$data['access_code'] = $this->getAccessCode(); |
129
|
|
|
$data['tid'] = $this->getTransactionId(); |
130
|
|
|
$data['amount'] = $this->getAmount(); |
131
|
|
|
$data['currency'] = $this->getCurrency(); |
132
|
|
|
$data['order_id'] = $this->getOrderId(); |
133
|
|
|
$data['redirect_url'] = $this->getReturnUrl(); |
134
|
|
|
$data['cancel_url'] = $this->getCancelUrl(); |
135
|
|
|
$data['merchant_param1'] = $this->getMerchantParameter1(); |
136
|
|
|
$data['merchant_param2'] = $this->getMerchantParameter2(); |
137
|
|
|
$data['merchant_param3'] = $this->getMerchantParameter3(); |
138
|
|
|
$data['merchant_param4'] = $this->getMerchantParameter4(); |
139
|
|
|
$data['merchant_param5'] = $this->getMerchantParameter5(); |
140
|
|
|
|
141
|
|
|
return $data; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Send data |
146
|
|
|
* |
147
|
|
|
* @param array $data Data |
148
|
|
|
* |
149
|
|
|
* @access public |
150
|
|
|
* @return PurchaseResponse |
151
|
|
|
*/ |
152
|
|
|
public function sendData($data) |
153
|
|
|
{ |
154
|
|
|
$merchant_data = []; |
155
|
|
|
|
156
|
|
|
foreach ( $this->getData() as $k => $v ) { |
157
|
|
|
if ( !empty($v) ) { |
158
|
|
|
$merchant_data[$k] = urlencode($v); |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
$cryto = new Crypto(); |
163
|
|
|
|
164
|
|
|
$encrypted_data = $cryto->encrypt(http_build_query($merchant_data), $this->getWorkingKey()); |
165
|
|
|
|
166
|
|
|
$url = $this->getEndpoint() . '&encRequest=' . $encrypted_data . '&access_code=' . $this->getAccessCode(); |
167
|
|
|
|
168
|
|
|
// echo '<pre>'; print_r([ |
169
|
|
|
// 'data' => $this->getData(), |
170
|
|
|
// 'merchant_data' => $merchant_data, |
171
|
|
|
// 'url' => $url |
172
|
|
|
// ]); echo '</pre>'; die; |
173
|
|
|
// |
174
|
|
|
// $httpResponse = $this->httpClient->request('POST', $this->getEndpoint()); |
175
|
|
|
|
176
|
|
|
return $this->response = new PurchaseResponse($this, [ |
177
|
|
|
'url' => $url, |
178
|
|
|
'merchant_data' => $merchant_data |
179
|
|
|
]); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Get endpoint |
184
|
|
|
* |
185
|
|
|
* Returns endpoint depending on test mode |
186
|
|
|
* |
187
|
|
|
* @access protected |
188
|
|
|
* @return string |
189
|
|
|
*/ |
190
|
|
|
protected function getEndpoint() |
191
|
|
|
{ |
192
|
|
|
return ($this->getTestMode() ? self::EP_HOST_TEST : self::EP_HOST_LIVE); |
193
|
|
|
} |
194
|
|
|
} |
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