luova / nagad
Laravel nagad payment package
v1.0.3
2021-10-26 07:09 UTC
README
laravel nagad Bangladesh Nagad
Laravel Nagad payment BD
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+
Installation
composer require luova/nagad
Setup
1 ) vendor publish (config)
php artisan vendor:publish --tag=nagad
1.1 ) if you are using Laravel before version 5.4, manually register the service provider in your config/app.php file
Luova\Nagad\NagadServiceProvider::class
2 ) Config setup
config/nagad.php
<?php return [ 'projectPath' => env('APP_URL', 'http://127.0.0.1:8000/nagad/callback'), 'sandbox' => env("NAGAD_API_SENDBOX", "http://sandbox.mynagad.com:10080/remote-payment-gateway-1.0/api/dfs"), 'live' => env("NAGAD_API_LIVE", "https://api.mynagad.com/api/dfs"), 'public_key' => env('NAGAD_PUBLIC_KEY', 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjBH1pFNSSRKPuMcNxmU5jZ1x8K9LPFM4XSu11m7uCfLUSE4SEjL30w3ockFvwAcuJffCUwtSpbjr34cSTD7EFG1Jqk9Gg0fQCKvPaU54jjMJoP2toR9fGmQV7y9fz31UVxSk97AqWZZLJBT2lmv76AgpVV0k0xtb/0VIv8pd/j6TIz9SFfsTQOugHkhyRzzhvZisiKzOAAWNX8RMpG+iqQi4p9W9VrmmiCfFDmLFnMrwhncnMsvlXB8QSJCq2irrx3HG0SJJCbS5+atz+E1iqO8QaPJ05snxv82Mf4NlZ4gZK0Pq/VvJ20lSkR+0nk+s/v3BgIyle78wjZP1vWLU4wIDAQAB'), 'private_key' => env('NAGAD_PRIVATE_KEY', 'MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCJakyLqojWTDAVUdNJLvuXhROV+LXymqnukBrmiWwTYnJYm9r5cKHj1hYQRhU5eiy6NmFVJqJtwpxyyDSCWSoSmIQMoO2KjYyB5cDajRF45v1GmSeyiIn0hl55qM8ohJGjXQVPfXiqEB5c5REJ8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GAfmSciL0SWQFU1qjUcXRvCzCK1h25WrYS7E6pppm/xia1ZOrtaLmKEEBbzvZjXqv7PhLoh3OQYJO0NM69QMCQi9JfAxnZKWx+m2tDHozyUIjQBDehve8UBRBRcCnDDwU015lQN9YNb23Fz+3VDB/LaF1D1kmBlUys3//r2OV0Q4ECgYBnpo6ZFmrHvV9IMIGjP7XIlVa1uiMCt41FVyINB9SJnamGGauW/pyENvEVh+ueuthSg37e/l0Xu0nm/XGqyKCqkAfBbL2Uj/j5FyDFrpF27PkANDo99CdqL5A4NQzZ69QRlCQ4wnNCq6GsYy2WEJyU2D+K8EBSQcwLsrI7QL7fvQ=='), 'apiCredentials' => [ 'merchant_id' => env("NAGAD_MERCHENT_ID", ''), // Your merchant ID 'wallet' => env("NAGAD_WALLET", ''), // Your merchant Wallet number ], 'apiUrl' => [ 'initialize' => "/check-out/initialize/", 'complete' => "/check-out/complete/", 'verify' => "/verify/payment/", 'callback' => "/callback/nagad", // Your callback url ], 'currencyCode' => '050', // payment currency code 'status' => 'sandbox', //sandbox or live ];
env setup
NAGAD_MERCHENT_ID="" NAGAD_WALLET="" NAGAD_API_SENDBOX="" NAGAD_API_LIVE="" NAGAD_PUBLIC_KEY="" NAGAD_PRIVATE_KEY=""
Usage
get callback url
<?php use LNagad; class CartController extends Controller { use LNagad; public function order() { // Call to payment Nagad $this->nagadInitialize([ 'amount' => '10', // cart ammount 'transaction_id' => '3354asdf' // unique order transaction id or your order id ]); }
verify payment // callback
<?php use LNagad; class CartController extends Controller { use LNagad; public function callback(Request $request) { $payment_ref_id = $request->payment_ref_id; $verify = $this->NagadPyamentVerify($payment_ref_id); // dd($verify); // For check verification response // After Your code }
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