Skip to content

Commit a2b465d

Browse files
Added check response signature
1 parent 1306582 commit a2b465d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
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\OnePay\Message\Response`.
8+
- Throw exception ở concern `\Omnipay\OnePay\Message\Conerns\ResponseSignatureValidation` khi response không tồn tại chữ ký.

src/Message/Concerns/ResponseSignatureValidation.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ trait ResponseSignatureValidation
2323
*/
2424
protected function validateSignature(): void
2525
{
26-
$data = array_filter($this->data, function ($parameter) {
26+
$data = $this->getData();
27+
28+
if (! isset($data['vpc_SecureHash'])) {
29+
throw new InvalidResponseException('Response from OnePay is invalid!');
30+
}
31+
32+
$dataSignature = array_filter($data, function ($parameter) {
2733
return 0 === strpos($parameter, 'vpc_') && 'vpc_SecureHash' !== $parameter;
2834
}, ARRAY_FILTER_USE_KEY);
2935
$signature = new Signature(
3036
$this->getRequest()->getVpcHashKey()
3137
);
3238

33-
if (! $signature->validate($data, $this->data['vpc_SecureHash'])) {
39+
if (! $signature->validate($dataSignature, $data['vpc_SecureHash'])) {
3440
throw new InvalidResponseException(sprintf('Data signature response from OnePay is invalid!'));
3541
}
3642
}

0 commit comments

Comments
 (0)