-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LICENSE Policy #32
Comments
Hello Yes you may use this module in a commercial product. I only ask that the project being properly acknowledged. Best -Nobuyori On Feb 18, 2016, 00:26 +0900, Rob Lavertynotifications@github.com, wrote:
|
Ah! No problem at all! I have a specific page just for that. Do you have a logo or media you'd like for me to put? |
Any plans to implement promises? I'm going to try bluebirds promisify |
Hello Rob, Thanks for reaching out. As for promises, I am working on that right now. I'm always open to feedbacks and thoughts! Best -Nobuyori On Feb 18, 2016, 03:17 +0900, Rob Lavertynotifications@github.com, wrote:
|
This works wonders! var iap = require( 'in-app-purchase' )
iap.Pvalidate = Promise.promisify( iap.validate )
iap.config( {
applePassword: "", // this comes from iTunes Connect
googlePublicKeyPath: "" // this is the path to the directory containing iap-sanbox/iap-live files
} )
iap.setup()
module.exports = function ( req, res, next ) {
req.that = {
data: _.pick( req.json, [ 'recipt' ] ),
xid: req.xid
}
Promise.resolve().bind( req.that ).then( function () {
if ( _.isInvalidUndefined( this.data, [ 'recipt' ] ) ) {
throw new restify.errors.InternalServerError( 'isInvalidUndefined!' )
}
return iap.Pvalidate( iap.APPLE, this.data.recipt )
} ).then( function ( response ) {
if ( !iap.isValidated( response ) ) {
throw new restify.errors.BadRequestError( 'Invalid purchase recipt!!!' )
}
this.recipt = _.last( iap.getPurchaseData( response, {
ignoreExpired: true
} ) )
if ( _.isUndefined( this.recipt.expirationDate ) ) {
throw new restify.errors.BadRequestError( 'Invalid purchase recipt!!!' )
}
return r.table( 'users' ).get( this.xid ).update( {
premium: this.recipt.expirationDate
} )
} ).then( function () {
return redis.hset( 'tok:' + this.xid, 'prm', this.recipt.expirationDate )
} ).then( function () {
res.send( {
stamp: this.recipt.expirationDate
} )
return next()
} ).catch( restify.errors.BadRequestError, function ( err ) {
res.send( {
err: true,
msg: err.message
} )
return next()
} ).catch( restify.errors.InternalServerError, function ( err ) {
return next( err )
} ).catch( function ( err ) {
return next( new restify.errors.InternalServerError( err ) )
} )
} Promisify works like a charm! |
Awesome! Thanks for the snippet. I just need to find the time to do this :-) On Feb 18, 2016, 09:04 +0900, Rob Lavertynotifications@github.com, wrote:
|
No problem man! |
…cha-9.0.3 build(deps-dev): bump mocha from 9.0.2 to 9.0.3
I'm a bit confused as to what your license policy states.
I'm familiar with the MIT, but that's about it. Am I able to use this project in a commercial product I'm selling to verify my in app purchases?
The text was updated successfully, but these errors were encountered: