Skip to content

Commit

Permalink
v13.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
j3k0 committed Sep 19, 2023
1 parent 6dfbbc8 commit 22ea0d6
Show file tree
Hide file tree
Showing 11 changed files with 529 additions and 389 deletions.
11 changes: 10 additions & 1 deletion RELEASE_NOTES.md
@@ -1,6 +1,15 @@
# Release Notes - Cordova Plugin Purchase

## 13.8.0
## 13.8

### 13.8.1

#### Fix AppStore eligibility determination of intro period

In the case where the StoreKit SDK doesn't return a "discounts" array,
determining the eligility of the intro period using iaptic was not functional.

### 13.8.0

#### Upgrade to Google Play Billing library 5.2.1

Expand Down
14 changes: 14 additions & 0 deletions api/modules.md
Expand Up @@ -5,3 +5,17 @@
### Namespaces

- [CdvPurchase](modules/CdvPurchase.md)

### Functions

- [initCDVPurchase](modules.md#initcdvpurchase)

## Functions

### initCDVPurchase

**initCDVPurchase**(): `void`

#### Returns

`void`
20 changes: 8 additions & 12 deletions api/modules/CdvPurchase.AppleAppStore.md
Expand Up @@ -44,25 +44,21 @@ Apple AppStore adapter using StoreKit version 1

### DiscountEligibilityDeterminer

Ƭ **DiscountEligibilityDeterminer**: (`applicationReceipt`: [`ApplicationReceipt`](../interfaces/CdvPurchase.AppleAppStore.ApplicationReceipt.md), `requests`: [`DiscountEligibilityRequest`](../interfaces/CdvPurchase.AppleAppStore.DiscountEligibilityRequest.md)[], `callback`: (`response`: `boolean`[]) => `void`) => `void`
Ƭ **DiscountEligibilityDeterminer**: (`applicationReceipt`: [`ApplicationReceipt`](../interfaces/CdvPurchase.AppleAppStore.ApplicationReceipt.md), `requests`: [`DiscountEligibilityRequest`](../interfaces/CdvPurchase.AppleAppStore.DiscountEligibilityRequest.md)[], `callback`: (`response`: `boolean`[]) => `void`) => `void` & { `cacheReceipt?`: (`receipt`: [`VerifiedReceipt`](../classes/CdvPurchase.VerifiedReceipt.md)) => `void` }

#### Type declaration
Determine which discount the user is eligible to.

▸ (`applicationReceipt`, `requests`, `callback`): `void`
**`Param`**

Determine which discount the user is eligible to.
An apple appstore receipt

##### Parameters
**`Param`**

| Name | Type | Description |
| :------ | :------ | :------ |
| `applicationReceipt` | [`ApplicationReceipt`](../interfaces/CdvPurchase.AppleAppStore.ApplicationReceipt.md) | An apple appstore receipt |
| `requests` | [`DiscountEligibilityRequest`](../interfaces/CdvPurchase.AppleAppStore.DiscountEligibilityRequest.md)[] | List of discount offers to evaluate eligibility for |
| `callback` | (`response`: `boolean`[]) => `void` | Get the response, a boolean for each request (matched by index). |
List of discount offers to evaluate eligibility for

##### Returns
**`Param`**

`void`
Get the response, a boolean for each request (matched by index).

___

Expand Down
2 changes: 1 addition & 1 deletion api/modules/CdvPurchase.md
Expand Up @@ -153,7 +153,7 @@ ___

### PLUGIN\_VERSION

`Const` **PLUGIN\_VERSION**: ``"13.8.0"``
`Const` **PLUGIN\_VERSION**: ``"13.8.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
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-purchase",
"version": "13.8.0",
"version": "13.8.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
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.8.0">
version="13.8.1">

<name>Purchase</name>
<description>Cordova Purchase plugin for iOS (AppStore), Android (PlayStore) and Windows</description>
Expand Down
94 changes: 93 additions & 1 deletion src/example/example.ts
Expand Up @@ -7,6 +7,43 @@

function demo() {

CdvPurchase.store.when().receiptsReady(() => {
console.log('All platforms are done loading their local receipts');
});

CdvPurchase.store.localTransactions.forEach(t => {
if (t.platform === CdvPurchase.Platform.APPLE_APPSTORE) {
const appleTransaction = t as CdvPurchase.AppleAppStore.SKTransaction;
appleTransaction.originalTransactionId;
}
});

const myProduct = CdvPurchase.store.get('my-product');
if (myProduct) {
const transaction = CdvPurchase.store.findInLocalReceipts(myProduct);
}

function readyAndVerified(callback: Function) {
CdvPurchase.store.ready(function () {
var localReceipts = CdvPurchase.store.localReceipts;
var verifiedReceipts = CdvPurchase.store.verifiedReceipts;
if (!CdvPurchase.store.validator || verifiedReceipts.length === localReceipts.length) {
callback();
return;
}
var onVerified = function() {
if (localReceipts.length === verifiedReceipts.length) {
CdvPurchase.store.off(onVerified);
if (callback) {
callback();
callback = null;
}
}
}
CdvPurchase.store.when().verified(onVerified);
});
}

const store = CdvPurchase.store;

const appStore = store.getAdapter(CdvPurchase.Platform.APPLE_APPSTORE);
Expand All @@ -32,12 +69,48 @@ function demo() {
platform: Platform.BRAINTREE,
}]);

