Readme
Introduction
This module allows the Titanium developer to provide in-app products.
Usage
Note: This module provides functionality that will not work in the simulator. Please run your tests on an actual device.
This module provides access to the products defined in Google Play Developer Console. You will need to add your app to Google Play Developer Console and define the in-app products there.
The following code segments are not complete; they only demonstrate the
essentials of using the module. See example/app.js
for a complete
example.
You load the module as usual:
var InAppProducts = require('com.logicallabs.inappproducts');
Basic steps to get a list of available products:
InAppProducts.addEventListener('receivedProducts', function(e) {
e.products.forEach(...
});
if (InAppProducts.getProducts({ SKUs: productIDs })) {
Ti.API.info('getProducts request started successfully.');
} else {
alert('Error: could not start getProducts request!');
}
Basic steps to purchase a product:
InAppProducts.addEventListener('purchaseUpdate', function(e) {
switch (e.purchase.state) {
...
});
productObj.purchase();
Basic steps to get a list of purchased (and not yet consumed) products:
InAppProducts.addEventListener('receivedPurchases', function(e) {
e.purchases.forEach(...
});
InAppProducts.getPurchases();
Consuming a Purchase
The purchase process of in-app products on Android includes an optional steps of consuming the purchase. This is useful for "consumable" purchases such as coins in a game, as opposed to permanent purchases such as enabling a for-fee feature. The purchase can be consumed by calling the consume method. Once this method is called, the purchase in question will not show up in the list of purchases provided by the getPurchases method.
Issues and Limitations
Receipt verification is not part of the module at this time -- the best practice encouraged by Google is to perform this verification on an independent server, not on the device.
Change Log
Version 1.0.0
- First release
Version 1.0.1
- Added safeguard against running module in emulator.
Version 1.0.2
- Hardened module to handle service disconnect.
- Improved handling of canceled purchases.
- Documentation fixes.
Author
Zsombor Papp, Logical Labs titanium@logicallabs.com
License
See LICENSE file included with the module for all terms and conditions specific to this module.
General terms and conditions for all Logical Labs Titanium Modules can be found here: http://www.logicallabs.com/logical-labs-titanium-module-terms-conditions
Copyright
Copyright (c) 2013-2014 by Logical Labs, LLC