Skip to content

Commit b6e95de

Browse files
committed
preperations to be added to npm
1 parent 466248c commit b6e95de

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

FA.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# کتابخانه پرداخت pay.ir برای typescript

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# payir-typescript
1+
# pay.ir node.js typescript library

lib/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ interface IVerifyArguments {
1212
token: number;
1313
}
1414

15+
/**
16+
* this class proved all of your required functions to make a successful payment using pay.ir gateway
17+
*/
1518
export default class PayIrTypescript {
1619
private readonly API_KEY: string;
1720
private readonly sendEndPoint = 'https://pay.ir/pg/send';
1821
private readonly verifyEndPoint = 'https://pay.ir/pg/verify';
1922
private readonly gateway = 'https://pay.ir/pg/';
20-
23+
/**
24+
* Creates an instance of pay ir typescript.
25+
* @param api api code received from pay.ir
26+
*/
2127
constructor(api: string) {
2228
if (api === '' || typeof api !== 'string') {
2329
throw new Error(
@@ -26,7 +32,9 @@ export default class PayIrTypescript {
2632
}
2733
this.API_KEY = api;
2834
}
29-
35+
/**
36+
* Handle errors of pay ir typescript
37+
*/
3038
private handleErrors = (reject: Function, error: any) => {
3139
if (error.response) {
3240
// The request was made and the server responded with a status code
@@ -46,7 +54,9 @@ export default class PayIrTypescript {
4654
);
4755
}
4856
};
49-
57+
/**
58+
* get payment url
59+
*/
5060
public send = (args: ISendArguments, getRedirect: boolean = false) => {
5161
return new Promise((resolve, reject) => {
5262
if (typeof args.amount !== 'number' || args.amount < 1000) {
@@ -75,7 +85,9 @@ export default class PayIrTypescript {
7585
});
7686
});
7787
};
78-
88+
/**
89+
* Verify successful payment token
90+
*/
7991
public verify = (args: IVerifyArguments) => {
8092
return new Promise((resolve, reject) => {
8193
if (typeof args.token !== 'number') {

package.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,40 @@
22
"name": "pay-ir",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "index.js",
5+
"main": "build/lib/index.js",
6+
"types": "build/lib/index.d.ts",
67
"scripts": {
78
"clean": "rimraf coverage build tmp",
89
"build": "tsc -p tsconfig.release.json",
910
"build:watch": "tsc -w -p tsconfig.release.json",
1011
"lint": "tslint -t stylish --project \"tsconfig.json\"",
1112
"server": "nodemon ./build/src/main.js"
1213
},
13-
"keywords": [],
14-
"author": "",
15-
"license": "ISC",
14+
"keywords": [
15+
"typescript",
16+
"payir"
17+
],
18+
"author": "Omid Astaraki",
19+
"license": "MIT",
1620
"dependencies": {
1721
"axios": "^0.18.0"
1822
},
23+
"prepare": "npm run build",
24+
"prepublishOnly": "npm run lint",
25+
"preversion": "npm run lint",
26+
"version": "git add -A src",
27+
"postversion": "git push && git push --tags",
28+
"repository": {
29+
"type": "git",
30+
"url": "https://github.com/electather/payir-typescript.git"
31+
},
32+
"bugs": {
33+
"url": "https://github.com/electather/payir-typescript/issues"
34+
},
35+
"homepage": "https://github.com/electather/payir-typescript",
36+
"files": [
37+
"lib/**/*"
38+
],
1939
"devDependencies": {
2040
"@types/axios": "^0.14.0",
2141
"typescript": "^3.4.3"

0 commit comments

Comments
 (0)