npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kapitalbank

v1.0.9

Published

Kapitalbank Payment Gateway

Downloads

4

Readme

KapitalBank Payment API with Node.js

The KapitalBank Payment Integration library is a Node.js module that facilitates seamless integration with KapitalBank's payment gateway. This library allows you to create orders, complete transactions, reverse transactions, and retrieve payment status and information with ease.

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Installation
  4. Usage
  5. License
  6. Disclaimer

Introduction

The KapitalBank Payment Integration library simplifies the integration of KapitalBank's payment gateway into Node.js applications. It provides methods to interact with the payment gateway, enabling the creation and management of payment orders.

Prerequisites

Before using this library, ensure you have the following prerequisites:

  1. Node.js installed on your server or development environment.
  2. Valid KapitalBank merchant credentials.
  3. SSL certificate and private key files for secure communication.

Installation

To use the KapitalBank Payment Integration library in your Node.js project, you need to install it via npm. Open a terminal and run the following command:

npm install kapitalbank@latest

Usage

Initialize

Import the KapitalBank class and initialize it with the required parameters:

const KapitalBank = require('kapitalbank');

const kb = new KapitalBank({
   merchantId: "YOUR_MERCHANT_ID",
   approveUrl: "APPROVE_URL",
   cancelUrl: "CANCEL_URL",
   declineUrl: "DECLINE_URL",
   liveMode: false,
   certFilePath: "CERT_FILE_PATH",
   keyFilePath: "KEY_FILE_PATH",
   defaultLanguage: "EN",
   currency: "944"
});

Configuration parameters

The KapitalBank class can be configured by passing appropriate values to its constructor. The available configuration options are:

  • merchantId: Your merchant ID.
  • approveUrl: The URL where successful payments will be redirected.
  • cancelUrl: The URL where canceled payments will be redirected.
  • declineUrl: The URL where declined payments will be redirected.
  • liveMode: Set to true for live mode, false for test mode.
  • certFilePath: The path to your SSL certificate file.
  • keyFilePath: The path to your SSL key file.
  • defaultLanguage: The default language for orders (optional, defaults to 'EN').
  • currency: The default currency for orders (optional, defaults to '944').

Ensure that you provide the correct values for your environment.

Create an Order

Use the createOrder method to create a new payment order:

const amount = 100;
const description = "ORDER_DESCRIPTION";
const preAuth = false;

const orderResult = await kb.createOrder(amount, description, preAuth);
console.log(orderResult);

Response:

{
   "success": true,
   "data": {
      "amount": 100,
      "orderId": "ORDER_ID",
      "sessionId": "SESSION_ID",
      "description": "ORDER_DESCRIPTION",
      "currency": 944,
      "lang": "EN",
      "paymentUrl": "https://tstpg.kapitalbank.az/index.jsp?ORDERID=ORDER_ID&SESSIONID=SESSION_ID",
      "orderType": "ORDER_TYPE"
   }
}

Complete an Order

Complete a payment order using the completeOrder method:

const orderId = "ORDER_ID";  // Replace with your order ID
const sessionId = "SESSION_ID";  // Replace with your session ID

const completionResult = await kb.completeOrder(orderId, sessionId, amount, description, lang);
console.log(completionResult);

Reverse a Transaction

Reverse a payment transaction with the reverseOrder method:

const orderId = "ORDER_ID";  // Replace with your order ID
const sessionId = "SESSION_ID";  // Replace with your session ID

const reversalResult = await kb.reverseOrder(orderId, sessionId, description, lang);
console.log(reversalResult);

Response:

{
  "success": true,
  "data": { 
     "orderId": 662685, 
     "respCode": "", 
     "respMessage": ""
  }
}

Get Order Status

Retrieve the status of a payment order using the getOrderStatus method:

const orderId = "ORDER_ID";  // Replace with your order ID
const sessionId = "SESSION_ID";  // Replace with your session ID

const status = await kb.getOrderStatus(orderId, sessionId, lang);
console.log(status);

Response:

{
   "success": true,
   "data": {
      "orderId": "ORDER_ID",
      "orderStatus": "ORDER_STATUS"
   }
}

Get Order Information

Obtain detailed information about a payment order with the getOrderInformation method:

const orderId = "ORDER_ID";  // Replace with your order ID
const sessionId = "SESSION_ID";  // Replace with your session ID

const info = await kb.getOrderInformation(orderId, sessionId, lang);
console.log(info);

Response:

{
   "success": true,
   "data": {
      "orderId": "ORDER_ID",
      "orderStatus": "ORDER_STATUS",
      "sessionId": "SESSION_ID",
      "createDate": "2023-09-17T09:39:05.000Z",
      "lastUpdateDate": null,
      "payDate": null,
      "amount": 100,
      "currency": "944",
      "orderLanguage": "EN",
      "description": "ORDER_DESCRIPTION",
      "approveUrl": "APPROVE_URL",
      "cancelUrl": "CANCEL_URL",
      "declineUrl": "DECLINE_URL",
      "receipt": "",
      "twoId": "",
      "refundAmount": "",
      "refundCurrency": null,
      "refundDate": null,
      "extSystemProcess": "0",
      "orderType": "Purchase",
      "orderSubType": "",
      "fee": 0,
      "TWODate": "",
      "TWOTime": ""
   }
}

License

This library is released under the MIT License. See the LICENSE file for details.

Disclaimer

This library is not officially maintained or endorsed by KapitalBank. Use it at your own risk.