siddiquinoor/nagad-in-laravel
Composer 安装命令:
composer require siddiquinoor/nagad-in-laravel
包简介
Nagad Payment Gateway for Laravel
关键字:
README 文档
README
Nagad is one of the Mobile Financial Services in Bangladesh. This package is built for Nagad Payment Gateway for Laravel 6.x, 7.x and 8.x+
Contents
Installation
Install the package via composer:
composer require siddiquinoor/nagad-in-laravel:dev-master
Configuration
Add config file in your config directory:
php artisan vendor:publish --tag=nagad-config
-
This will publish and config file in
config_path()of your application. e.gconfig/nagad.php -
Configure the Nagad merchant account. Use
sandbox = truefor development stage. -
Be sure to set the timezone of you application to
Asia/Dhakain order to work with Nagad Payment Gate Way. To do this: go toconfig/app.phpand set'timezone' => 'Asia/Dhaka'
Usage
Set Nagad call back to our route
// in routes/web.php Route::get('/nagad/callback', 'NagadController@callback')->name('nagad.callback');
Name the route in the nagad config file.
//in config/nagad.php
'callback' => 'nagad.callback' // or use env variable to store
env setup
NAGAD_METHOD=sandbox NAGAD_MERHCANT_ID=YOUR_MERCHANTID NAGAD_MERHCANT_PHONE=YOUR_PHONE_NUMBER NAGAD_KEY_PUBLIC=YOUR_PUBLIC_KEY NAGAD_KEY_PRIVATE=YOUR_PRIVATE_KEY NAGAD_CALLBACK_URL=nagad.callback
To Start payment, in your NagadController:
use NagadLaravel\Nagad; use Illuminate\Http\Request; public function createPayment() { /** * 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 use this method: /** * 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()); } }
To receive error response use this in App/Exceptions/Handler.php:
public function render($request, Exception $exception) { if($exception instanceof NagadException) { //return custom error page when custom exception is thrown return response()->view('errors.nagad', compact('exception')); } return parent::render($request, $exception); }
Available Methods
For Checking-out
setOrderID(string $orderID):$orderIDto be any unique AlphaNumeric StringsetAmount(string $amount):$amountto be any valid currency numeric StringsetAddionalInfo(array $array):$arrayto be any array to be returned at callbacksetCallbackUrl(string $url):$urlto be any url string to be overidden the defualt callback url set in configcheckout(): 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):$requestto beIlluminate\Http\Requestinstanceverify(): to verify the response.success(): to check if transaction is succeed.getErrors(): to get the error and errorCode if fails transactions | returnsarray[]getVerifiedResponse(): to get the full verified response | returnsarray[]getAdditionalData(bool $object): to get the additional info passed during checkout.$objectis to set return object or array.
License
The MIT License (MIT). Please see License File for more information.
siddiquinoor/nagad-in-laravel 适用场景与选型建议
siddiquinoor/nagad-in-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Nagad API」 「Nagad Laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 siddiquinoor/nagad-in-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 siddiquinoor/nagad-in-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 siddiquinoor/nagad-in-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is nagad payment gateway for laravel
A PSR-7 compatible library for making CRUD API endpoints
Nagad payment gateway laravel
Paystation is a php library for Bangladeshi payment gateway provider. You can integrate this in your php application and get customer payment using mfs, credit card and so on
Alfabank REST API integration
Laravel nagad payment package
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-06