14
14
*/
15
15
abstract class AbstractPurchaseRequest extends AbstractSignatureRequest
16
16
{
17
- use Concerns \PurchaseParameters;
18
-
19
17
/**
20
18
* {@inheritdoc}
21
19
*/
22
20
public function initialize (array $ parameters = [])
23
21
{
24
22
parent ::initialize ($ parameters );
23
+
25
24
$ this ->setAgainLink (
26
25
$ this ->getAgainLink () ?? $ this ->httpRequest ->getUri ()
27
26
);
28
27
$ this ->setVpcTicketNo (
29
28
$ this ->getVpcTicketNo () ?? $ this ->httpRequest ->getClientIp ()
30
29
);
30
+ $ this ->setTitle (
31
+ $ this ->getTitle () ?? ''
32
+ );
31
33
32
34
return $ this ;
33
35
}
@@ -39,8 +41,191 @@ public function initialize(array $parameters = [])
39
41
public function getData (): array
40
42
{
41
43
$ this ->validate ('AgainLink ' , 'Title ' );
44
+ $ data = parent ::getData ();
45
+ $ data ['redirect_url ' ] = $ this ->getEndpoint ().'? ' .http_build_query ($ data );
46
+
47
+ return $ data ;
48
+ }
49
+
50
+ /**
51
+ * {@inheritdoc}
52
+ */
53
+ public function sendData ($ data )
54
+ {
55
+ return $ this ->response = new PurchaseResponse ($ this , $ data );
56
+ }
42
57
43
- return parent ::getData ();
58
+ /**
59
+ * Trả về đường dẫn thanh toán tại hệ thống của bạn mà khách đã dùng để thanh toán.
60
+ * Nếu không thiết lập hệ thống sẽ tự động lấy đường dẫn của khách truy vấn hệ thống hiện tại, đối với CLI mode sẽ là empty.
61
+ *
62
+ * @return null|string
63
+ */
64
+ public function getAgainLink (): ?string
65
+ {
66
+ return $ this ->getParameter ('AgainLink ' );
67
+ }
68
+
69
+ /**
70
+ * Thiết lập đường dẫn thanh toán tại hệ thống của bạn mà khách đã dùng để thanh toán.
71
+ *
72
+ * @param string $link
73
+ * @return $this
74
+ */
75
+ public function setAgainLink (string $ link )
76
+ {
77
+ return $ this ->setParameter ('AgainLink ' , $ link );
78
+ }
79
+
80
+ /**
81
+ * Trả về tiêu đề hiển thị tại OnePay khi thanh toán.
82
+ *
83
+ * @return null|string
84
+ */
85
+ public function getTitle (): ?string
86
+ {
87
+ return $ this ->getParameter ('Title ' );
88
+ }
89
+
90
+ /**
91
+ * Thiết lập tiêu đề hiển thị tại OnePay khi thanh toán.
92
+ *
93
+ * @param string $title
94
+ * @return $this
95
+ */
96
+ public function setTitle (string $ title )
97
+ {
98
+ return $ this ->setParameter ('Title ' , $ title );
99
+ }
100
+
101
+ /**
102
+ * Phương thức ánh xạ của [[getClientIp()]].
103
+ *
104
+ * @return null|string
105
+ * @see getClientIp
106
+ */
107
+ public function getVpcTicketNo (): ?string
108
+ {
109
+ return $ this ->getClientIp ();
110
+ }
111
+
112
+ /**
113
+ * Phương thức ánh xạ của [[setClientIp()]].
114
+ *
115
+ * @param string $ticketNo
116
+ * @return $this
117
+ * @see setClientIp
118
+ */
119
+ public function setVpcTicketNo (string $ ticketNo )
120
+ {
121
+ return $ this ->setClientIp ($ ticketNo );
122
+ }
123
+
124
+ /**
125
+ * Trả về IP của khách dùng để thanh toán. Nếu không thiết lập sẽ lấy theo IP client đang truy cập hệ thống, đối với CLI mode thì sẽ là empty.
126
+ *
127
+ * @return null|string
128
+ */
129
+ public function getClientIp (): ?string
130
+ {
131
+ return $ this ->getParameter ('vpc_TicketNo ' );
132
+ }
133
+
134
+ /**
135
+ * Thiết lập IP của khách dùng để thanh toán.
136
+ *
137
+ * @param string $value
138
+ * @return $this
139
+ */
140
+ public function setClientIp ($ value )
141
+ {
142
+ return $ this ->setParameter ('vpc_TicketNo ' , $ value );
143
+ }
144
+
145
+ /**
146
+ * Phương thức ánh xạ của [[getAmount()]].
147
+ *
148
+ * @return null|string
149
+ * @see getAmount
150
+ */
151
+ public function getVpcAmount (): ?string
152
+ {
153
+ return $ this ->getAmount ();
154
+ }
155
+
156
+ /**
157
+ * Phương thức ánh xạ của [[setAmount()]].
158
+ *
159
+ * @param string $amount
160
+ * @return $this
161
+ * @see setAmount
162
+ */
163
+ public function setVpcAmount (string $ amount )
164
+ {
165
+ return $ this ->setAmount ($ amount );
166
+ }
167
+
168
+ /**
169
+ * Trả về số tiền của đơn hàng.
170
+ *
171
+ * @return null|string
172
+ */
173
+ public function getAmount (): ?string
174
+ {
175
+ return $ this ->getParameter ('vpc_Amount ' );
176
+ }
177
+
178
+ /**
179
+ * Thiết lập số tiền đơn hàng cần thanh toán.
180
+ *
181
+ * @param string $value
182
+ * @return $this
183
+ */
184
+ public function setAmount ($ value )
185
+ {
186
+ return $ this ->setParameter ('vpc_Amount ' , $ value );
187
+ }
188
+
189
+ /**
190
+ * Trả về thông tin đơn hàng.
191
+ *
192
+ * @return null|string
193
+ */
194
+ public function getVpcOrderInfo (): ?string
195
+ {
196
+ return $ this ->getParameter ('vpc_OrderInfo ' );
197
+ }
198
+
199
+ /**
200
+ * Thiết lập thông tin đơn hàng.
201
+ *
202
+ * @param string $info
203
+ * @return $this
204
+ */
205
+ public function setVpcOrderInfo (string $ info )
206
+ {
207
+ return $ this ->setParameter ('vpc_OrderInfo ' , $ info );
208
+ }
209
+
210
+ /**
211
+ * Trả về mã đơn hàng cần thanh toán.
212
+ *
213
+ * @return null|string
214
+ */
215
+ public function getVpcMerchTxnRef (): ?string
216
+ {
217
+ return $ this ->getParameter ('vpc_MerchTxnRef ' );
218
+ }
219
+
220
+ /**
221
+ * Thiết lập mã đơn hàng cần thanh toán tại hệ thống của bạn.
222
+ *
223
+ * @param string $info
224
+ * @return $this
225
+ */
226
+ public function setVpcMerchTxnRef (string $ ref )
227
+ {
228
+ return $ this ->setParameter ('vpc_MerchTxnRef ' , $ ref );
44
229
}
45
230
46
231
/**
0 commit comments