Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/Kkiapay.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use GuzzleHttp\Psr7;
use GuzzleHttp\Exception\RequestException;
use function GuzzleHttp\json_encode;
use function PHPSTORM_META\type;

/**
* Created by PhpStorm.
Expand All @@ -30,7 +29,7 @@ class Kkiapay
private $curl;

private $sandbox;

private $attempts = 0;

/**
Expand All @@ -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'
]);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -170,7 +169,7 @@ public function getPrivateKey()
}

/**
* @return null
* @return string
*/
public function getSecret()
{
Expand Down