1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/phpviet/omnipay-momo |
4
|
|
|
* @copyright (c) PHP Viet |
5
|
|
|
* @license [MIT](http://www.opensource.org/licenses/MIT) |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Omnipay\MoMo; |
9
|
|
|
|
10
|
|
|
use Omnipay\Common\AbstractGateway; |
11
|
|
|
use Omnipay\MoMo\Message\PayRefundRequest; |
12
|
|
|
use Omnipay\MoMo\Message\PayConfirmRequest; |
13
|
|
|
use Omnipay\MoMo\Message\POS\PurchaseRequest; |
14
|
|
|
use Omnipay\MoMo\Message\PayQueryStatusRequest; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Vuong Minh <[email protected]> |
18
|
|
|
* @since 1.0.0 |
19
|
|
|
*/ |
20
|
|
View Code Duplication |
class POSGateway extends AbstractGateway |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
use Concerns\Parameters; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function getName(): string |
28
|
|
|
{ |
29
|
|
|
return 'MoMo POS'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritdoc} |
34
|
|
|
* @return \Omnipay\Common\Message\RequestInterface|PurchaseRequest |
35
|
|
|
*/ |
36
|
|
|
public function purchase(array $options = []): PurchaseRequest |
37
|
|
|
{ |
38
|
|
|
return $this->createRequest(PurchaseRequest::class, $options); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Tạo yêu cầu xác nhận hoàn thành hoặc hủy bỏ giao dịch đến MoMo. |
43
|
|
|
* |
44
|
|
|
* @param array $options |
45
|
|
|
* @return \Omnipay\Common\Message\RequestInterface|PayConfirmRequest |
46
|
|
|
*/ |
47
|
|
|
public function payConfirm(array $options = []): PayConfirmRequest |
48
|
|
|
{ |
49
|
|
|
return $this->createRequest(PayConfirmRequest::class, $options); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Tạo yêu cầu truy vấn thông tin giao dịch đến MoMo. |
54
|
|
|
* |
55
|
|
|
* @param array $options |
56
|
|
|
* @return \Omnipay\Common\Message\RequestInterface|PayQueryStatusRequest |
57
|
|
|
*/ |
58
|
|
|
public function queryTransaction(array $options = []): PayQueryStatusRequest |
59
|
|
|
{ |
60
|
|
|
return $this->createRequest(PayQueryStatusRequest::class, $options); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
* @return \Omnipay\Common\Message\RequestInterface|PayRefundRequest |
66
|
|
|
*/ |
67
|
|
|
public function refund(array $options = []): PayRefundRequest |
68
|
|
|
{ |
69
|
|
|
return $this->createRequest(PayRefundRequest::class, $options); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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.