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 c801c26

Browse files
Clean code
1 parent 44fbf9a commit c801c26

File tree

5 files changed

+95
-17
lines changed

5 files changed

+95
-17
lines changed

‎src/AbstractGateway.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ abstract class AbstractGateway extends BaseAbstractGateway
2424
*/
2525
public function initialize(array $parameters = [])
2626
{
27-
parent::initialize(
27+
returnparent::initialize(
2828
$this->normalizeParameters($parameters)
2929
);
30-
31-
return $this;
3230
}
3331

3432
/**

‎src/Message/AbstractPurchaseRequest.php‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ abstract class AbstractPurchaseRequest extends AbstractSignatureRequest
2222
public function initialize(array $parameters = [])
2323
{
2424
parent::initialize($parameters);
25-
$this->setParameter('version', 2);
2625
$this->setAgainLink(
2726
$this->getAgainLink() ?? $this->httpRequest->getUri()
2827
);
@@ -32,4 +31,32 @@ public function initialize(array $parameters = [])
3231

3332
return $this;
3433
}
34+
35+
/**
36+
* {@inheritdoc}
37+
* @throws \Omnipay\Common\Exception\InvalidRequestException
38+
*/
39+
public function getData(): array
40+
{
41+
$this->validate('AgainLink', 'Title');
42+
43+
return parent::getData();
44+
}
45+
46+
/**
47+
* {@inheritdoc}
48+
*/
49+
protected function getSignatureParameters(): array
50+
{
51+
$baseParameters = array_fill_keys([
52+
'vpc_Version', 'vpc_Currency', 'vpc_Command', 'vpc_AccessCode', 'vpc_Merchant', 'vpc_Locale',
53+
'vpc_ReturnURL', 'vpc_MerchTxnRef', 'vpc_OrderInfo', 'vpc_Amount', 'vpc_TicketNo',
54+
], true);
55+
$parameters = array_merge($baseParameters, $this->getParameters());
56+
$parameters = array_filter(array_keys($parameters), function ($parameter) {
57+
return 0 === strpos($parameter, 'vpc_');
58+
});
59+
60+
return $parameters;
61+
}
3562
}

‎src/Message/AbstractRequest.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ abstract class AbstractRequest extends BaseAbstractRequest
2525
*/
2626
public function initialize(array $parameters = [])
2727
{
28-
parent::initialize(
28+
returnparent::initialize(
2929
$this->normalizeParameters($parameters)
3030
);
31-
32-
return $this;
3331
}
3432
}

‎src/Message/AbstractSignatureRequest.php‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,4 @@ public function getData(): array
3131

3232
return $parameters;
3333
}
34-
35-
/**
36-
* {@inheritdoc}
37-
*/
38-
protected function getSignatureParameters(): array
39-
{
40-
return array_filter(array_keys($this->getParameters()), function ($parameter) {
41-
return 0 === strpos($parameter, 'vpc_');
42-
});
43-
}
4434
}

‎src/Message/Concerns/PurchaseParameters.php‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,50 @@ public function setClientIp($value)
101101
return $this->setParameter('vpc_TicketNo', $value);
102102
}
103103

104+
/**
105+
* Phương thức ánh xạ của [[getClientIp()]].
106+
*
107+
* @return null|string
108+
* @see getAmount
109+
*/
110+
public function getVpcAmount(): ?string
111+
{
112+
return $this->getAmount();
113+
}
114+
115+
/**
116+
* Phương thức ánh xạ của [[setClientIp()]].
117+
*
118+
* @param string $amount
119+
* @return $this
120+
* @see setAmount
121+
*/
122+
public function setVpcAmount(string $amount)
123+
{
124+
return $this->setAmount($amount);
125+
}
126+
127+
/**
128+
* Trả về số tiền của đơn hàng.
129+
*
130+
* @return null|string
131+
*/
132+
public function getAmount(): ?string
133+
{
134+
return $this->getParameter('vpc_Amount');
135+
}
136+
137+
/**
138+
* Thiết lập số tiền đơn hàng cần thanh toán.
139+
*
140+
* @param string $value
141+
* @return $this
142+
*/
143+
public function setAmount($value)
144+
{
145+
return $this->setParameter('vpc_Amount', $value);
146+
}
147+
104148
/**
105149
* Trả về thông tin đơn hàng.
106150
*
@@ -121,4 +165,25 @@ public function setVpcOrderInfo(string $info)
121165
{
122166
return $this->setParameter('vpc_OrderInfo', $info);
123167
}
168+
169+
/**
170+
* Trả về mã đơn hàng cần thanh toán.
171+
*
172+
* @return null|string
173+
*/
174+
public function getVpcMerchTxnRef(): ?string
175+
{
176+
return $this->getParameter('vpc_MerchTxnRef');
177+
}
178+
179+
/**
180+
* Thiết lập mã đơn hàng cần thanh toán tại hệ thống của bạn.
181+
*
182+
* @param string $info
183+
* @return $this
184+
*/
185+
public function setVpcMerchTxnRef(string $ref)
186+
{
187+
return $this->setParameter('vpc_MerchTxnRef', $ref);
188+
}
124189
}

0 commit comments

Comments
(0)

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