Coder Social home page Coder Social logo

beyonic-laravel's Introduction

About this library

This is a simple/basic implementation of beyonic payments in laravel 5

Actions supported

Note: You must have a valid Beyonic account to use this library

  • RECEIVING MONEY [Collection request]
  • SENDING MONEY [Payments]

For more information visit Beyonic

Installation

composer require fannypack/beyonic

For Laravel <= 5.4 Register service provider

FannyPack\Beyonic\BeyonicServiceProvider::class,

For Laravel <= 5.4 Register Facade

'Beyonic' => FannyPack\Beyonic\Beyonic::class,

For Laravel > 5.4 Service provider and Facade are discovered automatically

After the service provider is registered run this command

php artisan vendor:publish

This command will create a copy of the library's config file and migrations into your code base

beyonic.php

Run migrations to create beyonic_payments table to store your payment instances

php artisan migrate

Environment setup

The library loads configurations from the .env file in your application's root folder. These are the contents of beyonic.php

return [
    'apiKey' => env('BEYONIC_API_KEY', ''),
    'currency' => env('CURRENCY', 'UGX'),
    'callback_url' => env('CALLBACK_URL', ''),
    'account_id' => env('ACCOUNT_ID', ''),
];

Usage in context of your beyonic account

Using it with your models, add trait FannyPack\Beyonic\Billable to your models and make sure your model has a phone_number field

namespace App;

use FannyPack\Beyonic\Billable;
use Illuminate\Database\Eloquent\Model;

class Account extends Model
{
    use Billable;
}

Requesting payment from a billable instance, this method takes an optional phone number in case you want to provide a different number to withdraw the funds from and the method returns a FannyPack\Beyonic\Payment::class instance

$account = Account::find(1);
$payment = Beyonic::deposit($account, $amount, $reason, $optional_phone_number);
// or
$payment = $account->deposit($amount, $reason, $optional_phone_number);

Information about a Collection request

$payment = $account->payments[0]
$response = Beyonic::info($payment);
// or
$response = $payment->info();

Sending payment to th phone number associated with the billable instance, this method takes an optional phone number in case you want to provide a different number to deposit the funds to and the method returns a FannyPack\Beyonic\Payment::class instance

$payment = Beyonic::withdraw($account, $amount, $reason, $optional_phone_number);
// or
$payment = $account->withdraw($amount, $reason, $optional_phone_number);

For information about the response body visit Beyonic

Bugs

For any bugs found, please email me at [email protected] or register an issue at issues

beyonic-laravel's People

Contributors

mpaannddreew avatar

Watchers

 avatar  avatar

Forkers

makpascal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.