77
88namespace Omnipay \VNPay \Message ;
99
10+ use Omnipay \VNPay \Concerns \Parameters ;
11+ use Omnipay \Common \Message \AbstractRequest ;
12+ use Omnipay \VNPay \Concerns \ParametersNormalization ;
13+
1014/**
1115 * @author Vuong Minh <vuongxuongminh@gmail.com>
1216 * @since 1.0.0
1317 */
1418abstract class AbstractSignatureRequest extends AbstractRequest
1519{
20+ use Parameters;
21+ use ParametersNormalization;
1622 use Concerns \RequestEndpoint;
1723 use Concerns \RequestSignature;
1824
25+ /**
26+ * {@inheritdoc}
27+ */
28+ public function initialize (array $ parameters = [])
29+ {
30+ parent ::initialize (
31+ $ this ->normalizeParameters ($ parameters )
32+ );
33+
34+ $ this ->setVnpIpAddr (
35+ $ this ->getVnpIpAddr () ?? $ this ->httpRequest ->getClientIp ()
36+ );
37+ $ this ->setVnpCreateDate (
38+ $ this ->getVnpCreateDate () ?? date ('Ymdhis ' )
39+ );
40+
41+ return $ this ;
42+ }
43+
1944 /**
2045 * {@inheritdoc}
2146 */
@@ -35,4 +60,133 @@ public function getData(): array
3560
3661 return $ parameters ;
3762 }
63+
64+ /**
65+ * Trả về mã đơn hàng cần thực thi tác vụ.
66+ * Đây là phương thức ánh xạ của [[getTransactionId()]].
67+ *
68+ * @return null|string
69+ * @see getTransactionId
70+ */
71+ public function getVnpTxnRef (): ?string
72+ {
73+ return $ this ->getTransactionId ();
74+ }
75+
76+ /**
77+ * Thiết lập mã đơn hàng cần thực thi tác vụ.
78+ * Đây là phương thức ánh xạ của [[setTransactionId()]].
79+ *
80+ * @param null|string $ref
81+ *
82+ * @return $this
83+ * @see setTransactionId
84+ */
85+ public function setVnpTxnRef (?string $ ref )
86+ {
87+ return $ this ->setTransactionId ($ ref );
88+ }
89+
90+ /**
91+ * {@inheritdoc}
92+ */
93+ public function getTransactionId (): ?string
94+ {
95+ return $ this ->getParameter ('vnp_TxnRef ' );
96+ }
97+
98+ /**
99+ * {@inheritdoc}
100+ */
101+ public function setTransactionId ($ value )
102+ {
103+ return $ this ->setParameter ('vnp_TxnRef ' , $ value );
104+ }
105+
106+ /**
107+ * Trả về thông tin đơn hàng hay lý do truy vấn đến VNPay.
108+ *
109+ * @return null|string
110+ */
111+ public function getVnpOrderInfo (): ?string
112+ {
113+ return $ this ->getParameter ('vnp_OrderInfo ' );
114+ }
115+
116+ /**
117+ * Thiết lập thông tin đơn hàng hay lý do truy vấn đến VNPay.
118+ *
119+ * @param null|string $info
120+ * @return $this
121+ */
122+ public function setVnpOrderInfo (?string $ info )
123+ {
124+ return $ this ->setParameter ('vnp_OrderInfo ' , $ info );
125+ }
126+
127+ /**
128+ * Trả về thời gian khởi tạo truy vấn đến VNPay.
129+ *
130+ * @return null|string
131+ * @see getVnpReturnUrl
132+ */
133+ public function getVnpCreateDate (): ?string
134+ {
135+ return $ this ->getParameter ('vnp_CreateDate ' );
136+ }
137+
138+ /**
139+ * Thiết lập thời gian khởi tạo truy vấn đến VNPay.
140+ * Mặc định sẽ là thời gian hiện tại.
141+ *
142+ * @param null|string $date
143+ * @return $this
144+ * @see setReturnUrl
145+ */
146+ public function setVnpCreateDate (?string $ date )
147+ {
148+ return $ this ->setParameter ('vnp_CreateDate ' , $ date );
149+ }
150+
151+ /**
152+ * Trả về ip của khách dùng để thanh toán.
153+ * Đây là phương thức ánh xạ của [[getClientIp()]].
154+ *
155+ * @return null|string
156+ * @see getClientIp
157+ */
158+ public function getVnpIpAddr (): ?string
159+ {
160+ return $ this ->getClientIp ();
161+ }
162+
163+ /**
164+ * Thiết lập ip của khách dùng để thanh toán.
165+ * Đây là phương thức ánh xạ của [[setClientIp()]].
166+ * Mặc định nếu không thiết lập sẽ là IP của khách.
167+ *
168+ * @param null|string $ip
169+ * @return $this
170+ * @see setClientIp
171+ */
172+ public function setVnpIpAddr (?string $ ip )
173+ {
174+ return $ this ->setClientIp ($ ip );
175+ }
176+
177+ /**
178+ * {@inheritdoc}
179+ */
180+ public function getClientIp (): ?string
181+ {
182+ return $ this ->getParameter ('vnp_IpAddr ' );
183+ }
184+
185+ /**
186+ * {@inheritdoc}
187+ */
188+ public function setClientIp ($ value )
189+ {
190+ return $ this ->setParameter ('vnp_IpAddr ' , $ value );
191+ }
38192}
0 commit comments