jellyfin-web/dashboard-ui/thirdparty/cordova/android/iap.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-05-28 05:49:46 -07:00
(function () {
var unlockId = "premiumunlock";
var updatedProducts = [];
function updateProductInfo(id, owned) {
updatedProducts = updatedProducts.filter(function (r) {
return r.id != id;
});
updatedProducts.push({
id: id,
owned: owned
});
}
function hasPurchased(id) {
var product = getProduct(id);
return product != null && product.owned;
}
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) {
2015-05-31 11:22:51 -07:00
return MainActivity.beginPurchase(id);
2015-05-28 05:49:46 -07:00
}
2015-05-31 12:12:58 -07:00
function onPurchaseComplete(result) {
alert(result);
}
2015-05-28 05:49:46 -07:00
window.IapManager = {
isPurchaseAvailable: isPurchaseAvailable,
hasPurchased: hasPurchased,
updateProduct: updateProductInfo,
2015-05-31 12:12:58 -07:00
beginPurchase: beginPurchase,
onPurchaseComplete: onPurchaseComplete
2015-05-28 05:49:46 -07:00
};
NativeIapManager.isPurchased(unlockId, "window.IapManager.updateProduct");
})();