Last active
December 16, 2015 06:19
-
-
Save troscoe/5390922 to your computer and use it in GitHub Desktop.
singleton model for #tialloy InApp purchases for iOS using StoreKit module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Storekit = require('ti.storekit'); | |
Storekit.receiptVerificationSandbox = true; | |
Storekit.receiptVerificationSharedSecret = "********************************"; | |
var verifyingReceipts = false; | |
exports.definition = { | |
config: { | |
"columns": { | |
"title":"TEXT", | |
"description":"TEXT", | |
"productid":"TEXT", | |
"appleid":"TEXT", | |
"purchased":"integer" | |
}, | |
"adapter": { | |
"type": "sql", | |
"collection_name": "purchases" | |
} | |
}, | |
"defaults" : { | |
"title":"", | |
"description":"", | |
"productid":"", | |
"appleid":"", | |
"purchased":0 | |
}, | |
extendModel: function(Model) { | |
_.extend(Model.prototype, { | |
requestProduct: function(identifier, success) { | |
Storekit.requestProducts([identifier], function (evt) { | |
if (!evt.success) { | |
alert('ERROR: We failed to talk to Apple!'); | |
} | |
else if (evt.invalid) { | |
alert('ERROR: We requested an invalid product!'); | |
} | |
else { | |
success(evt.products[0]); | |
} | |
}); | |
} | |
}); | |
return Model; | |
}, | |
extendCollection: function(Collection) { | |
_.extend(Collection.prototype, { | |
// extended functions and properties go here | |
}); | |
return Collection; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thinking about changing "appleid" to "vendorid" to not make it Apple specific but haven't taken a look at Android InApp purchases yet.