1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/phpviet/omnipay-vnpay |
4
|
|
|
* |
5
|
|
|
* @copyright (c) PHP Viet |
6
|
|
|
* @license [MIT](https://opensource.org/licenses/MIT) |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Omnipay\VNPay; |
10
|
|
|
|
11
|
|
|
use Omnipay\Common\AbstractGateway; |
12
|
|
|
use Omnipay\VNPay\Message\IncomingRequest; |
13
|
|
|
use Omnipay\VNPay\Message\PurchaseRequest; |
14
|
|
|
use Omnipay\VNPay\Message\QueryTransactionRequest; |
15
|
|
|
use Omnipay\VNPay\Message\RefundRequest; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Vuong Minh <[email protected]> |
19
|
|
|
* @since 1.0.0 |
20
|
|
|
*/ |
21
|
|
|
class Gateway extends AbstractGateway |
22
|
|
|
{ |
23
|
|
|
use Concerns\Parameters; |
24
|
|
|
use Concerns\ParametersNormalization; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
public function getName(): string |
30
|
|
|
{ |
31
|
|
|
return 'VNPay'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public function initialize(array $parameters = []) |
38
|
|
|
{ |
39
|
|
|
return parent::initialize( |
40
|
|
|
$this->normalizeParameters($parameters) |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
public function getDefaultParameters() |
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
'vnp_Version' => '2.0.0', |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest|PurchaseRequest |
57
|
|
|
*/ |
58
|
|
|
public function purchase(array $options = []): PurchaseRequest |
59
|
|
|
{ |
60
|
|
|
return $this->createRequest(PurchaseRequest::class, $options); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest|IncomingRequest |
66
|
|
|
*/ |
67
|
|
|
public function completePurchase(array $options = []): IncomingRequest |
68
|
|
|
{ |
69
|
|
|
return $this->createRequest(IncomingRequest::class, $options); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Tạo yêu cầu xác minh IPN gửi từ VNPay. |
74
|
|
|
* |
75
|
|
|
* @param array $options |
76
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest|IncomingRequest |
77
|
|
|
*/ |
78
|
|
|
public function notification(array $options = []): IncomingRequest |
79
|
|
|
{ |
80
|
|
|
return $this->createRequest(IncomingRequest::class, $options); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Tạo yêu cầu truy vấn thông tin giao dịch đến VNPay. |
85
|
|
|
* |
86
|
|
|
* @param array $options |
87
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest|QueryTransactionRequest |
88
|
|
|
*/ |
89
|
|
|
public function queryTransaction(array $options = []): QueryTransactionRequest |
90
|
|
|
{ |
91
|
|
|
return $this->createRequest(QueryTransactionRequest::class, $options); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* {@inheritdoc} |
96
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest|RefundRequest |
97
|
|
|
*/ |
98
|
|
|
public function refund(array $options = []): RefundRequest |
99
|
|
|
{ |
100
|
|
|
return $this->createRequest(RefundRequest::class, $options); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|