Skip to content

Commit 0812f20

Browse files
Added check response signature
1 parent 52e15a1 commit 0812f20

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Tất cả lịch sử tiến trình phát triển thư viện
55
## 1.0.1
66

77
- Implement phương thức `isCancelled` ở lớp `\Omnipay\VTCPay\Message\Response`.
8+
- Throw exception ở concern `\Omnipay\VTCPay\Message\Conerns\ResponseSignatureValidation` khi response không tồn tại chữ ký.

src/Message/Concerns/ResponseSignatureValidation.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@ trait ResponseSignatureValidation
2323
*/
2424
protected function validateSignature(): void
2525
{
26-
$data = $this->getData();
26+
$data = $dataSignature = $this->getData();
27+
28+
if (! isset($data['signature'])) {
29+
throw new InvalidResponseException(sprintf('Response from VTCPay is invalid!'));
30+
}
31+
2732
$signature = new Signature(
2833
$this->getRequest()->getSecurityCode()
2934
);
30-
$actual = $data['signature'];
31-
unset($data['signature']);
3235

33-
if (! $signature->validate($data, $actual)) {
36+
unset($dataSignature['signature']);
37+
38+
if (! $signature->validate($dataSignature, $data['signature'])) {
3439
throw new InvalidResponseException(sprintf('Data signature response from VTCPay is invalid!'));
3540
}
3641
}

0 commit comments

Comments
 (0)