From 541797e4998105d9000a587a68a01c89c36283bc Mon Sep 17 00:00:00 2001 From: Aleksandr Riabov Date: Tue, 19 Jan 2021 20:29:34 +0300 Subject: [PATCH 1/2] Updated checkHandlerRequest() method to be more flexibility --- UnitPay.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/UnitPay.php b/UnitPay.php index ad0e143..7faab02 100644 --- a/UnitPay.php +++ b/UnitPay.php @@ -370,25 +370,25 @@ public function api($method, $params = array()) } /** - * Check request on handler from UnitPay + * Checks request on handler from Unitpay * - * @return bool - * - * @throws InvalidArgumentException - * @throws UnexpectedValueException + * @param array $data Request data + * @return boolean Always `true` + * @throws InvalidArgumentException If some request parameter missing or missmatch + * @throws UnexpectedValueException If some request parameter has invalid value */ - public function checkHandlerRequest() + public function checkHandlerRequest(array $data = array()) { $ip = $this->getIp(); - if (!isset($_GET['method'])) { + + if (!isset($data['method'])) { throw new InvalidArgumentException('Method is null'); } - - if (!isset($_GET['params'])) { + if (!isset($data['params'])) { throw new InvalidArgumentException('Params is null'); } - list($method, $params) = array($_GET['method'], $_GET['params']); + list($method, $params) = array($data['method'], $data['params']); if (!in_array($method, $this->supportedPartnerMethods)) { throw new UnexpectedValueException('Method is not supported'); From f543c6f5797ba25a7b590168cc67525d42e0441a Mon Sep 17 00:00:00 2001 From: Aleksandr Riabov Date: Tue, 19 Jan 2021 20:32:32 +0300 Subject: [PATCH 2/2] Removed default value from data paramter from checkHandlerRequest() method --- UnitPay.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitPay.php b/UnitPay.php index 7faab02..784a0cc 100644 --- a/UnitPay.php +++ b/UnitPay.php @@ -377,7 +377,7 @@ public function api($method, $params = array()) * @throws InvalidArgumentException If some request parameter missing or missmatch * @throws UnexpectedValueException If some request parameter has invalid value */ - public function checkHandlerRequest(array $data = array()) + public function checkHandlerRequest(array $data) { $ip = $this->getIp();