xenon/nagad-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

xenon/nagad-api

Composer 安装命令:

composer require xenon/nagad-api

包简介

This is Bangladeshi nagad payment gateway api development library for php. This library can be used easily as pacakge dependency in your php application.

README 文档

README

Nagad api php xenon nagad api

Xenon/NagadApi

Features

  • Easy Installation
  • Easy Payment Processing
  • Composer based installation
  • Verify Payment
  • Demo Invoice Code Generate

Install Using Composer

composer require xenon/nagad-api

Example Code

<?php

use Xenon\NagadApi\Helper;
use Xenon\NagadApi\Base;

require 'vendor/autoload.php';

/**
 * ==============================================================================
 * all configuration are used here for demo purpose.
 * for use in dev mode use 'development'
 * for use in production mode use 'production'
 * ===============================================================================
 **/
$config = [
    'NAGAD_APP_ENV' => 'development', // development|production
    'NAGAD_APP_LOG' => '1',
    'NAGAD_APP_MERCHANTID' => '6800000025', //demo
    'NAGAD_APP_MERCHANT_PRIVATE_KEY' => 'MIIEvFAAxN1qfKiRiCL720FtQfIwPDp9ZqbG2OQbdyZUB8I08irKJ0x/psM4SjXasglHBK5G1DX7BmwcB/PRbC0cHYy3pXDmLI8pZl1NehLzbav0Y4fP4MdnpQnfzZJdpaGVE0oI15l',
    'NAGAD_APP_MERCHANT_PG_PUBLIC_KEY' => 'MIIBIjANBc54jjMJoP2toR9fGmQV7y9fzj',
    'NAGAD_APP_TIMEZONE' => 'Asia/Dhaka',
];

$nagad = new Base($config, [
    'amount' => 10,
    'invoice' => Helper::generateFakeInvoice(15, true),
    'merchantCallback' => 'https://example.com/payment/success/id=4',
]);

Method-1 : Use for website

$status = $nagad->payNow($nagad); //will redirect to payment page

Method-2 : Return Redirection url . You can use this according to need

$paymentUrl = $nagad->payNowWithoutRedirection($nagad); //will return payment url like below. You can use that url and do whatever u want to get payment from clients. 
http://sandbox.mynagad.com:10060/check-out/MDYyODAwNTcyNTYxNi42ODMwMDIwMDcxMDQyMjUuOU5PTEFVNkVaWkdUWVRBLmJiZGMyNTE3MTVmZTNiNjIzN2Zk

After that use below method for extracting payment response that will return an array

$successUrl = 'https://example.com/payment/success/id=4/?merchant=683XXXX225&order_id=CKH060JXXXXXFRA2&payment_ref_id=MXXXXXXXXtIMDYwSjFRSlBRMUZSQTIuMTg0NTE2Yzc3ZmEzNmEwZTJlZjk=&status=Success&status_code=00_0000_000&message=Successful%20Transaction&payment_dt=20211123235008&issuer_payment_ref=MTEyMzIzNDg1NzUwOS42ODMwMDIwMDcxMDQyMjUuQ0tIMDYwSjFRSlBRMUZSQTIuMTg0NTE2Yzc3ZmEzNmEwZTJlZjk=';
$response = Helper::successResponse("$successUrl");

Array
(
    [merchant] => 683XXXX225
    [order_id] => CKH060JXXXXXFRA2
    [payment_ref_id] => MXXXXXXXXtIMDYwSjFRSlBRMUZSQTIuMTg0NTE2Yzc3ZmEzNmEwZTJlZjk=
    [status] => Success
    [status_code] => 00_0000_000
    [message] => Successful Transaction
    [payment_dt] => 20211123235008
    [issuer_payment_ref] => MTEyMzIzNDg1NzUwOXXXXXtIMDYwSjFRSlBRMUZSQTIuMTg0NTE2Yzc3ZmEzNmEwZTJlZjk=
)

For payment verification use below method. You will then get below json as response.

$helper = new Helper($config);
$response = $helper->verifyPayment($response['payment_ref_id']);

Payment Verification Response

{
	merchantId: "683XXXX225",
	orderId: "CKH060JXXXXXFRA2",
	paymentRefId: "MXXXXXXXXtIMDYwSjFRSlBRMUZSQTIuMTg0NTE2Yzc3ZmEzNmEwZTJlZjk=",
	amount: "16",
	clientMobileNo: "016****5428",
	merchantMobileNo: "01XXXXXXX10",
	orderDateTime: "2021-11-23 23:48:22.0",
	issuerPaymentDateTime: "2021-11-23 23:50:08.0",
	issuerPaymentRefNo: "000XXXW",
	additionalMerchantInfo: null,
	status: "Success",
	statusCode: "000",
	cancelIssuerDateTime: null,
	cancelIssuerRefNo: null
}

Maintainer

Contributors

Important Information:

Sandbox Environment

  1. Need sandbox details for sandbox testing. Check your email that you have got from nagad authority
  2. Use sandbox details such as pgpublickey, privatekey, merchant-id for sandbox testing
  3. You need to register a mobile number for sandbox testing. Contact with your account manager for doing this
  4. You should test environment before going to live

Live Environment

  1. Need production details for production final. You will get through email
  2. Your server ip/domain and callback url should be whitelisted before running in production. You can contact with nagad team using mail or other system

Login to your Nagad Merchant Panel

https://auth.mynagad.com:10900/authentication-service-provider-1.0/login

Step 1: In the Merchant Portal, Go to Merchant Integration Details under Merchant Management Menu. You will get the Merchant ID which is your Merchant ID for Integration.

Then, Click on “Key Generate” and Download the Merchant Private Key and Merchant Public Key.

Step 2: _Go to Merchant Integration under Merchant Management Menu. Put your Call Back URL and Upload the Merchant Public Key which you have downloaded in Step 1. Add and Submit!_

Step 3: _Usage Production Details . You have to use public key and private key that you have downloaded!_

  1. If you have any question/query then email me arif98741@gmail.com
  2. Do Code, Be Crazy

### If you find any kind of issue or bug you are highly encouraged to report. For reporting use [issues option](https://github.com/arif98741/nagadApi/issues) For can also add pull request. For pull request you should use **dev** branch. Because our **master** branch is serving at this moment for usage around community. We dont want to messup

License

MIT

xenon/nagad-api 适用场景与选型建议

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

它主要适用于以下技术方向: 「api」 「payment gateway」 「nagad」 「nagad payment gateway」 「Bangladeshi payment gateway」 「nagad php library」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 6.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 46
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 46
  • Watchers: 4
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-24