Coder Social home page Coder Social logo

shahriar-shojib / nagad-payment-gateway Goto Github PK

View Code? Open in Web Editor NEW
26.0 1.0 11.0 152 KB

Node.js Library for accepting payments from Nagad

License: MIT License

JavaScript 3.57% TypeScript 96.43%
nagad-api nagad-api-library nagad-gateway nagad-payment nagad nodejs typescript npm javascript npm-library

nagad-payment-gateway's Introduction

nagad-payment-gateway

Test Suite Release

Nodejs library to accept nagad payments on your backend application

Features

  • Written in Typescript
  • No headaches when doing cryptographic operations, everything is handled inside the library.
  • Get Intellisense with vscode to avoid errors
  • Type definitions included, and all the documentation is provided as TSDoc comments

How to use

Installing the library

npm

npm install nagad-payment-gateway

yarn

yarn add nagad-payment-gateway


Initializing the library

javascript

file nagad.js

const { NagadGateway } = require('nagad-payment-gateway');

const config = {
	apiVersion: 'v-0.2.0',
	baseURL: process.env.BASE_URL,
	callbackURL: process.env.CALLBACK_URL,
	merchantID: process.env.MERCHANT_ID,
	merchantNumber: process.env.MERCHANT_NUMBER,
	privKey: '.keys/private.key',
	pubKey: '.keys/public.key',
	isPath: true,
};

const nagad = new NagadGateway(config);

module.exports = nagad;

typescript

Todo


Create a payment

try {
	const nagadURL = await nagad.createPayment({
		// -> get intellisense here
		amount: '100',
		ip: '10.10.0.10',
		orderId: `${Date.now()}`,
		productDetails: { a: '1', b: '2' },
		clientType: 'PC_WEB',
	});
	//redirect user to the nagad url
} catch (err) {
	console.log(err);
}

Verify a payment

try {
	const nagadURL = await nagad.verifyPayment(paymentRefID);
	//redirect user to the nagad url
} catch (err) {
	console.log(err);
}

More documentation coming soon


Contributing

  • Please Follow the code style and use the prettier config and eslint config provided in the repository
  • Feel free to open issues or pull request for any issues and bugfixes
  • If you want to implement new features or write documentation about existing features feel free to do it as well
  • To see a list of missing features or to-do's, please visit the project section of the github repository

License

MIT

DISCLAIMER: This software comes with absolutely no warranty and is not affiliated with the company Nagad in any way. Use at your own risk. Author and Contributors are not responsible for any financial damages, outages etc.

Author

Shahriar Shojib

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.