mirror of
https://github.com/HackPlan/node-iap.git
synced 2026-01-12 22:44:35 +08:00
34 lines
594 B
JavaScript
34 lines
594 B
JavaScript
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);
|
|
});
|
|
};
|