GithubHelp home page GithubHelp logo

code4mk / lara-nagad Goto Github PK

View Code? Open in Web Editor NEW
33.0 4.0 24.0 53 KB

Laravel Nagad payment mynagad

Home Page: https://code4mk.org

PHP 100.00%
nagad-payment laravel-payment laravel-nagad-payment code4mk bd-payment laravel

lara-nagad's Introduction

lara-nagad Bangladesh Nagad

Laravel Nagad payment BD

Installation

composer require code4mk/lara-nagad

Setup

1 ) vendor publish (config)

php artisan vendor:publish --provider="Code4mk\Nagad\NagadServiceProvider" --tag=config

1.1 ) if you are using Laravel before version 5.4, manually register the service provider in your config/app.php file

Code4mk\Nagad\NagadServiceProvider::class

2 ) Config setup

  • config/nagad.php
<?php

return [
    'sandbox_mode' => env('NAGAD_MODE', 'sandbox'),
    'merchant_id' => env('NAGAD_MERCHANT_ID','683002007104225'),
    'merchant_number' => env('NAGAD_MERCHANT_NUMBER','01711428036'),
    'callback_url' => env('NAGAD_CALLBACK_URL', 'http://127.0.0.1:8000/nagad/callback'),
    'public_key' => env('NAGAD_PUBLIC_KEY',''),
    'private_key' => env('NAGAD_PRIVATE_KEY','')
];

env setup

NAGAD_MERCHANT_ID=683002007104225
NAGAD_MERCHANT_NUMBER=01711428036
NAGAD_CALLBACK_URL=http://127.0.0.1:8000/nagad/callback
NAGAD_MODE=sandbox // sandbox or live
NAGAD_PUBLIC_KEY="" //sandbox <optional>
NAGAD_PRIVATE_KEY=""  // sandbox <optional>

Usage

get callback url

<?php
use NagadPayment;

$redirectUrl = NagadPayment::tnxID($id)
             ->amount($amount)
             ->getRedirectUrl();
return $redirectUrl;

verify payment // callback

<?php
use NagadPayment;

$verify = (object) NagadPayment::verify();
if($verify->status === 'Success'){
    $order = json_decode($verify->additionalMerchantInfo);
    $order_id = $order->tnx_id;
    // your functional task with order_id
}
if ($verify->status === 'Aborted') {
    dd($verify);
    // redirect or other what you want
}
dd($verify);

Note:

~Sandbox

  • Need a merchant account.
  • Register a Nagad number and need sandbox balance (contact with nagad)

~ Live

  • Need a merchant account (live server)
  • Contact with Nagad and provide your live server ip address.
  • provide support id ($sid) the nagad office

Live mode tips

Sandbox works fine but when you deploy your project on server you can't get any response and don't work payment system

How to enable nagad gateway on server

  • Contact with nagad, provide your ip and support ID which you will get from temporary route get-support-id . Nagad will be white-listed your ip and approve your merchant. Now your nagad gateway work properly on server.

~ temporary route (copy and paste)

Route::get('get-support-id',function(){
    $sid = NagadPayment::tnxID(1)
                 ->amount(100)
                 ->getSupportID();
    return $sid;
})

Demo

Any query

lara-nagad's People

Contributors

mostafa6765 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lara-nagad's Issues

Return a blank response from cPanel

Hi,
I've installed it on my project and it's working on localhost. But when I upload it into my cPanel server then it's return a blank respone from pay method.

$redirectUrl = NagadPayment::tnxID($id)
            ->amount($amount)
            ->getRedirectUrl();
        return response()->json($redirectUrl);

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.