adelowo / laravel-gbowo by adelowo

Laravel bridge for the Gbowo payment library
25
1
2
Package Data
Maintainer Username: adelowo
Maintainer Contact: me@lanreadelowo.com (Lanre Adelowo)
Package Create Date: 2017-03-29
Package Last Update: 2019-01-21
Language: PHP
License: MIT
Last Refreshed: 2024-04-16 03:00:21
Package Statistics
Total Downloads: 25
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

Laravel-Gbowo - A Laravel bridge for Gbowo

Latest Version on Packagist Software License Build Status

Installation


$ composer require adelowo/laravel-gbowo

  • Append the GbowoServiceProvider to the provider key in config/app.php
Gbowo\Bridge\Laravel\GbowoServiceProvider::class
  • Set up a default adapter in config/services.php
<?php
//...other config values
"gbowo" => [
    "default" => "paystack"
];
 

This step is optionally but can be helpful when you are certain you wouldn't be switching adapters in multiple places in your app.

Only paystack and amplifypay are currently supported.

  • Optional, you can also make use of facades by adding this to the aliases key in config/app.php

"Gbowo" : Gbowo\Bridge\Laravel\Facades::class

Usage

Gbowo's official doc is highly recommendeded.


class BillingController extends Controller
{
    public function chargeCustomer(Request $request)
    {
        $adapter = app("gbowo")->adapter("paystack");
        // $adapter = app("gbowo")->adapter("amplifypay");

        
        $data = ["email" => $request->get('email') , "amount" => $request->get('amount')];
        
        return redirect($adapter->charge($data));
    }
}

Calling the adapter method without passing in an adapter name would return an instance of the default adapter set in the config file.

Adding custom adapters

If you have written a custom adapter, you can include this in your app by doing what is obtainable below in a ServiceProvider of your choice.


$config = ["key" => "value", "other" => "stuff"]; //some bootstrap options your adapter might need.

$this->app["gbowo"]->extend("voguepay" , function() use ($config)){
    return new VoguePayAdapter($config);
});

And you can access this new adapter anywhere in your code via


$voguePay = app("gbowo")->adapter("voguePay");

$voguePay->charge(['c' => 'd']);

Facades


use Gbowo\Bridge\Laravel\Facades

Gbowo::adapter("paystack")->charge([])

//You can call any method on the facade as you would in the normal instance. Do check the api methods

API methods

  • createPaystackAdapter()
  • createAmplifyPayAdapter()
  • extend(string $adapterName, Closure $callback)
  • adapter(string $name = null)

If $name is left null, the default adapter would be fetched by inspecting the value of config.services.gbowo.default

License

MIT