承接 code4mk/lara-nagad 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

code4mk/lara-nagad

最新稳定版本:v1.0.1

Composer 安装命令:

composer require code4mk/lara-nagad

包简介

Laravel nagad payment package

README 文档

README

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

统计信息

  • 总下载量: 2.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 35
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 34
  • Watchers: 2
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-22