📦 Shepa.com Node.js Module
By using this package, you'll be able to work with Shepa.com REST Api in Node.js (Back-End) without any problem! This package is usable for all Node.js Frameworks such as Express.js, Hapi.js, Sails.js, Adonis.js or others.
This package uses ECMASCRIPT 6 features so make sure that your Node.js version supports it.
First step, Installation and Initialization
First of all, install the module with NPM command:
$ npm install shepa-payment-getaway --save
Then, create an instance of Payir class and pass your Gateway API KEY to it:
const Shepa = ;const gateway = 'YOUR API KEY|sandbox';
Second step, Send Request
After initializing, you should send a payment request in order to receive the
transId and redirect user to the Bank.
Hopefuly, you can get rid of the Callback functions by using Promises:
First parameter is
amount of the transaction, the second one is your
callback URL and the third one is the
mobile (optional) and the third one is the
If operations are done successfully, you'll have access to payment URL in
then, otherwise you can read error message in
The error message might be a Farsi text; Therefore, make sure your page supports UTF-8 encoding.
Third step, Verify Request
When user perform the transaction, it will redirect to your callback URL, so you should verify that in a POST route.
The only parameter of the
verify method is your POST request body. There are differences between Node.js web frameworks so you should pass it accurate. For example:
// How to access to POST data// Express.jsconsole;// Hapi.jsconsole;
express.js framework we will have:
When transaction is done,
then will have an input object that contains following values:
|refid||The refid of transaction|
|transId The unique id of the transaction|
|amount||The amount of transaction|
|cardNumber||The User's bank card number|
sandbox string instead of your gateway API Key, you can test your code.
If you need a sample code, you can take a look at
This package is under Apache 2.0 license.