Giter Club home page Giter Club logo

laravel-walletone's Introduction

Laravel package for integrating WalletOne payment gateway into laravel app

Packagist Version GitHub last commit License

Package that integrates WalletOne API into your Laravel app.

Install

Via Composer

$ composer require allanvb/laravel-walletone

If you're using Laravel 5.5 or above, the package will automatically register provider and facade.

Laravel 5.4 and below

Add Allanvb\LaravelWalletOne\Providers\WalletoneServiceProvider to the providers array in your config/app.php:

'providers' => [
    // Other service providers...

    Allanvb\LaravelWalletOne\Providers\WalletoneServiceProvider::class,
],

Add an alias in your config/app.php:

'aliases' => [
    ...
    'WalletOne' => Allanvb\LaravelWalletOne\Facades\WalletOne::class,
],

Or you can use the facade class when needed:

use Allanvb\LaravelWalletOne\Facades\WalletOne;

Configuration

You can use php artisan vendor:publish to copy the configuration file to your app's config directory:

$ php artisan vendor:publish --provider="Allanvb\LaravelWalletOne\Providers\WalletoneServiceProvider" --tag="config"

Then update config/wallet-one.php with your credentials. Also you can update your .env file with the following:

WALLETONE_MERCHANT=merchant_id
WALLETONE_SECRET=secret_key
WALLETONE_SIGNATURE=signature_method
WALLETONE_CURRENCY=currency
WALLETONE_SUCCESS=success_url
WALLETONE_FAIL=fail_url

Usage:

To use the WalletOne Library you can access the facade, or request the instance from the service container:

WalletOne::make($orderID, $amount, $description, $options);

Or

app('walletone')->make($orderID, $amount, $description, $options);

Parameters:

  • $orderID - (string) ID of user order on your e-commerce (required).
  • $amount - (float) Amount of money the user has to pay (required).
  • $description - (string) Payment description (required).
  • $options - (array) Any other options you want to save on WalletOne service, or get back in response.

In order to create payment form for user, you have to get all post params by using getParams() method.

$params = WalletOne::getParams();

Then send this params to your view and create form.

As form action use WalletOne::API_URL.

In order to get response from WalletOne service, you have to define a post route inside your web.php. This route should use \Allanvb\LaravelWalletOne\Http\Middleware\WalletonePay::class middleware.

You can add this middleware to your Kernel.php inside App\Http folder.

    protected $routeMiddleware = [
        // Other service providers...
        
        'walletone-payment' => \Allanvb\LaravelWalletOne\Http\Middleware\WalletonePay::class
    ];

Then you can use it as following:

Route::post('/payment-webhook', 'YourController')->middleware('walletone-payment');

NOTE:

  • Your controller should return WalletOne::response() method !
  • Don't forget to add your route into $except param of VerifyCsrfToken middleware !

Each request to your route will generate a SuccessPayment or FailedPayment event, so all you have to do is to define a event listener for each of them.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

This package is actually a continuity of pdazcom/laravel-walletone whose author is Konstantin A.

License

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

laravel-walletone's People

Contributors

allanvb avatar

Watchers

 avatar

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.