Download the PHP package prevailexcel/laravel-bani without Composer

On this page you can find all versions of the php package prevailexcel/laravel-bani. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-bani

laravel-bani

Latest Stable Version

A Laravel Package for working with Bani Payments seamlessly.

This package also allows you to receive webhooks from Bani which it verifies for you and processes the payloads. It also implements The Bani Pop Payment Widget and handles the callback for laravel. You can start collecting payment in fiat and crypto payments in minutes.

Installation

PHP 5.4+ or HHVM 3.3+, and Composer are required.

To get the latest version of Laravel Bani, simply require it

Or add the following line to the require block of your composer.json file.

You'll then need to run composer install or composer update to download it and have the autoloader updated.

Once Laravel Bani is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.

If you use Laravel >= 5.5 you can skip this step and go to configuration

Also, register the Facade like so:

Configuration

You can publish the configuration file using this command:

A configuration-file named bani.php with some sensible defaults will be placed in your config directory:

General payment flow

This is how the payment flow should be like:

1. Collect Customer Order Data

You have to collect necessary information from the user about what they are paying for and the amount. These usually include Email, Amount, Phone Number, First name and last name. You can do this from your blade form directly (if you're building a website) or from the client app via a request.

2. Get the Bani Pop Widget or call the methods you want.

Bani allows users to pay without leaving your website or app. So you can call the payWithWidget() to get the Bani Pop Widget and your user can complete payment.

If you want to implement your own UI or you're building an API, you can use a variety of fluent methods you can use to start and complete the payment. You can use bankTransfer(),mobileMoney(),payWithCrypto(),startPayWithOpay() and even more.

3. You service the customer after payment

After having completed payment, you have to confirm the payment. This package helps handle webhook in a breeze. It also helps you handle callback if you use the pop widget.

As recommended, use the webhook response which this package verifies for you and then mark their order as paid and send them to a thank you page, send an email or whatever you want to do.

Usage

Open your .env file and add all the necessary keys like so:

If you are using a hosting service like heroku, ensure to add the above details to your configuration variables. Remember to change BANI_ENV to 'live' and update the keys when you are in production

Next, you have to setup your routes.

There are 3 routes you should have to get started.

  1. To initiate payment
  2. To setup callback (if you want to use the payWithWidget()) - Route::callback.
  3. To setup webhook and handle the event responses - Route::webhook.

OR

Lets pay with widget now.

This opens the widget and your user completes payment. The packages redirects to the handleGatewayCallback() which veifies the payment and then you can use the payment data.

To test with bank transfer, after selecting bank, copy the account and head to https://demo-checkout.getbani.com/test_bank/ to make test payment and then come back to your site and click on "I've paid {amount}" button.

Lets pay with bank transfer now.

To get customer ref, you can create the bani()->createCustomer($userdata) method wth user details or find the user via phone bani()->customer("+2348011111111") to get the user details.

This will return data that includes the account details which you will display or send to your user to make payment. You can listen to the webhook and service the user. Write the heavy operations inside the handleWebhook() method.

This package recommends to use a queued job to proccess the webhook data especially if you handle heavy operations like sending mail and more

How does the webhook routing Route::webhook(Controller::class, 'methodName') work?

Behind the scenes, by default this will register a POST route 'bani/webhook' to the controller and method you provide. Because the app that sends webhooks to you has no way of getting a csrf-token, you must add that route to the except array of the VerifyCsrfToken middleware:

A sample form will look like so:

When clicking the submit button the customer gets redirected to the Pop Widget.

So now the customer did some actions there (hopefully he or she paid the order) and now the package will redirect the customer to the Callback URL Route::callback().

We must validate if the redirect to our site is a valid request (we don't want imposters to wrongfully place non-paid order).

In the controller that handles the request coming from the payment provider, we have

Bani::getPaymentData() - This function calls the verifyTransaction() methods and ensure it is a valid transaction else it throws an exception.

Some fluent methods this package provides are listed here.

Customer

Collecting Payment

Verification

Misc

Todo

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!

Don't forget to follow me on Twitter! and also follow me on LinkedIn!

Also check out my page on medium to catch articles and tutorials on Laravel follow me on medium!

Thanks! Chimeremeze Prevail Ejimadu.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-bani with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version ^7.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package prevailexcel/laravel-bani contains the following files

Loading the files please wait ....