0.0.11 • Published 9 years ago
@ostad/moth v0.0.11
Moth for shaparak!
Description
This package made to make easy to deal with shaparak terminal however it's so soon to use it.
Installation
npm install @ostad/moth --save
Settings
For using you have to save your terminal settings in config/bank.json with format like this.
{
"default": {
"name": "bankName",
"description": "",
"portals": {
"host": "pep.shaparak.ir",
"pay": "/gateway.aspx",
"result": "/CheckTransactionResult.aspx",
"verify": "/VerifyPayment.aspx",
"refund": "/doRefund.aspx"
},
"metchanId": "123456",
"terminalId": "654321",
"key": "private pem key"
},
"shop2": {
"name": "pasargad",
"description": "",
"portals": {
"host": "pep.shaparak.ir",
"pay": "/gateway.aspx",
"result": "/CheckTransactionResult.aspx",
"verify": "/VerifyPayment.aspx",
"refund": "/doRefund.aspx"
},
"metchanId": "234567",
"terminalId": "987654",
"key": "private pem key"
}
}
Usage
you need to pass an object like folowing table
Name | Description | type(s) | Nullabe | Default |
---|---|---|---|---|
bank | Name of the bank object in bank.json | string | true | Default |
invoiceNumber | Invoice nubmer | number,string | false | |
invoiceDate | Invoice date | Date, string | true | current datetime |
amount | amount money to pay in RIAL | number, string | false | |
redirectAddress | the URL for proccessing to after the payment. | string | false |
Example
var moth = require('@ostad/moth').invoice;
var invoice = {
bank:'pasargad',
invoiceNumber:'123',
invoiceDate: '2015-11-13 15:43:32' ,
amount: '240000',
redirectAddress:'http://eco.mysite.com/'
};
//sign the request
moth(invoice).pay();
//check for payment
moth(invoice).result();
//confirm payment
moth(invoice).verify()
//return money to user
moth(invoice).refund()