hyperpay-sdk
v1.2.418
Published
hyperpay-sdk is the hyperpay api integration package
Downloads
22
Readme
hyperpay-sdk
Overview
The hyperpay-sdk package provides a convenient set of utilities for interacting with the HyperPay API, facilitating operations such as virtual card application, physical card binding, and KYC (Know Your Customer) processes.
Installation
hyperpay-sdk requires Node.js v18+ to run.
Install the dependencies and devDependencies and start the server.
npm install --save hyperpay-sdk
Usage
Initialize HyperPay Client
import { HyperPayHelper , HyperPayClient} from "hyperpay-sdk";
const HyperConnection = new HyperPayClient(
'https://sandbox.hyperpay.io', // base url
'your_merchant_API_KEY', // merchant API key
'path/to/your/private_key.pem',
'path/to/your/public_key.pem'
);
const HyperPay = new HyperPayHelper(HyperConnection);
Virtual Card Application
const data: any = {
"user_id": string,
"first_name": string,
"last_name": string,
"email": string,
"country_code": string,
"first_recharge_amount": string,
"mobile_code": string,
"mobile": string,
"card_type_id": string // from hyperpay
}
const timestamp = new Date().getTime().toString();
const mc_trade_no = HyperPay.generateMcTradeNo(data.user_id, data.card_type_id, data.first_name);
const request = HyperPay.virtualCardApplyRequest({ ...data, mc_trade_no });
const signHeader = HyperPay.signHeader(request, timestamp);
HyperPay.cardApplicationExpressV4(request, signHeader);
Physical Card Binding
const bindData = {
"card_no": "5554790000007009",
"envelope_no": "888888",
"mc_trade_no": "48d2741747a4493223feb22",
"user_identifier": "[email protected]"
}
HyperPay.bindingPhysicalCard(bindData);
Physical Card Binding KYC
const bindingKycData = {
mc_trade_no: "string",
email: "string",
first_name: "string",
last_name: "string",
mobile: "string",
mobile_code: "string",
address: "string",
birthday: "string", // YYYY-MM-DD
city: "string",
country_id: "number",
doc_no:"number",
doc_type: "number",
emergency_contact: "string",
gender: "number", // 1 for male, 2 for female
nationality_id: "number",
state: "string",
zip_code: "string",
sign_img: "string",// base64
front_doc: "string",// base64
mix_doc: "string"// base64
};
const request = HyperPay.physicalCardBindingKyc(bindingKycData);
const signHeader = HyperPay.signHeader(request, timestamp);
HyperPay.cardApplicationKYCBindingV4(request, signHeader);
Card Application Information
HyperPay.queryCardApplicationResult(mc_trade_no)
Card Bank details Information
hyperpay.bankCardDetailV2(cardID)
Note
Ensure to replace placeholder values like YOUR_MERCHANT_ID, and update file paths for the private and public keys according to your project structure.
License
ISC
Free Software, Hell Yeah!