Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ea1f63b

Browse files
Clean code
1 parent c801c26 commit ea1f63b

File tree

7 files changed

+209
-237
lines changed

7 files changed

+209
-237
lines changed

‎src/Message/AbstractPurchaseRequest.php‎

Lines changed: 188 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@
1414
*/
1515
abstract class AbstractPurchaseRequest extends AbstractSignatureRequest
1616
{
17-
use Concerns\PurchaseParameters;
18-
1917
/**
2018
* {@inheritdoc}
2119
*/
2220
public function initialize(array $parameters = [])
2321
{
2422
parent::initialize($parameters);
23+
2524
$this->setAgainLink(
2625
$this->getAgainLink() ?? $this->httpRequest->getUri()
2726
);
2827
$this->setVpcTicketNo(
2928
$this->getVpcTicketNo() ?? $this->httpRequest->getClientIp()
3029
);
30+
$this->setTitle(
31+
$this->getTitle() ?? ''
32+
);
3133

3234
return $this;
3335
}
@@ -39,8 +41,191 @@ public function initialize(array $parameters = [])
3941
public function getData(): array
4042
{
4143
$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+
}
4257

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);
44229
}
45230

46231
/**

‎src/Message/AbstractResponse.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Omnipay\Common\Message\AbstractResponse as BaseAbstractResponse;
1111

1212
/**
13+
* @method AbstractRequest getRequest()
14+
*
1315
* @author Vuong Minh <vuongxuongminh@gmail.com>
1416
* @since 1.0.0
1517
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /