定制 dgvai/laravel-nagad 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dgvai/laravel-nagad

Composer 安装命令:

composer require dgvai/laravel-nagad

包简介

Nagad Payment Gateway for Laravel (Bangladesh)

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock

Nagad is one of the Financial Services in Bangladesh. This package is built for Nagad Payment Gateway for Laravel 6.x, 7.x and 8.x+

Contents

Installation

You can install the package via composer:

composer require dgvai/laravel-nagad

Setting up your configuration

Extract the nagad config files:

php artisan vendor:publish --tag=nagad-config
  • This will publish and config file in config_path() of your application. Eg. config/nagad.php

  • Configure the configurations for the nagad merchant acocunt. Use sandbox = true for development stage.

  • Be sure to set the timezone of you application to Asia/Dhaka in order to work with Nagad PG. To do this: go to config/app.php and set 'timezone' => 'Asia/Dhaka'

Usage

NagadPG uses three stages of payment process, and two of theme are simultaneous. To get started, first you have to setup a callback route (GET) for the Nagad Callback and name the route in the nagad config file.

    // in routes/web.php
    Route::get('/nagad/callback', 'NagadController@callback')->name('nagad.callback');

    //in config/nagad.php
    'callback' => 'nagad.callback' // or use env variable to store

To Start payment, in your controller:

    // in SomeController.php
    use DGvai\Nagad\Facades\Nagad;

    public function createPayement() 
    {
        /**
         * Method 1: Quickest
         * This will automatically redirect you to the Nagad PG Page
         * */

        return Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->checkout()
            ->redirect();
        
        /**
         * Method 2: Manual Redirection
         * This will return only the redirect URL and manually redirect to the url
         * */

        $url = Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->checkout()
            ->getRedirectUrl();

        return ['url' => $url];


        /**
         * Method 3: Advanced 
         * You set additional params which will be return at the callback
         * */

        return Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->setAddionalInfo(['pid' => 9, 'myName' => 'DG'])
            ->checkout()
            ->redirect();


        /**
         * Method 4: Advanced Custom Callabck
         * You can set/override callback url while creating payment
         * */

        return Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->setAddionalInfo(['pid' => 9, 'myName' => 'DG'])
            ->setCallbackUrl("https://manual-callback.url/callback")
            ->checkout()
            ->redirect();
    }
    

To receive the callback response, in your callback controller method:

     // in CallbackController.php
    use DGvai\Nagad\Facades\Nagad;
    use Illuminate\Http\Request;

    /**
     * This is the routed callback method
     * which receives a GET request.
     * 
     * */

    public function callback(Request $request)
    {
        $verified = Nagad::callback($request)->verify();
        if($verified->success()) {

            // Get Additional Data
            dd($verified->getAdditionalData());
            
            // Get Full Response
            dd($verified->getVerifiedResponse());
        } else {
            dd($verified->getErrors());
        }
    }

Available Methods

For Checking-out

  • setOrderID(string $orderID) : $orderID to be any unique AlphaNumeric String
  • setAmount(string $amount) : $amount to be any valid currency numeric String
  • setAddionalInfo(array $array) : $array to be any array to be returned at callback
  • setCallbackUrl(string $url) : $url to be any url string to be overidden the defualt callback url set in config
  • checkout() : to initiate checkout process.
  • redirect() : to direct redirect to the NagadPG Web Page.
  • getRedirectUrl() : instead of redirecting, getting the redirect url manually.

For Callback

  • callback($request) : $request to be Illuminate\Http\Request instance
  • verify() : to verify the response.
  • success() : to check if transaction is succeed.
  • getErrors() : to get the error and errorCode if fails transactions | returns array[]
  • getVerifiedResponse() : to get the full verified response | returns array[]
  • getAdditionalData(bool $object) : to get the additional info passed during checkout. $object is to set return object or array.

Changelog

Please see CHANGELOG for more information what has changed recently.

License

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

dgvai/laravel-nagad 适用场景与选型建议

dgvai/laravel-nagad 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.77k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2020 年 09 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 dgvai/laravel-nagad 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dgvai/laravel-nagad 我们能提供哪些服务?
定制开发 / 二次开发

基于 dgvai/laravel-nagad 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-23