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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pepco/nodejs-rest-sdk

v0.2.2

Published

NodeJS package to connect your application to Pasargad Bank Internet Payment Gateway through RESTful API

Readme

NodeJS SDK for Pasargad IPG

NodeJS package to connect your application to Pasargad Internet Payment Gateway through RESTful API

Installation

For installation, use npm package:

$ npm install @pepco/nodejs-rest-sdk

Usage

Redirect User to Payment Gateway

// Tip! Initialize this property in your payment service constructor method!
const PasargadApi = require('@pepco/nodejs-rest-sdk');
const pasargad = new PasargadApi(
    "YOUR_MERCHANT_CODE",
    "YOUR_TERMINAL_ID",
    "http://yoursite.com/redirect-url-here/",
    "certificate_file_location.xml"); 
    //e.q: 
    // const pasargad = new PasargadApi(xxxxxx,xxxxx,"https://pep.co.ir/ipgtest","cert.xml");

// Set Amount
pasargad.amount = 15000;

// Set Invoice Number (it MUST BE UNIQUE) 
pasargad.invoiceNumber = "4029";

// set Invoice Date with below format (Y/m/d H:i:s)
pasargad.invoiceDate = "2021/08/08 11:54:03";

// get the Generated RedirectUrl from Pasargad API (async request):
// output example: https://pep.shaparak.ir/payment.aspx?n=bPo+Z8GLB4oh5W0KVNohihxCu1qBB3kziabGvO1xqg8Y=  
pasargad.redirect().then(redirectURL => {
    // redirect user to `redirectURL`
    console.log(redirectURL);
});

Checking and Verifying Transaction

After Payment Process, User is going to be returned to your redirect_url.

payment gateway is going to answer the payment result with sending below parameters to your redirectURL (as QueryString parameters):

  • InvoiceNumber (IN field)
  • InvoiceDate (ID field)
  • TransactionReferenceID (tref field)

Store this information in a proper data storage and let's check transaction result by sending a check api request to the Bank:

// Set Transaction refrence id received in 
pasargad.transactionReferenceID = "636843820118990203";

// Set Unique Invoice Number that you want to check the result
pasargad.invoiceNumber = 4029;

// set Invoice Date of your Invoice
pasargad.invoiceDate = "2021/08/08 11:54:03";

// check Transaction result
pasargad.checkTransaction().then(response => {
    // you can handle the response here:
    console.log(response);
});

Successful result:

{
    "TraceNumber": 13,
    "ReferenceNumber": 100200300400500,
    "TransactionDate": "2021/08/08 11:58:23",
    "Action": "1003",
    "TransactionReferenceID": "636843820118990203",
    "InvoiceNumber": "4029",
    "InvoiceDate": "2021/08/08 11:54:03",
    "MerchantCode": 100123,
    "TerminalCode": 200123,
    "Amount": 15000,
    "IsSuccess": true,
    "Message": " "
}

If you got IsSuccess with true value, so everything is O.K!

Now, for your successful transaction, you should call verifyPayment() method to keep the money and Bank makes sure the checking process was done properly:

// Set Amount
pasargad.amount = 15000;

// Set Invoice Number (it MUST BE UNIQUE) 
pasargad.invoiceNumber = "4029";

// set Invoice Date with below format (Y/m/d H:i:s)
pasargad.invoiceDate = "2021/08/08 11:54:03";

// verify payment:
pasargad.verifyPayment().then(response => {
    // response
    console.log(response);
});

...and the successful response looks like this response:

{
 "IsSuccess": true,
 "Message": " ",
 "MaskedCardNumber": "5022-29**-****-2328",
 "HashedCardNumber": "2DDB1E270C598677AE328AA37C2970E3075E1DB6665C5AAFD131C59F7FAD99F23680536B07C140D24AAD8355EA9725A5493AC48E0F48E39D50B54DB906958182",
 "ShaparakRefNumber": "100200300400500"
}

Payment Refund

If for any reason, you decided to cancel an order in early hours after taking the order (maximum 2 hours later), you can refund the client payment to his/her bank card.

for this, use refundPayment() method:

// Set Unique Invoice Number that you want to check the result
pasargad.invoiceNumber = "4029";

// set Invoice Date of your Invoice
pasargad.invoiceDate = "2021/08/08 11:54:03";

// check Transaction result    
pasargad.refundPayment().then(response => {
        // handle response here:
        console.log(response);
    });

Support

Please use your credentials to login into Support Panel

Contact Author/Maintainer: Reza Seyf