From c4580f3fed7d03fdfac5a3637269a78c11010d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dana=20JR=E2=9C=A8?= <46923804+iamdanajr@users.noreply.github.com> Date: Sat, 17 Jun 2023 09:45:16 +0000 Subject: [PATCH 1/2] Update Kkiapay.php Fixed intellisense report for getSecret return status --- src/Kkiapay.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kkiapay.php b/src/Kkiapay.php index 5b3aad4..17e0887 100644 --- a/src/Kkiapay.php +++ b/src/Kkiapay.php @@ -170,7 +170,7 @@ public function getPrivateKey() } /** - * @return null + * @return string */ public function getSecret() { From b29e885c9e016c33f681eb87072bbf88ebb4acee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dana=20JR=E2=9C=A8?= <46923804+iamdanajr@users.noreply.github.com> Date: Sat, 17 Jun 2023 10:06:47 +0000 Subject: [PATCH 2/2] Fixed Psr7 error -Update the guzzle package to the latest version; -Replace all the Psr7 deprecated function to the new ones; --- src/Kkiapay.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Kkiapay.php b/src/Kkiapay.php index 17e0887..1749569 100644 --- a/src/Kkiapay.php +++ b/src/Kkiapay.php @@ -5,7 +5,6 @@ use GuzzleHttp\Psr7; use GuzzleHttp\Exception\RequestException; use function GuzzleHttp\json_encode; -use function PHPSTORM_META\type; /** * Created by PhpStorm. @@ -30,7 +29,7 @@ class Kkiapay private $curl; private $sandbox; - + private $attempts = 0; /** @@ -43,7 +42,7 @@ public function __construct($public_key, $private_key, $secret = null, $sandbox $this->secret = $secret; $this->sandbox = $sandbox; $this->curl = new \GuzzleHttp\Client([ - 'verify' => __DIR__ . '/../data/cacert.pem' + 'verify' => __DIR__ . '/../cert/cacert.pem' ]); } @@ -74,7 +73,7 @@ public function verifyTransaction($transactionId) $response = $response->getBody()->getContents(); } catch (RequestException $e) { $this->attempts += 1; - if($this->attempts > 3) return $e->getResponse()->getStatusCode(); + if ($this->attempts > 3) return $e->getResponse()->getStatusCode(); return $this->verifyTransaction($transactionId); } return json_decode((string)$response); @@ -101,7 +100,7 @@ public function refundTransaction($transactionId) return json_decode((string)$reponse); } catch (RequestException $e) { if ($e->hasResponse()) { - $reponse = "{" . $this->get_string_between(Psr7\str($e->getResponse()), "{", "}") . "}"; + $reponse = "{" . $this->get_string_between(Psr7\Message::toString($e->getResponse()), "{", "}") . "}"; return json_decode((string)$reponse); } @@ -134,7 +133,7 @@ public function setupPayout(array $options) return json_decode((string)$reponse); } catch (RequestException $e) { if ($e->hasResponse()) { - $reponse = "{" . $this->get_string_between(Psr7\str($e->getResponse()), "{", "}") . "}"; + $reponse = "{" . $this->get_string_between(Psr7\Message::toString($e->getResponse()), "{", "}") . "}"; return json_decode((string)$reponse); } $reponse = json_encode(array("status" => STATUS::FAILED));