Skip to content

Commit

Permalink
v13.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
j3k0 committed Dec 27, 2024
1 parent fb48b94 commit f75c125
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 21 deletions.
15 changes: 15 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

## 13.12

### 13.12.1

#### (googleplay) Fix #1434 - validProducts.find is not a product

Somet user had this occasional error:

Error: TypeError: validProducts.find is not a function
at http://localhost/:9909:64
at Array.map (<anonymous>)
at iabLoaded (http://localhost/:9908:46)
at Object.callbackFromNative (http://localhost/:1708:52)
at <anonymous>:1:9

This happened when another call to the native side was made before the list of products was returned (race condition kind of bug). It's fixed in that release.

### 13.12.0

#### (googleplay) Upgrade to Google Play Billing library 7.1.1
Expand Down
5 changes: 5 additions & 0 deletions api/classes/CdvPurchase.AppleAppStore.SKProduct.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ ___

Returns true if the product is owned.

Important: This value will be false when the app starts and will only become
true after purchase receipts have been loaded and validated. Without receipt validation,
it might remain false depending on the platform, make sure to store the ownership status
of non-consumable products in some way.

#### Returns

`boolean`
Expand Down
5 changes: 5 additions & 0 deletions api/classes/CdvPurchase.GooglePlay.GProduct.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ ___

Returns true if the product is owned.

Important: This value will be false when the app starts and will only become
true after purchase receipts have been loaded and validated. Without receipt validation,
it might remain false depending on the platform, make sure to store the ownership status
of non-consumable products in some way.

#### Returns

`boolean`
Expand Down
5 changes: 5 additions & 0 deletions api/classes/CdvPurchase.Product.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ ___

Returns true if the product is owned.

Important: This value will be false when the app starts and will only become
true after purchase receipts have been loaded and validated. Without receipt validation,
it might remain false depending on the platform, make sure to store the ownership status
of non-consumable products in some way.

#### Returns

`boolean`
Expand Down
31 changes: 28 additions & 3 deletions api/classes/CdvPurchase.Store.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ ___

Return true if a product is owned

Important: The value will be false when the app starts and will only become
true after purchase receipts have been loaded and validated. Without receipt validation,
it might remain false depending on the platform, make sure to store the ownership status
of non-consumable products in some way.

#### Parameters

| Name | Type | Description |
Expand Down Expand Up @@ -700,7 +705,12 @@ ___

**when**(): [`When`](../interfaces/CdvPurchase.When.md)

Setup events listener.
Register event callbacks.

Events overview:
- `productUpdated`: Called when product metadata is loaded from the store
- `receiptUpdated`: Called when local receipt information changes (ownership status change, for example)
- `verified`: Called after successful receipt validation (requires a receipt validator)

#### Returns

Expand All @@ -709,8 +719,23 @@ Setup events listener.
**`Example`**

```ts
// Monitor ownership with receipt validation
store.when()
.productUpdated(product => updateUI(product))
.approved(transaction => transaction.verify())
.verified(receipt => receipt.finish());
.verified(receipt => {
if (store.owned("my-product")) {
// Product is owned and verified
}
});
```

**`Example`**

```ts
// Monitor ownership without receipt validation
store.when().receiptUpdated(receipt => {
if (store.owned("my-product")) {
// Product is owned according to local data
}
});
```
2 changes: 1 addition & 1 deletion api/modules/CdvPurchase.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ ___

### PLUGIN\_VERSION

`Const` **PLUGIN\_VERSION**: ``"13.12.0"``
`Const` **PLUGIN\_VERSION**: ``"13.12.1"``

Current release number of the plugin.

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-purchase",
"version": "13.12.0",
"version": "13.12.1",
"description": "Cordova Purchase plugin for iOS, Android, Windows (AppStore, Play, UWP)",
"cordova": {
"id": "cordova-plugin-purchase",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-purchase"
xmlns:android="http://schemas.android.com/apk/res/android"
version="13.12.0">
version="13.12.1">

<name>Purchase</name>
<description>Cordova Purchase plugin for iOS (AppStore), Android (PlayStore) and Windows</description>
Expand Down
12 changes: 6 additions & 6 deletions src/ts/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace CdvPurchase {
/**
* Current release number of the plugin.
*/
export const PLUGIN_VERSION = '13.12.0';
export const PLUGIN_VERSION = '13.12.1';

/**
* Entry class of the plugin.
Expand Down Expand Up @@ -350,12 +350,12 @@ namespace CdvPurchase {

/**
* Register event callbacks.
*
*
* Events overview:
* - `productUpdated`: Called when product metadata is loaded from the store
* - `receiptUpdated`: Called when local receipt information changes (ownership status change, for example)
* - `verified`: Called after successful receipt validation (requires a receipt validator)
*
*
* @example
* // Monitor ownership with receipt validation
* store.when()
Expand All @@ -365,8 +365,8 @@ namespace CdvPurchase {
* // Product is owned and verified
* }
* });
*
* @example
*
* @example
* // Monitor ownership without receipt validation
* store.when().receiptUpdated(receipt => {
* if (store.owned("my-product")) {
Expand Down Expand Up @@ -506,7 +506,7 @@ namespace CdvPurchase {

/**
* Return true if a product is owned
*
*
* Important: The value will be false when the app starts and will only become
* true after purchase receipts have been loaded and validated. Without receipt validation,
* it might remain false depending on the platform, make sure to store the ownership status
Expand Down
35 changes: 31 additions & 4 deletions www/store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ declare namespace CdvPurchase {
get canPurchase(): boolean;
/**
* Returns true if the product is owned.
*
* Important: This value will be false when the app starts and will only become
* true after purchase receipts have been loaded and validated. Without receipt validation,
* it might remain false depending on the platform, make sure to store the ownership status
* of non-consumable products in some way.
*/
get owned(): boolean;
/** @internal */
Expand Down Expand Up @@ -749,7 +754,7 @@ declare namespace CdvPurchase {
/**
* Current release number of the plugin.
*/
const PLUGIN_VERSION = "13.12.0";
const PLUGIN_VERSION = "13.12.1";
/**
* Entry class of the plugin.
*/
Expand Down Expand Up @@ -923,13 +928,30 @@ declare namespace CdvPurchase {
/** true if the plugin is initialized and ready */
get isReady(): boolean;
/**
* Setup events listener.
* Register event callbacks.
*
* Events overview:
* - `productUpdated`: Called when product metadata is loaded from the store
* - `receiptUpdated`: Called when local receipt information changes (ownership status change, for example)
* - `verified`: Called after successful receipt validation (requires a receipt validator)
*
* @example
* // Monitor ownership with receipt validation
* store.when()
* .productUpdated(product => updateUI(product))
* .approved(transaction => transaction.verify())
* .verified(receipt => receipt.finish());
* .verified(receipt => {
* if (store.owned("my-product")) {
* // Product is owned and verified
* }
* });
*
* @example
* // Monitor ownership without receipt validation
* store.when().receiptUpdated(receipt => {
* if (store.owned("my-product")) {
* // Product is owned according to local data
* }
* });
*/
when(): When;
/**
Expand Down Expand Up @@ -993,6 +1015,11 @@ declare namespace CdvPurchase {
/**
* Return true if a product is owned
*
* Important: The value will be false when the app starts and will only become
* true after purchase receipts have been loaded and validated. Without receipt validation,
* it might remain false depending on the platform, make sure to store the ownership status
* of non-consumable products in some way.
*
* @param product - The product object or identifier of the product.
*/
owned(product: {
Expand Down
43 changes: 39 additions & 4 deletions www/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ var CdvPurchase;
}
/**
* Returns true if the product is owned.
*
* Important: This value will be false when the app starts and will only become
* true after purchase receipts have been loaded and validated. Without receipt validation,
* it might remain false depending on the platform, make sure to store the ownership status
* of non-consumable products in some way.
*/
get owned() {
// Pseudo implementation to make typescript happy.
Expand Down Expand Up @@ -1384,7 +1389,7 @@ var CdvPurchase;
/**
* Current release number of the plugin.
*/
CdvPurchase.PLUGIN_VERSION = '13.12.0';
CdvPurchase.PLUGIN_VERSION = '13.12.1';
/**
* Entry class of the plugin.
*/
Expand Down Expand Up @@ -1618,13 +1623,30 @@ var CdvPurchase;
/** true if the plugin is initialized and ready */
get isReady() { return this._readyCallbacks.isReady; }
/**
* Setup events listener.
* Register event callbacks.
*
* Events overview:
* - `productUpdated`: Called when product metadata is loaded from the store
* - `receiptUpdated`: Called when local receipt information changes (ownership status change, for example)
* - `verified`: Called after successful receipt validation (requires a receipt validator)
*
* @example
* // Monitor ownership with receipt validation
* store.when()
* .productUpdated(product => updateUI(product))
* .approved(transaction => transaction.verify())
* .verified(receipt => receipt.finish());
* .verified(receipt => {
* if (store.owned("my-product")) {
* // Product is owned and verified
* }
* });
*
* @example
* // Monitor ownership without receipt validation
* store.when().receiptUpdated(receipt => {
* if (store.owned("my-product")) {
* // Product is owned according to local data
* }
* });
*/
when() {
const ret = {
Expand Down Expand Up @@ -1747,6 +1769,11 @@ var CdvPurchase;
/**
* Return true if a product is owned
*
* Important: The value will be false when the app starts and will only become
* true after purchase receipts have been loaded and validated. Without receipt validation,
* it might remain false depending on the platform, make sure to store the ownership status
* of non-consumable products in some way.
*
* @param product - The product object or identifier of the product.
*/
owned(product) {
Expand Down Expand Up @@ -4944,6 +4971,14 @@ var CdvPurchase;
/** Called when a list of product definitions have been loaded */
const iabLoaded = (validProducts) => {
this.log.debug("Loaded: " + JSON.stringify(validProducts));
// Add type check to handle invalid responses
if (!Array.isArray(validProducts)) {
const message = `Invalid product list received: ${JSON.stringify(validProducts)}, retrying later...`;
this.log.warn(message);
this.retry.retry(go);
this.context.error(playStoreError(CdvPurchase.ErrorCode.LOAD, message, null));
return;
}
const ret = products.map(registeredProduct => {
const validProduct = validProducts.find(vp => vp.productId === registeredProduct.id);
if (validProduct && validProduct.productId) {
Expand Down

0 comments on commit f75c125

Please sign in to comment.