GithubHelp home page GithubHelp logo

dipesh79 / laravelesewa Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 22 KB

Laravel Esewa - A simple laravel package to integrate esewa payment.

Home Page: https://dipesh79.github.io/LaravelEsewa/

PHP 100.00%
esewa esewa-api laravel laravel-package payment

laravelesewa's Introduction

Laravel Esewa Package

Laravel Esewa

This Laravel package allows you to create payment using Esewa.

Usage/Examples

Install Using Composer

composer require dipesh79/laravel-esewa

Add One Variable in .env

You can get marchant id from Esewa

ESEWA_MERCHANT_ID="Esewa Merchant Id"
ESEWA_ENV = "Sandbox" or "Live"

Publish Vendor File

php artisan vendor:publish --provider="Dipesh79\LaravelEsewa\EsewaServiceProvider"

or

php artisan vendor:publish

And publish "Dipesh79\LaravelEsewa\EsewaServiceProvider"

Redirect the user to payment page from your controller

use Dipesh79\LaravelEsewa\LaravelEsewa;

//Your Controller Method
public function esewaPayment()
{
    //Store payment details in DB with pending status
    $payment = new LaravelEsewa();
    $amount = 123; 
    $order_id = 251264889; //Your Unique Order Id
    $tax_amount = 0; //Tax Amount. If there is not tax amount then keep it 0
    $service_charge = 0; // Serivce Charge. If there is no service charge then keep it 0
    $delivery_charge = 0; // Delivery Charge. If there is no delivery charge then keep it 0.
    $su = route('success.url);
    $fu = route('fail.url);
    return redirect($payment->esewaCheckout($amount,$tax_amount,$service_charge,$delivery_charge,$order_id,$su,$fu))
}

After Successfull Payment esewa will redirect the user to your success url and you can change the payment status to Success else you can change the status to Fail when esewa redirect user to fail url.

Success Payment Case

public function esewaSuccess(Request $request)
{
    $order_id = $request->oid;
    $payment = Payment::where('order_id', $order_id)->first();
    $payment->status = "Success";
    $payment->save();

    //Other Tasks
           
}

Fail Payment Case

public function esewaFail(Request $request)
{
    $payment = Payment::where('order_id', $request->oid)->first();
    $payment->status = "Fail";
    $payment->save();
    //Other Tasks           
}

License

MIT

Author

Support

For support, email [email protected].

laravelesewa's People

Contributors

dipesh79 avatar

Stargazers

 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.