forked from Wizcorp/node-iap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (46 loc) · 1.08 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
var platforms = {
apple: require('./lib/apple'),
google: require('./lib/google')
};
exports.verifyPayment = function (platform, payment, cb) {
function syncError(error) {
process.nextTick(function () {
cb(error);
});
}
if (!payment) {
return syncError(new Error('No payment given'));
}
var engine = platforms[platform];
if (!engine) {
return syncError(new Error('Platform ' + platform + ' not recognized'));
}
engine.verifyPayment(payment, function (error, result) {
if (error) {
return cb(error);
}
result.platform = platform;
cb(null, result);
});
};
exports.voided = function (platform, payment, cb) {
function syncError(error) {
process.nextTick(function () {
cb(error);
});
}
if (platform != "google") {
return syncError(new Error('Not supported on platform'));
}
var engine = platforms[platform];
if (!engine) {
return syncError(new Error('Platform ' + platform + ' not recognized'));
}
engine.voided(payment, function (error, result) {
if (error) {
return cb(error);
}
result.platform = platform;
cb(null, result);
});
};