Add in-app purchase for MacOS

This commit is contained in:
Adrien Fery 2017-11-30 14:27:33 +01:00 committed by Cheng Zhao
parent 143816bee1
commit f3ae566164
12 changed files with 593 additions and 0 deletions

View file

@ -0,0 +1,46 @@
'use strict'
const binding = process.atomBinding('in_app_purchase')
const v8Util = process.atomBinding('v8_util')
module.exports = {
canMakePayments: function() {
return binding.canMakePayments();
},
getReceiptURL: function() {
return binding.getReceiptURL();
},
purchaseProduct: function(productID, quantity, callback) {
if (typeof productID !== 'string') {
throw new TypeError('productID must be a string')
}
if (typeof quantity !== 'number') {
quantity = 1
}
if (typeof callback !== 'function') {
callback = function() {};
}
return binding.purchaseProduct(productID, quantity, callback)
},
addTransactionListener: function(callback) {
if (typeof callback !== 'function') {
throw new TypeError('callback must be a function')
}
return binding.addTransactionListener(callback)
}
}
// Mark standard asynchronous functions.
v8Util.setHiddenValue(
module.exports.purchaseProduct, 'asynchronous', true)
v8Util.setHiddenValue(
module.exports.addTransactionListener, 'asynchronous', true)