store.validator = {
url: 'https://validator.iaptic.com',
timeout: 30000,
}
Platform.APPLE_APPSTORE

store.when().pending(transaction => {
// transaction is pending (waiting for parent approval, cash payment, ...)
});

// Replace an old purchase when finalizing the new one on google play.
store.order(product, {
googlePlay: {
oldPurchaseToken: 'abcdefghijkl',
prorationMode: CdvPurchase.GooglePlay.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
}
});

// For those 2 subscription products, the plugin will automatically replace the currently owned one (if any) when placing a new order.
store.register([{
id: 'no_ads_yearly',
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY,
group: 'noAds'
}, {
id: 'no_ads_monthly',
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.GOOGLE_PLAY,
group: 'noAds'
}]);

store.when()
.approved(transaction => transaction.verify())
.verified(receipt => receipt.finish())
.finished(transaction => console.log('Products owned: ' + transaction.products.map(p => p.id).join(',')))
.receiptUpdated(r => updatePurchases(r))
.productUpdated(p => updateUI(p));
.productUpdated(p => updateUI(p))
.unverified(r => {
if (r.payload.code === CdvPurchase.ErrorCode.COMMUNICATION) {
console.log("HTTP ERROR: " + r.payload.status);
}
})

const iaptic = new CdvPurchase.Iaptic({
appName: 'demo',
Expand Down Expand Up @@ -68,6 +141,18 @@ function demo() {
console.log('Store is ready!');
});

store.localReceipts.forEach(x => x.verify());
store.register({
id: '',
platform: CdvPurchase.Platform.APPLE_APPSTORE,
});
store.initialize().then().catch();
store.when().verified(verifiedReceipt => {
})
.productUpdated(p => p.pricing?.price)

store.defaultPlatform

function updatePurchases(receipt: CdvPurchase.Receipt) {
receipt.transactions.forEach(transaction => {
transaction.products.forEach(trProduct => {
Expand All @@ -94,7 +179,14 @@ function demo() {
console.log("subscription1 ordered successfully");
}
});
store.localTransactions[0].state
}
store.localTransactions.findIndex(transaction => {
transaction.state === CdvPurchase.TransactionState.
})

store.verifiedReceipts[0].sourceReceipt
instanceof CdvPurchase.GooglePlay.Receipt

function manageSubscriptions() {
store.manageSubscriptions(Platform.GOOGLE_PLAY);
Expand Down
2 changes: 1 addition & 1 deletion src/ts/store.ts
Expand Up @@ -30,7 +30,7 @@ namespace CdvPurchase {
/**
* Current release number of the plugin.
*/
export const PLUGIN_VERSION = '13.8.0';
export const PLUGIN_VERSION = '13.8.1';

/**
* Entry class of the plugin.
Expand Down

0 comments on commit 22ea0d6

Please sign in to comment.