habitica/website/server/libs/inAppPurchases.js

23 lines
641 B
JavaScript
Raw Normal View History

2016-06-26 15:04:16 +00:00
import nconf from 'nconf';
import iap from 'in-app-purchase';
import Bluebird from 'bluebird';
// Validation ERROR Codes
2016-06-27 12:26:20 +00:00
// const INVALID_PAYLOAD = 6778001;
2016-06-26 15:04:16 +00:00
// const CONNECTION_FAILED = 6778002;
// const PURCHASE_EXPIRED = 6778003;
iap.config({
2016-06-27 12:26:20 +00:00
// This is the path to the directory containing iap-sanbox/iap-live files
2016-06-26 15:04:16 +00:00
googlePublicKeyPath: nconf.get('IAP_GOOGLE_KEYDIR'),
});
2016-07-04 13:45:52 +00:00
module.exports = {
setup: Bluebird.promisify(iap.setup, { context: iap }),
validate: Bluebird.promisify(iap.validate, { context: iap }),
2016-07-04 14:12:43 +00:00
isValidated: iap.isValidated,
getPurchaseData: iap.getPurchaseData,
2016-07-04 13:45:52 +00:00
GOOGLE: iap.GOOGLE,
2016-07-04 14:12:43 +00:00
APPLE: iap.APPLE,
};