mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-12 06:57:47 +00:00
dummy iap verify routes
This commit is contained in:
parent
2ea12d5c71
commit
cc4812712a
4 changed files with 73 additions and 3 deletions
|
|
@ -41,5 +41,6 @@
|
|||
"mode":"sandbox",
|
||||
"client_id":"client_id",
|
||||
"client_secret":"client_secret"
|
||||
}
|
||||
},
|
||||
"IAP_GOOGLE_KEYDIR": "/path/to/google/public/key/dir/"
|
||||
}
|
||||
|
|
|
|||
63
src/controllers/payments/iap.js
Normal file
63
src/controllers/payments/iap.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
var iap = require('in-app-purchase');
|
||||
var async = require('async');
|
||||
var payments = require('./index');
|
||||
|
||||
/*
|
||||
For google iap, you need to name your public key file as:
|
||||
iap-sanbox or iap-live
|
||||
*/
|
||||
iap.config({
|
||||
googlePublicKeyPath: "/path/to/google/public/key/dir/"
|
||||
});
|
||||
|
||||
exports.androidVerify = function(req, res, next) {
|
||||
console.info(req.body);
|
||||
|
||||
var token = req.body.id;
|
||||
var user = res.locals.user;
|
||||
|
||||
iap.setup(function (error) {
|
||||
if (error) {
|
||||
console.error('something went wrong...');
|
||||
console.error(error);
|
||||
|
||||
return;
|
||||
}
|
||||
/*
|
||||
google receipt must be provided as an object
|
||||
{
|
||||
"data": "{stringified data object}",
|
||||
"signature": "signature from google"
|
||||
}
|
||||
*/
|
||||
// iap is ready
|
||||
/*iap.validate(iap.GOOGLE, googleReceipt, function (err, googleRes) {
|
||||
if (err) {
|
||||
return console.error(err);
|
||||
}
|
||||
if (iap.isValidated(googleRes)) {
|
||||
// yay good!
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
/*
|
||||
async.waterfall([
|
||||
function(response, cb) {
|
||||
payments.buyGems(user, {customerId: response.id, paymentMethod: 'IAP'});
|
||||
|
||||
user.save(cb);
|
||||
}
|
||||
], function(err, saved){
|
||||
if (err) return res.send(500, err.toString()); // don't json this, let toString() handle errors
|
||||
res.send(200);
|
||||
user = token = null;
|
||||
});*/
|
||||
};
|
||||
|
||||
exports.iosVerify = function(req, res, next) {
|
||||
console.info(req.body);
|
||||
|
||||
var token = req.body.id;
|
||||
var user = res.locals.user;
|
||||
};
|
||||
|
|
@ -7,9 +7,9 @@ var moment = require('moment');
|
|||
var isProduction = nconf.get("NODE_ENV") === "production";
|
||||
var stripe = require('./stripe');
|
||||
var paypal = require('./paypal');
|
||||
var User = require('mongoose').model('User');
|
||||
var members = require('../members')
|
||||
var async = require('async');
|
||||
var iap = require('./iap');
|
||||
|
||||
function revealMysteryItems(user) {
|
||||
_.each(shared.content.gear.flat, function(item) {
|
||||
|
|
@ -123,4 +123,7 @@ exports.paypalSubscribeSuccess = paypal.executeBillingAgreement;
|
|||
exports.paypalSubscribeCancel = paypal.cancelSubscription;
|
||||
exports.paypalCheckout = paypal.createPayment;
|
||||
exports.paypalCheckoutSuccess = paypal.executePayment;
|
||||
exports.paypalIPN = paypal.ipn;
|
||||
exports.paypalIPN = paypal.ipn;
|
||||
|
||||
exports.iapAndroidVerify = iap.androidVerify;
|
||||
exports.iapIosVerify = iap.iosVerify;
|
||||
|
|
|
|||
|
|
@ -17,4 +17,7 @@ router.post("/stripe/subscribe/edit", auth.auth, i18n.getUserLanguage, payments.
|
|||
//router.get("/stripe/subscribe", auth.authWithUrl, i18n.getUserLanguage, payments.stripeSubscribe); // checkout route is used (above) with ?plan= instead
|
||||
router.get("/stripe/subscribe/cancel", auth.authWithUrl, i18n.getUserLanguage, payments.stripeSubscribeCancel);
|
||||
|
||||
router.post("/iap/android/verify", auth.authWithUrl, i18n.getUserLanguage, payments.iapAndroidVerify);
|
||||
router.post("/iap/ios/verify", auth.authWithUrl, i18n.getUserLanguage, payments.iapIosVerify);
|
||||
|
||||
module.exports = router;
|
||||
Loading…
Reference in a new issue