Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PAYSTACK_SECRET_KEY="your secret key goes here"
PAYSTACK_SECRET_KEY_FAKE="a fake secret key goes here"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ docs
vendor
nbproject
src/Routes/SkeletonClass.php
.env
.env
.idea/
13 changes: 11 additions & 2 deletions src/Paystack/Helpers/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace YabaCon\Paystack\Helpers;

use \Closure;
use Guzzle\Http\Exception\RequestException;
use \YabaCon\Paystack\Contracts\RouteInterface;

/**
Expand Down Expand Up @@ -132,8 +133,16 @@ private function callViaCurl($interface, $payload = [ ], $sentargs = [ ])
// Use Guzzle if found, else use Curl
if ($this->use_guzzle && class_exists('\\GuzzleHttp\\Client') && class_exists('\\GuzzleHttp\\Psr7\\Request')) {
$request = new \GuzzleHttp\Psr7\Request(strtoupper($method), $endpoint, $headers, $body);
$client = new \GuzzleHttp\Client(['http_errors' => false]);
$response = $client->send($request);
$client = new \GuzzleHttp\Client();
try{
$response = $client->send($request);
}catch(\GuzzleHttp\Exception\RequestException $e){
if ($e->hasResponse()){
$response = $e->getResponse();
}else{
$response = null;
}
}
return $response;

} else {
Expand Down
8 changes: 6 additions & 2 deletions tests/EndToEndTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
error_reporting(-1);
require_once __DIR__ . '/../vendor/autoload.php';

$dotenv = new Dotenv\Dotenv(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
$dotenv = new Dotenv\Dotenv(dirname(dirname(__FILE__)));
$dotenv->load();

$paystack = new \YabaCon\Paystack(getenv("PAYSTACK_SECRET_KEY"));
//$paystack->useGuzzle();

$paystack2 = new \YabaCon\Paystack(getenv("PAYSTACK_SECRET_KEY_FAKE"));
$paystack2->useGuzzle();
$k = $paystack2->customer->list();
print_r(json_decode($k->getbody(), true));

if (false) {
print_r($paystack->customer(1));
Expand Down