This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @link https://github.com/phpviet/omnipay-onepay |
||
4 | * |
||
5 | * @copyright (c) PHP Viet |
||
6 | * @license [MIT](https://opensource.org/licenses/MIT) |
||
7 | */ |
||
8 | |||
9 | namespace Omnipay\OnePay\Message; |
||
10 | |||
11 | /** |
||
12 | * @author Vuong Minh <[email protected]> |
||
13 | * @since 1.0.0 |
||
14 | */ |
||
15 | abstract class AbstractPurchaseRequest extends AbstractSignatureRequest |
||
16 | { |
||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | public function initialize(array $parameters = []) |
||
21 | { |
||
22 | parent::initialize($parameters); |
||
23 | |||
24 | $this->setParameter('vpc_Command', 'pay'); |
||
25 | $this->setAgainLink( |
||
26 | $this->getAgainLink() ?? $this->httpRequest->getUri() |
||
27 | ); |
||
28 | $this->setVpcTicketNo( |
||
29 | $this->getVpcTicketNo() ?? $this->httpRequest->getClientIp() |
||
30 | ); |
||
31 | $this->setTitle( |
||
32 | $this->getTitle() ?? '' |
||
33 | ); |
||
34 | $this->setCurrency( |
||
35 | $this->getCurrency() ?? 'VND' |
||
36 | ); |
||
37 | $this->setVpcLocale( |
||
38 | $this->getVpcLocale() ?? 'vn' |
||
39 | ); |
||
40 | |||
41 | return $this; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | * @throws \Omnipay\Common\Exception\InvalidRequestException |
||
47 | */ |
||
48 | public function getData(): array |
||
49 | { |
||
50 | $this->validate('AgainLink', 'Title'); |
||
51 | $data = parent::getData(); |
||
52 | unset($data['vpc_User'], $data['vpc_Password']); |
||
53 | |||
54 | return $data; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function sendData($data): PurchaseResponse |
||
61 | { |
||
62 | $redirectUrl = $this->getEndpoint().'?'.http_build_query($data); |
||
63 | |||
64 | return $this->response = new PurchaseResponse($this, $data, $redirectUrl); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Trả giao diện ngôn ngữ khách dùng để thanh toán. |
||
69 | * |
||
70 | * @return null|string |
||
71 | */ |
||
72 | public function getVpcLocale(): ?string |
||
73 | { |
||
74 | return $this->getParameter('vpc_Locale'); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Thiết lập giao diện ngôn ngữ khách dùng để thanh toán. |
||
79 | * |
||
80 | * @param null|string $locale |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function setVpcLocale(?string $locale) |
||
84 | { |
||
85 | return $this->setParameter('vpc_Locale', $locale); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Trả về đường dẫn thanh toán tại hệ thống của bạn mà khách đã dùng để thanh toán. |
||
90 | * Nếu không thiết lập hệ thống sẽ tự động lấy đường dẫn của khách truy vấn hệ thống hiện tại, đối với CLI mode sẽ là empty. |
||
91 | * |
||
92 | * @return null|string |
||
93 | */ |
||
94 | public function getAgainLink(): ?string |
||
95 | { |
||
96 | return $this->getParameter('AgainLink'); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Thiết lập đường dẫn thanh toán tại hệ thống của bạn mà khách đã dùng để thanh toán. |
||
101 | * |
||
102 | * @param null|string $link |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function setAgainLink(?string $link) |
||
106 | { |
||
107 | return $this->setParameter('AgainLink', $link); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Trả về tiêu đề hiển thị tại OnePay khi thanh toán. |
||
112 | * |
||
113 | * @return null|string |
||
114 | */ |
||
115 | public function getTitle(): ?string |
||
116 | { |
||
117 | return $this->getParameter('Title'); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Thiết lập tiêu đề hiển thị tại OnePay khi thanh toán. |
||
122 | * |
||
123 | * @param null|string $title |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function setTitle(?string $title) |
||
127 | { |
||
128 | return $this->setParameter('Title', $title); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Phương thức ánh xạ của [[getClientIp()]]. |
||
133 | * |
||
134 | * @return null|string |
||
135 | * @see getClientIp |
||
136 | */ |
||
137 | public function getVpcTicketNo(): ?string |
||
138 | { |
||
139 | return $this->getClientIp(); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Phương thức ánh xạ của [[setClientIp()]]. |
||
144 | * |
||
145 | * @param null|string $ticketNo |
||
146 | * @return $this |
||
147 | * @see setClientIp |
||
148 | */ |
||
149 | public function setVpcTicketNo(?string $ticketNo) |
||
150 | { |
||
151 | return $this->setClientIp($ticketNo); |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * {@inheritdoc} |
||
156 | */ |
||
157 | public function getClientIp(): ?string |
||
158 | { |
||
159 | return $this->getParameter('vpc_TicketNo'); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * {@inheritdoc} |
||
164 | */ |
||
165 | public function setClientIp($value) |
||
166 | { |
||
167 | return $this->setParameter('vpc_TicketNo', $value); |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * Phương thức ánh xạ của [[getAmount()]]. |
||
172 | * |
||
173 | * @return null|string |
||
174 | * @see getAmount |
||
175 | */ |
||
176 | public function getVpcAmount(): ?string |
||
177 | { |
||
178 | return $this->getAmount(); |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * Phương thức ánh xạ của [[setAmount()]]. |
||
183 | * |
||
184 | * @param null|string $amount |
||
185 | * @return $this |
||
186 | * @see setAmount |
||
187 | */ |
||
188 | public function setVpcAmount(?string $amount) |
||
189 | { |
||
190 | return $this->setAmount($amount); |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * {@inheritdoc} |
||
195 | */ |
||
196 | public function getAmount(): ?string |
||
197 | { |
||
198 | return $this->getParameter('vpc_Amount'); |
||
199 | } |
||
200 | |||
201 | /** |
||
202 | * {@inheritdoc} |
||
203 | */ |
||
204 | public function setAmount($value) |
||
205 | { |
||
206 | return $this->setParameter('vpc_Amount', $value); |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * Trả về thông tin đơn hàng. |
||
211 | * |
||
212 | * @return null|string |
||
213 | */ |
||
214 | public function getVpcOrderInfo(): ?string |
||
215 | { |
||
216 | return $this->getParameter('vpc_OrderInfo'); |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * Thiết lập thông tin đơn hàng. |
||
221 | * |
||
222 | * @param null|string $info |
||
223 | * @return $this |
||
224 | */ |
||
225 | public function setVpcOrderInfo(?string $info) |
||
226 | { |
||
227 | return $this->setParameter('vpc_OrderInfo', $info); |
||
228 | } |
||
229 | |||
230 | /** |
||
231 | * Trả về mã đơn hàng cần thanh toán. |
||
232 | * |
||
233 | * @return null|string |
||
234 | */ |
||
235 | public function getVpcMerchTxnRef(): ?string |
||
236 | { |
||
237 | return $this->getParameter('vpc_MerchTxnRef'); |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * Thiết lập mã đơn hàng cần thanh toán tại hệ thống của bạn. |
||
242 | * |
||
243 | * @param null|string $ref |
||
244 | * @return $this |
||
245 | */ |
||
246 | public function setVpcMerchTxnRef(?string $ref) |
||
247 | { |
||
248 | return $this->setParameter('vpc_MerchTxnRef', $ref); |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * Trả về đơn vị tiền tệ sử dụng thanh toán của khách. |
||
253 | * |
||
254 | * @return null|string |
||
255 | */ |
||
256 | public function getVpcCurrency(): ?string |
||
257 | { |
||
258 | return $this->getCurrency(); |
||
259 | } |
||
260 | |||
261 | /** |
||
262 | * Thiết lập đơn vị tiền tệ sử dụng thanh toán của khách. |
||
263 | * |
||
264 | * @param null|string $currency |
||
265 | * @return $this |
||
266 | */ |
||
267 | public function setVpcCurrency(?string $currency) |
||
268 | { |
||
269 | return $this->setCurrency($currency); |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * {@inheritdoc} |
||
274 | */ |
||
275 | public function getCurrency(): ?string |
||
276 | { |
||
277 | return ($currency = $this->getParameter('vpc_Currency')) ? strtoupper($currency) : null; |
||
278 | } |
||
279 | |||
280 | /** |
||
281 | * {@inheritdoc} |
||
282 | */ |
||
283 | public function setCurrency($value) |
||
284 | { |
||
285 | return $this->setParameter('vpc_Currency', $value); |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * Trả về số điện thoại khách hàng. |
||
290 | * |
||
291 | * @return null|string |
||
292 | */ |
||
293 | public function getVpcCustomerPhone(): ?string |
||
294 | { |
||
295 | return $this->getParameter('vpc_Customer_Phone'); |
||
296 | } |
||
297 | |||
298 | /** |
||
299 | * Thiết lập số điện thoại khách hàng. |
||
300 | * |
||
301 | * @param null|string $phone |
||
302 | * @return $this |
||
303 | */ |
||
304 | public function setVpcCustomerPhone(?string $phone) |
||
305 | { |
||
306 | return $this->setParameter('vpc_Customer_Phone', $phone); |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * Trả về id khách hàng. |
||
311 | * |
||
312 | * @return null|string |
||
313 | */ |
||
314 | public function getVpcCustomerId(): ?string |
||
315 | { |
||
316 | return $this->getParameter('vpc_Customer_Id'); |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * Thiết lập id khách hàng. |
||
321 | * |
||
322 | * @param null|string $id |
||
323 | * @return $this |
||
324 | */ |
||
325 | public function setVpcCustomerId(?string $id) |
||
326 | { |
||
327 | return $this->setParameter('vpc_Customer_Id', $id); |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * Phương thức ánh xạ của [[getReturnUrl()]]. |
||
332 | * Trả về đường dẫn tại hệ thống của bạn sẽ redirect khách về sau khi thanh toán. |
||
333 | * |
||
334 | * @return null|string |
||
335 | * @see getReturnUrl |
||
336 | */ |
||
337 | public function getVpcReturnURL(): ?string |
||
338 | { |
||
339 | return $this->getReturnUrl(); |
||
340 | } |
||
341 | |||
342 | /** |
||
343 | * Phương thức ánh xạ của [[setReturnUrl()]]. |
||
344 | * |
||
345 | * @param null|string $url |
||
346 | * @return $this |
||
347 | * @see setReturnUrl |
||
348 | */ |
||
349 | public function setVpcReturnURL(?string $url) |
||
350 | { |
||
351 | return $this->setReturnUrl($url); |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * {@inheritdoc} |
||
356 | */ |
||
357 | public function getReturnUrl(): ?string |
||
358 | { |
||
359 | return $this->getParameter('vpc_ReturnURL'); |
||
360 | } |
||
361 | |||
362 | /** |
||
363 | * {@inheritdoc} |
||
364 | */ |
||
365 | public function setReturnUrl($value) |
||
366 | { |
||
367 | return $this->setParameter('vpc_ReturnURL', $value); |
||
368 | } |
||
369 | |||
370 | /** |
||
371 | * Trả về email khách hàng. |
||
372 | * |
||
373 | * @return null|string |
||
374 | */ |
||
375 | public function getVpcCustomerEmail(): ?string |
||
376 | { |
||
377 | return $this->getParameter('vpc_Customer_Email'); |
||
378 | } |
||
379 | |||
380 | /** |
||
381 | * Thiết lập email khách hàng. |
||
382 | * |
||
383 | * @param null|string $email |
||
384 | * @return $this |
||
385 | */ |
||
386 | public function setVpcCustomerEmail(?string $email) |
||
387 | { |
||
388 | return $this->setParameter('vpc_Customer_Email', $email); |
||
389 | } |
||
390 | |||
391 | /** |
||
392 | * {@inheritdoc} |
||
393 | */ |
||
394 | protected function getSignatureParameters(): array |
||
395 | { |
||
396 | $parameters = [ |
||
397 | 'vpc_Version', 'vpc_Currency', 'vpc_Command', 'vpc_AccessCode', 'vpc_Merchant', 'vpc_Locale', |
||
398 | 'vpc_ReturnURL', 'vpc_MerchTxnRef', 'vpc_OrderInfo', 'vpc_Amount', 'vpc_TicketNo', |
||
399 | ]; |
||
400 | |||
401 | if ($this->getVpcCustomerId()) { |
||
0 ignored issues
–
show
|
|||
402 | $parameters[] = 'vpc_Customer_Id'; |
||
403 | } |
||
404 | |||
405 | if ($this->getVpcCustomerEmail()) { |
||
0 ignored issues
–
show
The expression
$this->getVpcCustomerEmail() of type null|string is loosely compared to true ; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
406 | $parameters[] = 'vpc_Customer_Email'; |
||
407 | } |
||
408 | |||
409 | if ($this->getVpcCustomerPhone()) { |
||
0 ignored issues
–
show
The expression
$this->getVpcCustomerPhone() of type null|string is loosely compared to true ; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
410 | $parameters[] = 'vpc_Customer_Phone'; |
||
411 | } |
||
412 | |||
413 | return $parameters; |
||
414 | } |
||
415 | } |
||
416 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: