aamarpay.v2 is a library used for easy integration of aamarpay payment gateway with node applications
aamarpay.v2 হল একটি লাইব্রেরি যা নোড অ্যাপ্লিকেশনের সাথে aamarpay পেমেন্ট গেটওয়ে সহজে ইন্টিগ্রেশন করার জন্য ব্যাবহৃত হয়
- Easy setup and easy-to-use API
- Uses promises, so supports
async
await
syntax
Installation
npm i aamarpay.v2
Usage
import { Payment } from "aamarpay.v2";
const Start = async () => {
try {
const Pay = new Payment(
"aamarpaytest", // store id
"dbb74894e82415a2f7ff0ec3a97e4183", // signature key
false // false = sandbox , true = live
);
const res = await Pay.init({
data: {
amount: "100",
currency: "BDT",
cus_email: "nahid@gmail.com",
cus_name: "nahid hasan",
cus_phone: "01XXXXXXXX",
desc: "This is a demo",
tran_id: "202312171066nahid",
cus_add1: "demo address",
},
cancel_url: "/",
fail_url: "/",
success_url: "/",
});
console.log(res); //return the payment URL
} catch (error) {
console.log(error);
}
};
import { Payment } from "aamarpay.v2";
Payment is a class that makes an instance of a payment object that helps us to create a payment.
payment class Constructor has 3 Parameters
- store id = string
- signature key = string
- is Live = Booleans
new Payment("store_id", "signature_key", isLive);
Example
new Payment("aamarpaytest", "dbb74894e82415a2f7ff0ec3a97e4183", false);
this credential was provided by Aamarpay Sandbox docs check here
init method
[instance].init(payload);
replace instance to your payment object
Payload is an Object that has property 4 property
- data = object
- cancel_url = URL to redirect when the payment was canceled
- fail_url = URL to redirect when the payment was fail
- success_url = URL to redirect when the payment was successful and this endpoint also work as webhooks
Data Object Property :
{
amount: string;
currency: "BDT" | "USD" | "EUR"| "INR" | "PKR" | "CAD"| "AUD" | "CNY" | "RUB"| "SAR" | "QAR";
desc: string;
cus_name: string;
cus_email: string;
cus_phone: string;
tran_id: string; //this should uniq in every transaction
cus_city?: string; // optional
cus_state?: string; // optional
cus_country?: string; // optional
cus_postcode?: string; // optional
cus_add1?: string; // optional
cus_add2?: string; // optional
opt_a?: string; // optional
opt_b?: string; // optional
opt_c?: string; // optional
opt_d?: string; // optional
}
typeScript type:
import { AamarpayRequestData } from "aamarpay.v2";
and the init()
method returned a promise and the result was a URL for the payment page
Search method:
[instance].Search("transactions_id");
replace instance to your payment object
this method is used to retrieve the transaction information base on transaction id;
this return a promise and result is
{
pg_txnid: string;
mer_txnid: string;
risk_title: string;
risk_level: string | null;
cus_name: string;
cus_email: string;
cus_phone: string;
cus_add1: string;
cus_add2: string;
cus_city: string;
cus_state: string;
cus_postcode: string;
cus_country: string;
cus_fax: string;
ship_name: string | null;
ship_add1: string | null;
ship_add2: string | null;
ship_city: string | null;
ship_state: string | null;
ship_postcode: string | null;
ship_country: string | null;
desc: string | null;
merchant_id: string;
store_id: string;
amount: string;
amount_bdt: string;
pay_status: string;
status_code: string;
status_title: string;
cardnumber: string;
approval_code: string;
payment_processor: string;
bank_trxid: string;
payment_type: string;
error_code: string;
error_title: string;
bin_country: string;
bin_issuer: string;
bin_cardtype: string;
bin_cardcategory: string;
date: string;
date_processed: string;
amount_currency: string;
rec_amount: string;
processing_ratio: string;
processing_charge: string;
ip: string;
currency: string;
currency_merchant: string;
convertion_rate: string;
opt_a: string;
opt_b: string;
opt_c: string;
opt_d: string;
verify_status: string;
call_type: string;
email_send: string;
doc_recived: string;
checkout_status: string;
}
typeScript type:
import { TransactionInfo } from "aamarpay.v2";
if you want to know more check out aamarpay official website
terms
The software is given in its current state with no guarantees, whether explicitly stated or implied. This includes assurances of its suitability for a specific purpose, merchantability, or overall quality. The author or copyright holder cannot be held responsible for any claims, damages, or other liabilities arising from the use or transactions related to the software, whether through contract, tort, or any other legal grounds.