Skip to content

Commit

Permalink
Null fields should not be part of signature [closes #60]
Browse files Browse the repository at this point in the history
  • Loading branch information
janlanger committed Oct 24, 2022
1 parent 41702a3 commit 7b8b281
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Crypto/SignatureDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function generateMessage(array $data, array $keys): array
}
continue;
}
if (!array_key_exists($key, $data)) {
if (!array_key_exists($key, $data) || $data[$key] === null) {
continue;
}

Expand Down
23 changes: 23 additions & 0 deletions tests/unit/Crypto/SignatureDataFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ public function getFormatDataForSignatureData(): array
],
'2017|0|2|1|CARD|VISA|MASTERCARD|PAN_ONLY',
],
[
[
'payId' => null,
'dttm' => null,
'resultCode' => null,
'resultMessage' => null,
'paymentStatus' => null,
'authCode' => null,
'statusDetail' => null,
],
[
'dttm' => '20221020125950',
'merchantId' => null,
'payId' => 'ea900d28f513@HJ',
'resultCode' => 0,
'resultMessage' => 'OK',
'paymentStatus' => 8,
'authCode' => null,
'statusDetail' => null,
'actions' => null,
],
'ea900d28f513@HJ|20221020125950|0|OK|8',
],
];
}

Expand Down

0 comments on commit 7b8b281

Please sign in to comment.