Skip to content

Commit 39b5d6a

Browse files
Added check response signature
1 parent 0be8082 commit 39b5d6a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

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

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

src/Message/Concerns/ResponseSignatureValidation.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ trait ResponseSignatureValidation
2424
*/
2525
protected function validateSignature(): void
2626
{
27-
$data = [];
27+
$data = $this->getData();
28+
29+
if (! isset($data['signature'])) {
30+
throw new InvalidResponseException(sprintf('Response from MoMo is invalid!'));
31+
}
32+
33+
$dataSignature = [];
2834
$signature = new Signature(
2935
$this->getRequest()->getSecretKey()
3036
);
@@ -34,10 +40,10 @@ protected function validateSignature(): void
3440
$pos = $parameter;
3541
}
3642

37-
$data[$pos] = Arr::getValue($parameter, $this->data);
43+
$dataSignature[$pos] = Arr::getValue($parameter, $data);
3844
}
3945

40-
if (! $signature->validate($data, $this->data['signature'])) {
46+
if (! $signature->validate($dataSignature, $data['signature'])) {
4147
throw new InvalidResponseException(sprintf('Data signature response from MoMo is invalid!'));
4248
}
4349
}

0 commit comments

Comments
 (0)