|
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\Message\AllInOne; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @link https://developers.momo.vn/#/docs/aio/?id=ph%c6%b0%c6%a1ng-th%e1%bb%a9c-thanh-to%c3%a1n |
|
12
|
|
|
* |
|
13
|
|
|
* @author Vuong Minh <[email protected]> |
|
14
|
|
|
* @since 1.0.0 |
|
15
|
|
|
*/ |
|
16
|
|
|
class PurchaseRequest extends AbstractSignatureRequest |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $responseClass = PurchaseResponse::class; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* {@inheritdoc} |
|
25
|
|
|
*/ |
|
26
|
|
|
public function initialize(array $parameters = []) |
|
27
|
|
|
{ |
|
28
|
|
|
parent::initialize($parameters); |
|
29
|
|
|
$this->setOrderInfo($this->getParameter('orderInfo') ?? ''); |
|
30
|
|
|
$this->setExtraData($this->getParameter('extraData') ?? ''); |
|
31
|
|
|
$this->setParameter('requestType', 'captureMoMoWallet'); |
|
32
|
|
|
|
|
33
|
|
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Trả về extra data gửi đến MoMo. |
|
38
|
|
|
* |
|
39
|
|
|
* @return null|string |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getExtraData(): ?string |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->getParameter('extraData'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Thiết lập dữ liệu kèm theo đơn hàng. |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $data |
|
50
|
|
|
* @return $this |
|
51
|
|
|
*/ |
|
52
|
|
|
public function setExtraData(string $data) |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->setParameter('extraData', $data); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Trả về order info gửi đến MoMo. |
|
59
|
|
|
* |
|
60
|
|
|
* @return null|string |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getOrderInfo(): ?string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->getParameter('orderInfo'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Thiết lập thông tin đơn hàng. |
|
69
|
|
|
* |
|
70
|
|
|
* @param string $info |
|
71
|
|
|
* @return $this |
|
72
|
|
|
*/ |
|
73
|
|
|
public function setOrderInfo(string $info) |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->setParameter('orderInfo', $info); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* {@inheritdoc} |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function getSignatureParameters(): array |
|
82
|
|
|
{ |
|
83
|
|
|
return [ |
|
84
|
|
|
'partnerCode', 'accessKey', 'requestId', 'amount', 'orderId', 'orderInfo', 'returnUrl', 'notifyUrl', |
|
85
|
|
|
'extraData', |
|
86
|
|
|
]; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|