1. Go to this page and download the library: Download adelowo/gbowo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adelowo / gbowo example snippets
$adapter = new \Gbowo\Adapter\Paystack\PaystackAdapter();
$response = $adapter->charge();
header("Location : {$response}");
exit();
$adapter = (new \Gbowo\GbowoFactory())->createAdapter("paystack"); //or "amplifypay"
return $adapter->charge();
$paystack = new \Gbowo\Adapter\Paystack\PaystackAdapter();
$amplifyPay = new \Gbowo\Adapter\Amplifypay\AmplifypayAdapter()
$client = new \GuzzleHttp\Client(['key' => "value"]);
$amplifyPay = new \Gbowo\Adapter\Amplifypay\AmplifypayAdapter($client)
//paystack adapter
var_dump($adapter->getPaymentData($_GET['trxref'])) ; //you should clean this up.
//amplifypay adapter
var_dump($adapter->getPaymentData($_GET['tran_response'])); // clean up
//let's assume it is an enterprisey app
$interswitch = new class implements \Gbowo\Contract\Adapter\AdapterInterface
{
protected $interswitch;
public function __construct()
{
$this->interswitch = new \stdClass(new \ArrayObject(new \stdClass())); // It wasn't me
}
public function charge(array $data = [])
{
return "charged by interswitch";
}
};
$adapter = new \Gbowo\GbowoFactory(["interswitch" => $interswitch]); //add the interswith adapter as a custom one.
$interswitchAdapter = $adapter->createAdapter("interswitch");
$interswitchAdapter->charge(['a' => 'b', 'c' => 'd']);
namespace Vendor\AdapterName\Plugin;
use Gbowo/Contract/Plugin/PluginInterface;
use Gbowo\Exception\TransactionVerficationFailedException;
class ApiPinger implements PluginInterface
{
public function getPluginAccessor():string
{
return "pingApi"; //Oops.. Let's confirm if the api isn't dead before making any request. And it must be a string without parenthesis
}
/**
* You can also leave this method out but you must extend the `AbstractPlugin` class. Doing so, means you'd have to get rid of the plugin interface here as the abstract plugin already does that.
*/
public function setAdapter(AdapterInterface $adapter)
{
//useful for helpers like getting stuffs from "accessors" on the adapter instance like the already configured HttpClient object
$this->adapter = $adapter ;
return $this;
}
/**
* Ping the gateway Api
* @param bool $shouldThrow. Should an exception be thrown if the api is down ?.
* @return bool true - if the api is up and running.
false - if the api is down and $throw is set to false.
* @throws \Exception if the api is down and $throw is set to false.
*/
public function handle(bool $shouldThrow = false)
{
$response = $this->adapter->getHttpClient()->get("https://api.homepage.com");
if ($response->getStatusCode() === 200 ) {
return true;
}
if ($shouldThrow) {
throw TransactionVerficationFailedException::createFromResponse($response);
}
return false;
}
}
$adapter->addPlugin(new Vendor\AdapterName\Plugin\ApiPinger(PaystackAdapter::API_LINK));
//Usage like this
$adapter->pingApi(true);
$adapter->pingApi();