Node AamarPay
Node JS and Express JS module for using AamarPay payment gateway in Bangladesh.
Features
- Easy setup and easy to use API
- Uses promises, so supports
async
await
syntax - Token generation and verification methods included
Installation
npm install aamarpay
Usage
const PAY = ; // A string of good length. Should be stored securely.const KEY = "OHZTDSRCU75APMKGYBHA0IL1GQDPXZHAGCAUAWOR9EXHVND9AAMEVEMAEZXIYLTR"; let ip = '20.20.20.20' domain = 'domain.com' storeId = 'storeid' signatureKey = 'abcdefgh' hashKey = KEY; PAY; let seed = 'ABCD' // can not be emptylet token = PAYconsole;console; PAY ;
API
init
It sets up the module for use, takes an object with 5 keys -
ip
the registered IP address for AamarPaydomain
the registered domain name for AamarPaystoreId
the store ID provided by AamarPay upon sign upsignatureKey
the signature key provided by AamarPay upon sign uphashKey
a randomized string to generate and verify tokens. It should be of good length. It also should be stored securely.
postdata:Promise
It is a method that makes the payment processing request with data
using curl and returns a promise. See example above and AamarPay documentation.
The promise resolves with an object with following properties -
statusCode
response status codedata
raw data returned from AamarPayheaders
response headerstrack
tracking id of the requested invoiceurl
payment url
The promise rejects with an object with following properties -
statusCode
response status codedata
raw data returned from AamarPayheaders
response headers
tokenseed:String
It creates a hashed token that can be verified later. seed
must be unique like a payment ID or order ID. this uses hashKey
to generate token.
verifyseed,token:Boolean
It verifies a token
for provided seed
using hashKey
.
License
The MIT License (MIT)
Copyright (c) 2020 Md. Naeemur Rahman (https://naeemur.github.io)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.