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

ssl-commerz-node

v1.0.4

Published

Module to implement sslcommerz payment gateway to NodeJs based app

Downloads

114

Readme

SSLCOMMERZ Payment Gateway integration in NodeJs (with MERN example)

It is npm package which provides functionalities to implement SSLCommerz Payment Gateway in Node Based Apps.

Installation

Via NPM

npm i ssl-commerz-node

Via YARN

yarn add ssl-commerz-node

MERN Stack Example (demo)

Set the parameters to make a request

const SSLCommerz = require("ssl-commerz-node");
const PaymentSession = SSLCommerz.PaymentSession;
require("dotenv").config();

// For live payment set first parameter `false` and for sandbox set it `true`
const payment = new PaymentSession(
  true,
  process.env.SSLCOMMERZ_STORE_ID,
  process.env.SSLCOMMERZ_STORE_PASSWORD
);

// Set the urls
payment.setUrls({
  success: "yoursite.com/success", // If payment Succeed
  fail: "yoursite.com/fail", // If payment failed
  cancel: "yoursite.com/cancel", // If user cancel payment
  ipn: "yoursite.com/ipn", // SSLCommerz will send http post request in this link
});

// Set order details
payment.setOrderInfo({
  total_amount: 1570, // Number field
  currency: "BDT", // Must be three character string
  tran_id: "ref12345667", // Unique Transaction id
  emi_option: 0, // 1 or 0
  multi_card_name: "internetbank", // Do not Use! If you do not customize the gateway list,
  allowed_bin: "371598,371599,376947,376948,376949", // Do not Use! If you do not control on transaction
  emi_max_inst_option: 3, // Max instalment Option
  emi_allow_only: 0, // Value is 1/0, if value is 1 then only EMI transaction is possible
});

// Set customer info
payment.setCusInfo({
  name: "Simanta Paul",
  email: "[email protected]",
  add1: "66/A Midtown",
  add2: "Andarkilla",
  city: "Chittagong",
  state: "Optional",
  postcode: 4000,
  country: "Bangladesh",
  phone: "010000000000",
  fax: "Customer_fax_id",
});

// Set shipping info
payment.setShippingInfo({
  method: "Courier", //Shipping method of the order. Example: YES or NO or Courier
  num_item: 2,
  name: "Simanta Paul",
  add1: "66/A Midtown",
  add2: "Andarkilla",
  city: "Chittagong",
  state: "Optional",
  postcode: 4000,
  country: "Bangladesh",
});

// Set Product Profile
payment.setProductInfo({
  product_name: "Computer",
  product_category: "Electronics",
  product_profile: "general",
});

See this for details: https://developer.sslcommerz.com/doc/v4/#ready-the-parameters

After setting the parameters initialize the payment

// use SSLCommerz_payment_init function/controller for payment request
exports.SSLCommerz_payment_init = async (req, res) => {
  // Initiate Payment and Get session key
  payment.paymentInit().then((response) => {
    console.log(response);
    // res.send(response);
  });
}

This link containes details about the response parameters: https://developer.sslcommerz.com/doc/v4/#returned-parameters

Response Parameters Examples

After Success

console.log(response["status"]);

SUCCESS

console.log(response["sessionkey"]);

D37CD2C0A0D322991531D217E194F981

console.log(response["GatewayPageURL"]);

https://sandbox.sslcommerz.com/EasyCheckOut/testcded37cd2c0a0d322991531d217e194f981

After Failure (Wrong Store ID)

console.log(response["status"]);

FAILED

console.log(response["failedreason"]);

Store Credential Error Or Store is De-active

The GatewayPageURL is the url of the payment page.