jellyfin-web/dashboard-ui/cordova/android/iap.js
Luke Pulverenti 55e40bdcf7 vulcanize
2015-06-20 00:48:45 -04:00

61 lines
1.3 KiB
JavaScript

(function () {
var unlockId = "com.mb.android.unlock";
var updatedProducts = [];
function updateProductInfo(id, owned, price) {
updatedProducts = updatedProducts.filter(function (r) {
return r.id != id;
});
var product = {
id: id,
owned: owned,
price: price
};
updatedProducts.push(product);
Events.trigger(IapManager, 'productupdated', [product]);
}
function getProduct(id) {
var products = updatedProducts.filter(function (r) {
return r.id == id;
});
return products.length ? products[0] : null;
}
function isPurchaseAvailable(id) {
return NativeIapManager.isStoreAvailable();
}
function beginPurchase(id) {
return MainActivity.beginPurchase(id);
}
function onPurchaseComplete(result) {
if (result) {
refreshPurchases();
}
}
function refreshPurchases() {
NativeIapManager.isPurchased(unlockId, "window.IapManager.updateProduct");
}
window.IapManager = {
isPurchaseAvailable: isPurchaseAvailable,
getProductInfo: getProduct,
updateProduct: updateProductInfo,
beginPurchase: beginPurchase,
onPurchaseComplete: onPurchaseComplete
};
refreshPurchases();
})();