-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
99 lines (91 loc) · 1.98 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
class Idpy {
createTransaction(
key,
sandBox,
order_id,
amount,
name,
phony,
mail,
description,
callBack
) {
const request = require('request');
const axios = require('axios');
var options = {
method: 'POST',
url: 'https://api.idpay.ir/v1.1/payment',
headers: {
'X-API-KEY': key,
'X-SANDBOX': sandBox,
'Content-Type': 'application/json'
},
body: JSON.stringify({
order_id: order_id,
amount: amount,
name: name,
phony: phony,
mail: mail,
desc: description,
callback: callBack
})
};
var data = JSON.stringify({
order_id: order_id,
amount: amount,
name: name,
phony: phony,
mail: mail,
desc: description,
callback: callBack
});
var config = {
method: 'post',
url: 'https://api.idpay.ir/v1.1/payment',
headers: {
'X-API-KEY': key,
'X-SANDBOX': sandBox,
'Content-Type': 'application/json'
},
data: data
};
return axios(config);
}
validTransaction(key, sandBox, id, order_id) {
const axios = require('axios');
var data = JSON.stringify({
id: id,
order_id: order_id
});
var config = {
method: 'POST',
url: 'https://api.idpay.ir/v1.1/payment/verify',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': key,
'X-SANDBOX': sandBox
},
data: data
};
return axios(config);
}
transactionInquiry(key, sandBox, id, order_id) {
const axios = require('axios');
var data = JSON.stringify({
id: id,
order_id: order_id
});
var config = {
method: 'POST',
url: 'https://api.idpay.ir/v1.1/payment/inquiry',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': key,
'X-SANDBOX': sandBox
},
data: data
};
return axios(config);
}
}
module.exports = Idpy;