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