Skip to content

Commit

Permalink
v13.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
j3k0 committed Feb 21, 2023
1 parent 5c745f2 commit a94199e
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 11 deletions.
9 changes: 8 additions & 1 deletion api/classes/CdvPurchase.AppleAppStore.Adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Adapter for Apple AppStore using StoreKit version 1

### Properties

- [\_canMakePayments](CdvPurchase.AppleAppStore.Adapter.md#_canmakepayments)
- [\_products](CdvPurchase.AppleAppStore.Adapter.md#_products)
- [\_receipt](CdvPurchase.AppleAppStore.Adapter.md#_receipt)
- [autoFinish](CdvPurchase.AppleAppStore.Adapter.md#autofinish)
Expand Down Expand Up @@ -69,6 +70,12 @@ Adapter for Apple AppStore using StoreKit version 1

## Properties

### \_canMakePayments

**\_canMakePayments**: `boolean` = `false`

___

### \_products

**\_products**: [`SKProduct`](CdvPurchase.AppleAppStore.SKProduct.md)[] = `[]`
Expand Down Expand Up @@ -187,7 +194,7 @@ The value is set by the "Adapters" class (which is responsible for initializing

`get` **isSupported**(): `boolean`

Returns true on Android, the only platform supported by this adapter
Returns true on iOS, the only platform supported by this adapter

#### Returns

Expand Down
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.3.2"``
`Const` **PLUGIN\_VERSION**: ``"13.3.3"``

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.3.2",
"version": "13.3.3",
"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.3.2">
version="13.3.3">

<name>Purchase</name>
<description>Cordova Purchase plugin for iOS (AppStore), Android (PlayStore) and Windows</description>
Expand Down
5 changes: 5 additions & 0 deletions src/example/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ function demo() {

const store = CdvPurchase.store;

const appStore = store.getAdapter(CdvPurchase.Platform.APPLE_APPSTORE);
if (appStore && appStore.checkSupport('order')) {
// user can make payments
}

// Shortcuts
const ProductType = CdvPurchase.ProductType;
const Platform = CdvPurchase.Platform;
Expand Down
2 changes: 1 addition & 1 deletion src/ts/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace CdvPurchase {
/**
* Current release number of the plugin.
*/
export const PLUGIN_VERSION = '13.3.2';
export const PLUGIN_VERSION = '13.3.3';

/**
* Entry class of the plugin.
Expand Down
6 changes: 4 additions & 2 deletions www/store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ declare namespace CdvPurchase {
/**
* Current release number of the plugin.
*/
const PLUGIN_VERSION = "13.3.2";
const PLUGIN_VERSION = "13.3.3";
/**
* Entry class of the plugin.
*/
Expand Down Expand Up @@ -2205,6 +2205,7 @@ declare namespace CdvPurchase {
id: Platform;
name: string;
ready: boolean;
_canMakePayments: boolean;
/**
* Set to true to force a full refresh of the receipt when preparing a receipt validation call.
*
Expand Down Expand Up @@ -2233,7 +2234,7 @@ declare namespace CdvPurchase {
/** True to auto-finish all transactions */
autoFinish: boolean;
constructor(context: CdvPurchase.Internal.AdapterContext, options: AdapterOptions);
/** Returns true on Android, the only platform supported by this adapter */
/** Returns true on iOS, the only platform supported by this adapter */
get isSupported(): boolean;
private upsertTransactionInProgress;
private removeTransactionInProgress;
Expand All @@ -2247,6 +2248,7 @@ declare namespace CdvPurchase {
private setPaymentMonitor;
private callPaymentMonitor;
initialize(): Promise<IError | undefined>;
private canMakePayments;
/** True iff the appStoreReceipt is already being initialized */
private _appStoreReceiptLoading;
/** List of functions waiting for the appStoreReceipt to be initialized */
Expand Down
25 changes: 22 additions & 3 deletions www/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ var CdvPurchase;
/**
* Current release number of the plugin.
*/
CdvPurchase.PLUGIN_VERSION = '13.3.2';
CdvPurchase.PLUGIN_VERSION = '13.3.3';
/**
* Entry class of the plugin.
*/
Expand Down Expand Up @@ -1101,6 +1101,9 @@ var CdvPurchase;
/** Return true if a product or offer can be purchased */
canPurchase(offer) {
const product = (offer instanceof CdvPurchase.Offer) ? this.get(offer.productId, offer.platform) : offer;
const adapter = this.adapters.findReady(offer.platform);
if (!(adapter === null || adapter === void 0 ? void 0 : adapter.checkSupport('order')))
return false;
return CdvPurchase.Internal.LocalReceipts.canPurchase(this.localReceipts, product);
}
/**
Expand Down Expand Up @@ -2127,6 +2130,7 @@ var CdvPurchase;
this.id = CdvPurchase.Platform.APPLE_APPSTORE;
this.name = 'AppStore';
this.ready = false;
this._canMakePayments = false;
/**
* Set to true to force a full refresh of the receipt when preparing a receipt validation call.
*
Expand Down Expand Up @@ -2167,7 +2171,7 @@ var CdvPurchase;
this.validProducts[vp.id] = Object.assign(Object.assign({}, vp), rp);
});
}
/** Returns true on Android, the only platform supported by this adapter */
/** Returns true on iOS, the only platform supported by this adapter */
get isSupported() {
return window.cordova.platformId === 'ios';
}
Expand Down Expand Up @@ -2323,16 +2327,29 @@ var CdvPurchase;
restoreCompleted: () => {
this.log.info('restoreCompleted');
},
}, () => {
}, async () => {
this.log.info('bridge.init done');
setTimeout(() => this.initializeAppReceipt(() => this.receiptsUpdated()), 300);
await this.canMakePayments();
resolve(undefined);
}, (code, message) => {
this.log.info('bridge.init failed: ' + code + ' - ' + message);
resolve(CdvPurchase.storeError(code, message));
});
});
}
async canMakePayments() {
return new Promise(resolve => {
this.bridge.canMakePayments(() => {
this._canMakePayments = true;
resolve(true);
}, (message) => {
this.log.warn(`canMakePayments: ${message}`);
this._canMakePayments = false;
resolve(false);
});
});
}
/**
* Create the application receipt
*/
Expand Down Expand Up @@ -2647,6 +2664,8 @@ var CdvPurchase;
return;
}
checkSupport(functionality) {
if (functionality === 'order')
return this._canMakePayments;
const supported = [
'order', 'manageBilling', 'manageSubscriptions'
];
Expand Down

0 comments on commit a94199e

Please sign in to comment.