cc.fovea.cordova.purchase
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -305,2 +305,3 @@ # API Documentation | ||
store.ERR_DOWNLOAD = ERROR_CODES_BASE + 21; | ||
store.ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE = ERROR_CODES_BASE + 22; | ||
@@ -356,2 +357,3 @@ ### product states | ||
- `product.transaction` - Latest transaction data for this product (see [transactions](#transactions)). | ||
- `product.additionalData` - additional data possibly required for passing info in event based behavior. | ||
@@ -617,3 +619,3 @@ ### *store.Product* public methods | ||
- `"invalid"` - all products in the INVALID state. | ||
- `"owned"` - all products in the INVALID state. | ||
- `"owned"` - all products in the OWNED state. | ||
- etc. (see [here](#product-states) for all product states). | ||
@@ -649,3 +651,3 @@ | ||
## <a name="order"></a>*store.order(product)* | ||
## <a name="order"></a>*store.order(product, additionalData)* | ||
@@ -660,2 +662,6 @@ Initiate the purchase of a product. | ||
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 | ||
See the ["Purchasing section"](#purchasing) to learn more about | ||
@@ -662,0 +668,0 @@ the purchase process. |
{ | ||
"name": "cc.fovea.cordova.purchase", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "Cordova Purchase plugin for iOS and Android (AppStore and PlayStore)", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -9,3 +9,3 @@ # Cordova Purchase Plugin | ||
This plugin allows **In-App Purchases** to be made from **Cordova and PhoneGap** applications, on **Android**, **iOS** and **Windows** (Store/Phone 8.1) | ||
This plugin allows **In-App Purchases** to be made from **Cordova and PhoneGap** applications, on **Android**, **iOS** and **Windows** (Store/Phone) | ||
@@ -33,3 +33,3 @@ It lets you handle all platforms with a single codebase. | ||
```xml | ||
<gap:plugin name="cc.fovea.cordova.purchase" source="npm" version="4.0.0" /> | ||
<gap:plugin name="cc.fovea.cordova.purchase" source="npm" version="6.0.0" /> | ||
``` | ||
@@ -40,3 +40,3 @@ | ||
```xml | ||
<gap:plugin name="cc.fovea.cordova.purchase" source="npm" version="4.0.0"> | ||
<gap:plugin name="cc.fovea.cordova.purchase" source="npm" version="6.0.0"> | ||
<param name="BILLING_KEY" value="MIIB...."/> | ||
@@ -64,3 +64,3 @@ </gap:plugin> | ||
- with Google Play client version 3.9.16 or higher | ||
- **Windows** Store/Phone 8.1 | ||
- **Windows** Store/Phone 8.1 or higher | ||
@@ -67,0 +67,0 @@ ## Extensions |
@@ -45,2 +45,3 @@ (function(){ | ||
/*///*/ store.ERR_DOWNLOAD = ERROR_CODES_BASE + 21; | ||
/*///*/ store.ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE = ERROR_CODES_BASE + 22; | ||
@@ -47,0 +48,0 @@ /// |
@@ -11,3 +11,3 @@ (function() { | ||
/// | ||
/// ## <a name="order"></a>*store.order(product)* | ||
/// ## <a name="order"></a>*store.order(product, additionalData)* | ||
/// | ||
@@ -22,6 +22,10 @@ /// Initiate the purchase of a product. | ||
/// | ||
/// 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 | ||
/// | ||
/// See the ["Purchasing section"](#purchasing) to learn more about | ||
/// the purchase process. | ||
/// | ||
store.order = function(pid) { | ||
store.order = function(pid, additionalData) { | ||
@@ -36,3 +40,4 @@ var p = pid; | ||
loaded: true, | ||
valid: false | ||
valid: false, | ||
additionalData: additionalData | ||
}); | ||
@@ -39,0 +44,0 @@ } |
@@ -63,8 +63,14 @@ /*global storekit */ | ||
if (product.type === store.CONSUMABLE || product.type === store.NON_RENEWING_SUBSCRIPTION) { | ||
if (product.transaction && product.transaction.id) { | ||
storekit.finish(product.transaction.id); | ||
var transactionId = (product.transaction && product.transaction.id) || storekit.transactionForProduct[product.id]; | ||
if (transactionId) { | ||
storekit.finish(transactionId); | ||
// TH 08/03/2016: Remove the finished transaction from product.transactions. | ||
// Previously didn't clear transactions for these product types on finish. | ||
// storekitPurchased suppresses approved events for transactions in product.transactions, | ||
// so this prevented the approved event from firing when re-purchasing a product for which finish failed. | ||
if (product.transactions) { | ||
var idx = product.transactions.indexOf(transactionId); | ||
if (idx >= 0) product.transactions.splice(idx, 1); | ||
} | ||
} | ||
else if (storekit.transactionForProduct[product.id]) { | ||
storekit.finish(storekit.transactionForProduct[product.id]); | ||
} | ||
else { | ||
@@ -393,2 +399,19 @@ store.log.debug("ios -> error: unable to find transaction for " + product.id); | ||
// TH 08/03/2016: Treat errors like cancellations: | ||
// - trigger the "error" event on the associated product | ||
// - set the product back to the VALID state | ||
// This makes it possible to know which product raised an error (previously, errors only fired on the global error listener, which obscures product id). | ||
// It also seems more consistent with the documented API. See https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#events and https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#notes | ||
p = store.get(options.productId); | ||
if (p) { | ||
p.trigger("error", [new store.Error({ | ||
code: errorCode, | ||
message: errorText | ||
}), p]); | ||
p.set({ | ||
transaction: null, | ||
state: store.VALID | ||
}); | ||
} | ||
store.error({ | ||
@@ -395,0 +418,0 @@ code: errorCode, |
@@ -120,3 +120,2 @@ (function() { | ||
} | ||
store.inappbilling[method](function(data) { | ||
@@ -168,2 +167,3 @@ // Success callabck. | ||
if (product.type === store.CONSUMABLE || product.type === store.NON_RENEWING_SUBSCRIPTION) { | ||
var transaction = product.transaction; | ||
product.transaction = null; | ||
@@ -182,3 +182,5 @@ store.inappbilling.consumePurchase( | ||
}, | ||
product.id); | ||
product.id, | ||
transaction.id | ||
); | ||
} | ||
@@ -185,0 +187,0 @@ else { |
@@ -78,7 +78,7 @@ /* | ||
}; | ||
InAppBilling.prototype.consumePurchase = function (success, fail, productId) { | ||
InAppBilling.prototype.consumePurchase = function (success, fail, productId, transactionId) { | ||
if (this.options.showLog) { | ||
log('consumePurchase called!'); | ||
} | ||
return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "consumePurchase", [productId]); | ||
return cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "consumePurchase", [productId, transactionId]); | ||
}; | ||
@@ -85,0 +85,0 @@ InAppBilling.prototype.getAvailableProducts = function (success, fail) { |
@@ -36,7 +36,6 @@ (function () { | ||
store.setProductData = function(product, data) { | ||
var transaction = data.transaction; | ||
var license = data.license; | ||
store.log.debug("windows -> product data for " + product.id); | ||
store.log.debug("windows -> product data for " + product.id); | ||
store.log.debug(transaction); | ||
@@ -43,0 +42,0 @@ store.log.debug(license); |
@@ -82,2 +82,5 @@ (function() { | ||
/// - `product.additionalData` - additional data possibly required for passing info in event based behavior. | ||
this.additionalData = null; | ||
this.stateChanged(); | ||
@@ -84,0 +87,0 @@ }; |
@@ -151,3 +151,3 @@ (function(){ | ||
/// - `"invalid"` - all products in the INVALID state. | ||
/// - `"owned"` - all products in the INVALID state. | ||
/// - `"owned"` - all products in the OWNED state. | ||
/// - etc. (see [here](#product-states) for all product states). | ||
@@ -154,0 +154,0 @@ /// |
@@ -43,2 +43,4 @@ var cordova = require('cordova'); | ||
this.currentApp = Windows.ApplicationModel.Store.CurrentApp; | ||
// Load the product licenses | ||
this.productLicenses = this.currentApp.licenseInformation.productLicenses; | ||
} | ||
@@ -109,3 +111,12 @@ //Don't need to init anything else here | ||
function (purchaseResults) { | ||
win({ transaction: purchaseResults }); | ||
// Create the transaction json from the PurchaseResults object that Windows returns | ||
var transaction_results = { | ||
transaction: { | ||
offerId: purchaseResults.offerId, | ||
receiptXml: purchaseResults.receiptXml, | ||
status: purchaseResults.status, | ||
transactionId: purchaseResults.transactionId | ||
} | ||
}; | ||
win(transaction_results); | ||
}, | ||
@@ -123,3 +134,3 @@ function (err) { | ||
} else { | ||
this.buy(win, fail, args); | ||
this.inappbilling.buy(win, fail, productId); | ||
} | ||
@@ -126,0 +137,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
816950
95
14141
0