From 92ca18afbaffe2bbf286208b22dbc4b6c13a9d07 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Fri, 31 May 2024 09:08:00 +0200 Subject: [PATCH 1/2] Able to retrieve the hash from the validator --- src/Handlers/HMAC/Validator.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Handlers/HMAC/Validator.php b/src/Handlers/HMAC/Validator.php index 92560cbe..b3efd00b 100644 --- a/src/Handlers/HMAC/Validator.php +++ b/src/Handlers/HMAC/Validator.php @@ -49,7 +49,7 @@ class Validator extends Hmac /** * @var string */ - protected string $hash; + protected string $hash = ''; /** * @param Config $config @@ -102,4 +102,12 @@ public function validateOrFail(string $header, string $uri, string $method, $dat throw new BuckarooException($this->config->getLogger(), "HMAC validation failed."); } + + /** + * @return string + */ + public function getHash(): string + { + return $this->hash; + } } From f5a313177fd7df36ccb48d821c76da2186924361 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Mon, 16 Dec 2024 16:21:02 +0100 Subject: [PATCH 2/2] Return null when ask for specific parameter in response --- src/Transaction/Response/TransactionResponse.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Transaction/Response/TransactionResponse.php b/src/Transaction/Response/TransactionResponse.php index c6b9bbf4..0c419593 100644 --- a/src/Transaction/Response/TransactionResponse.php +++ b/src/Transaction/Response/TransactionResponse.php @@ -105,9 +105,14 @@ public function isValidationFailure(): bool */ public function data(?string $key = null) { - if ($key && isset($this->data[$key])) + if ($key) { - return $this->data[$key]; + if (isset($this->data[$key])) + { + return $this->data[$key]; + } + + return null; } return $this->data;