From a9a4919814a0f6a400f5f488387383b4ff8448e9 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hoelt Date: Sat, 22 Oct 2016 21:11:01 +0300 Subject: [PATCH] Fix linter warnings --- doc/api.md | 3 ++- src/js/order.js | 2 +- src/js/platforms/plugin-bridge.js | 2 +- www/store-android.js | 6 +++--- www/store-ios.js | 18 ++++++++-------- www/store-windows.js | 34 ++++++++++++++++++------------- 6 files changed, 36 insertions(+), 29 deletions(-) diff --git a/doc/api.md b/doc/api.md index 6ab26f39..42fc5a09 100644 --- a/doc/api.md +++ b/doc/api.md @@ -352,8 +352,8 @@ Products object have the following fields and methods. - `product.owned` - Product is owned - `product.downloading` - Product is downloading non-consumable content - `product.downloaded` - Non-consumable content has been successfully downloaded for this product + - `product.additionalData` - additional data possibly required for product purchase - `product.transaction` - Latest transaction data for this product (see [transactions](#transactions)). - - `product.additionalData` - additional data possibly required for passing info in event based behavior. ### *store.Product* public methods @@ -658,6 +658,7 @@ The `product` argument can be either: The `additionalData` argument can be either: - null - object with attribute `oldPurchasedSkus`, a string array with the old subscription to upgrade/downgrade on Android. See: [android developer](https://developer.android.com/google/play/billing/billing_reference.html#upgrade-getBuyIntentToReplaceSkus) for more info + - object with attribute `developerPayload`, string representing the developer payload as described in [billing best practices](https://developer.android.com/google/play/billing/billing_best_practices.html) See the ["Purchasing section"](#purchasing) to learn more about the purchase process. diff --git a/src/js/order.js b/src/js/order.js index 6caadb4b..77f3e952 100644 --- a/src/js/order.js +++ b/src/js/order.js @@ -41,7 +41,7 @@ store.order = function(pid, additionalData) { } } if (additionalData) { - p.additionalData = additionalData; + p.additionalData = additionalData; } var localCallbackId = callbackId++; diff --git a/src/js/platforms/plugin-bridge.js b/src/js/platforms/plugin-bridge.js index da92f00e..1f40c59d 100644 --- a/src/js/platforms/plugin-bridge.js +++ b/src/js/platforms/plugin-bridge.js @@ -76,7 +76,7 @@ InAppBilling.prototype.subscribe = function (success, fail, productId, additiona } additionalData = (!!additionalData) && (additionalData.constructor === Object) ? additionalData : {}; if (additionalData.oldPurchasedSkus && this.options.showLog) { - log('subscribe called with upgrading of old SKUs!'); + log('subscribe called with upgrading of old SKUs!'); } return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "subscribe", [productId, additionalData || {}]); }; diff --git a/www/store-android.js b/www/store-android.js index f764de6e..d9135da5 100644 --- a/www/store-android.js +++ b/www/store-android.js @@ -1130,7 +1130,7 @@ store.order = function(pid, additionalData) { } } if (additionalData) { - p.additionalData = additionalData; + p.additionalData = additionalData; } var localCallbackId = callbackId++; @@ -2072,8 +2072,8 @@ InAppBilling.prototype.subscribe = function (success, fail, productId, additiona } additionalData = (!!additionalData) && (additionalData.constructor === Object) ? additionalData : {}; if (additionalData.oldPurchasedSkus && this.options.showLog) { - log('subscribe called with upgrading of old SKUs!'); - } + log('subscribe called with upgrading of old SKUs!'); + } return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "subscribe", [productId, additionalData || {}]); }; InAppBilling.prototype.consumePurchase = function (success, fail, productId, transactionId) { diff --git a/www/store-ios.js b/www/store-ios.js index acdde653..ef44341c 100644 --- a/www/store-ios.js +++ b/www/store-ios.js @@ -370,7 +370,7 @@ var ERROR_CODES_BASE = 6777000; /*///*/ store.ERR_REFRESH = ERROR_CODES_BASE + 19; // Failed to refresh the store. /*///*/ store.ERR_PAYMENT_EXPIRED = ERROR_CODES_BASE + 20; /*///*/ store.ERR_DOWNLOAD = ERROR_CODES_BASE + 21; - /*///*/ store.ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE = ERROR_CODES_BASE + 22; +/*///*/ store.ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE = ERROR_CODES_BASE + 22; /// /// ### product states @@ -481,12 +481,12 @@ store.Product = function(options) { /// - `product.downloaded` - Non-consumable content has been successfully downloaded for this product this.downloaded = options.downloaded; + /// - `product.additionalData` - additional data possibly required for product purchase + this.additionalData = options.additionalData || null; + /// - `product.transaction` - Latest transaction data for this product (see [transactions](#transactions)). this.transaction = null; - /// - `product.additionalData` - additional data possibly required for passing info in event based behavior. - this.additionalData = null; - this.stateChanged(); }; @@ -1131,6 +1131,7 @@ var callbackId = 0; /// The `additionalData` argument can be either: /// - null /// - object with attribute `oldPurchasedSkus`, a string array with the old subscription to upgrade/downgrade on Android. See: [android developer](https://developer.android.com/google/play/billing/billing_reference.html#upgrade-getBuyIntentToReplaceSkus) for more info +/// - object with attribute `developerPayload`, string representing the developer payload as described in [billing best practices](https://developer.android.com/google/play/billing/billing_best_practices.html) /// /// See the ["Purchasing section"](#purchasing) to learn more about /// the purchase process. @@ -1145,13 +1146,12 @@ store.order = function(pid, additionalData) { p = new store.Product({ id: pid, loaded: true, - valid: false, - additionalData: additionalData + valid: false }); } - else if (additionalData) { - p.additionalData = additionalData; - } + } + if (additionalData) { + p.additionalData = additionalData; } var localCallbackId = callbackId++; diff --git a/www/store-windows.js b/www/store-windows.js index 41b640e6..5b99899b 100644 --- a/www/store-windows.js +++ b/www/store-windows.js @@ -349,7 +349,7 @@ var ERROR_CODES_BASE = 6777000; /*///*/ store.ERR_REFRESH = ERROR_CODES_BASE + 19; // Failed to refresh the store. /*///*/ store.ERR_PAYMENT_EXPIRED = ERROR_CODES_BASE + 20; /*///*/ store.ERR_DOWNLOAD = ERROR_CODES_BASE + 21; - /*///*/ store.ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE = ERROR_CODES_BASE + 22; +/*///*/ store.ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE = ERROR_CODES_BASE + 22; /// /// ### product states @@ -460,12 +460,12 @@ store.Product = function(options) { /// - `product.downloaded` - Non-consumable content has been successfully downloaded for this product this.downloaded = options.downloaded; + /// - `product.additionalData` - additional data possibly required for product purchase + this.additionalData = options.additionalData || null; + /// - `product.transaction` - Latest transaction data for this product (see [transactions](#transactions)). this.transaction = null; - /// - `product.additionalData` - additional data possibly required for passing info in event based behavior. - this.additionalData = null; - this.stateChanged(); }; @@ -1110,6 +1110,7 @@ var callbackId = 0; /// The `additionalData` argument can be either: /// - null /// - object with attribute `oldPurchasedSkus`, a string array with the old subscription to upgrade/downgrade on Android. See: [android developer](https://developer.android.com/google/play/billing/billing_reference.html#upgrade-getBuyIntentToReplaceSkus) for more info +/// - object with attribute `developerPayload`, string representing the developer payload as described in [billing best practices](https://developer.android.com/google/play/billing/billing_best_practices.html) /// /// See the ["Purchasing section"](#purchasing) to learn more about /// the purchase process. @@ -1124,13 +1125,12 @@ store.order = function(pid, additionalData) { p = new store.Product({ id: pid, loaded: true, - valid: false, - additionalData: additionalData + valid: false }); } - else if (additionalData) { - p.additionalData = additionalData; - } + } + if (additionalData) { + p.additionalData = additionalData; } var localCallbackId = callbackId++; @@ -2059,17 +2059,22 @@ InAppBilling.prototype.getPurchases = function (success, fail) { } return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "getPurchases", ["null"]); }; -InAppBilling.prototype.buy = function (success, fail, productId) { +InAppBilling.prototype.buy = function (success, fail, productId, additionalData) { if (this.options.showLog) { log('buy called!'); } - return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "buy", [productId]); + additionalData = (!!additionalData) && (additionalData.constructor === Object) ? additionalData : {}; + return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "buy", [productId, additionalData]); }; -InAppBilling.prototype.subscribe = function (success, fail, productId) { +InAppBilling.prototype.subscribe = function (success, fail, productId, additionalData) { if (this.options.showLog) { log('subscribe called!'); } - return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "subscribe", [productId]); + additionalData = (!!additionalData) && (additionalData.constructor === Object) ? additionalData : {}; + if (additionalData.oldPurchasedSkus && this.options.showLog) { + log('subscribe called with upgrading of old SKUs!'); + } + return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "subscribe", [productId, additionalData || {}]); }; InAppBilling.prototype.consumePurchase = function (success, fail, productId, transactionId) { if (this.options.showLog) { @@ -2266,6 +2271,7 @@ store.when("requested", function(product) { if (product.type === store.FREE_SUBSCRIPTION || product.type === store.PAID_SUBSCRIPTION) { method = 'subscribe'; } + store.inappbilling[method](function(data) { // Success callabck. // @@ -2302,7 +2308,7 @@ store.when("requested", function(product) { else { product.set("state", store.VALID); } - }, product.id); + }, product.id, product.additionalData); }); });