Skip to content

Commit

Permalink
v13.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
j3k0 committed Feb 18, 2023
1 parent 2482f0b commit 69b17b3
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 13 deletions.
3 changes: 2 additions & 1 deletion api/classes/CdvPurchase.AppleAppStore.Adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ ___

### order

**order**(`offer`): `Promise`<`undefined` \| [`IError`](../interfaces/CdvPurchase.IError.md)\>
**order**(`offer`, `additionalData`): `Promise`<`undefined` \| [`IError`](../interfaces/CdvPurchase.IError.md)\>

Initializes an order.

Expand All @@ -423,6 +423,7 @@ Initializes an order.
| Name | Type |
| :------ | :------ |
| `offer` | [`Offer`](CdvPurchase.Offer.md) |
| `additionalData` | [`AdditionalData`](../interfaces/CdvPurchase.AdditionalData.md) |

#### Returns

Expand Down
2 changes: 1 addition & 1 deletion api/classes/CdvPurchase.AppleAppStore.Bridge.Bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ ___
| `productId` | `string` |
| `quantity` | `number` |
| `applicationUsername` | `undefined` \| `string` |
| `discount` | `undefined` \| `string` |
| `discount` | `undefined` \| [`PaymentDiscount`](../interfaces/CdvPurchase.AppleAppStore.PaymentDiscount.md) |
| `success` | () => `void` |
| `error` | () => `void` |

Expand Down
9 changes: 9 additions & 0 deletions api/interfaces/CdvPurchase.AdditionalData.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ Data to attach to a transaction.

### Properties

- [appStore](CdvPurchase.AdditionalData.md#appstore)
- [applicationUsername](CdvPurchase.AdditionalData.md#applicationusername)
- [braintree](CdvPurchase.AdditionalData.md#braintree)
- [googlePlay](CdvPurchase.AdditionalData.md#googleplay)

## Properties

### appStore

`Optional` **appStore**: [`AdditionalData`](CdvPurchase.AppleAppStore.AdditionalData.md)

Apple AppStore specific additional data

___

### applicationUsername

`Optional` **applicationUsername**: `string`
Expand Down
19 changes: 19 additions & 0 deletions api/interfaces/CdvPurchase.AppleAppStore.AdditionalData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Interface: AdditionalData

[CdvPurchase](../modules/CdvPurchase.md).[AppleAppStore](../modules/CdvPurchase.AppleAppStore.md).AdditionalData

Additional data passed with an order on AppStore

## Table of contents

### Properties

- [discount](CdvPurchase.AppleAppStore.AdditionalData.md#discount)

## Properties

### discount

`Optional` **discount**: [`PaymentDiscount`](CdvPurchase.AppleAppStore.PaymentDiscount.md)

Information about the payment discount
59 changes: 59 additions & 0 deletions api/interfaces/CdvPurchase.AppleAppStore.PaymentDiscount.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Interface: PaymentDiscount

[CdvPurchase](../modules/CdvPurchase.md).[AppleAppStore](../modules/CdvPurchase.AppleAppStore.md).PaymentDiscount

The signed discount applied to a payment

**`See`**

[https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc](https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc)

## Table of contents

### Properties

- [id](CdvPurchase.AppleAppStore.PaymentDiscount.md#id)
- [key](CdvPurchase.AppleAppStore.PaymentDiscount.md#key)
- [nonce](CdvPurchase.AppleAppStore.PaymentDiscount.md#nonce)
- [signature](CdvPurchase.AppleAppStore.PaymentDiscount.md#signature)
- [timestamp](CdvPurchase.AppleAppStore.PaymentDiscount.md#timestamp)

## Properties

### id

**id**: `string`

A string used to uniquely identify a discount offer for a product.

___

### key

**key**: `string`

A string that identifies the key used to generate the signature.

___

### nonce

**nonce**: `string`

A universally unique ID (UUID) value that you define.

___

### signature

**signature**: `string`

A string representing the properties of a specific promotional offer, cryptographically signed.

___

### timestamp

**timestamp**: `string`

The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.
2 changes: 2 additions & 0 deletions api/modules/CdvPurchase.AppleAppStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ Apple AppStore adapter using StoreKit version 1
### Interfaces

- [AdapterOptions](../interfaces/CdvPurchase.AppleAppStore.AdapterOptions.md)
- [AdditionalData](../interfaces/CdvPurchase.AppleAppStore.AdditionalData.md)
- [ApplicationReceipt](../interfaces/CdvPurchase.AppleAppStore.ApplicationReceipt.md)
- [DiscountEligibilityRequest](../interfaces/CdvPurchase.AppleAppStore.DiscountEligibilityRequest.md)
- [PaymentDiscount](../interfaces/CdvPurchase.AppleAppStore.PaymentDiscount.md)

### Type Aliases

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.1"``
`Const` **PLUGIN\_VERSION**: ``"13.3.2"``

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.1",
"version": "13.3.2",
"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.1">
version="13.3.2">

<name>Purchase</name>
<description>Cordova Purchase plugin for iOS (AppStore), Android (PlayStore) and Windows</description>
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.1';
export const PLUGIN_VERSION = '13.3.2';

/**
* Entry class of the plugin.
Expand Down
30 changes: 27 additions & 3 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.1";
const PLUGIN_VERSION = "13.3.2";
/**
* Entry class of the plugin.
*/
Expand Down Expand Up @@ -998,6 +998,8 @@ declare namespace CdvPurchase {
googlePlay?: GooglePlay.AdditionalData;
/** Braintree specific additional data */
braintree?: Braintree.AdditionalData;
/** Apple AppStore specific additional data */
appStore?: AppleAppStore.AdditionalData;
}
/**
* Purchase platforms supported by the plugin
Expand Down Expand Up @@ -2150,6 +2152,11 @@ declare namespace CdvPurchase {
namespace AppleAppStore {
type PaymentMonitorStatus = 'cancelled' | 'failed' | 'purchased' | 'deferred';
type PaymentMonitor = (status: PaymentMonitorStatus) => void;
/** Additional data passed with an order on AppStore */
interface AdditionalData {
/** Information about the payment discount */
discount?: PaymentDiscount;
}
/**
* Determine which discount the user is eligible to.
*
Expand Down Expand Up @@ -2254,7 +2261,7 @@ declare namespace CdvPurchase {
private loadEligibility;
private callDiscountEligibilityDeterminer;
load(products: IRegisterProduct[]): Promise<(Product | IError)[]>;
order(offer: Offer): Promise<undefined | IError>;
order(offer: Offer, additionalData: CdvPurchase.AdditionalData): Promise<undefined | IError>;
finish(transaction: Transaction): Promise<undefined | IError>;
refreshReceipt(): Promise<undefined | IError | ApplicationReceipt>;
receiptValidationBody(receipt: Receipt): Promise<Validator.Request.Body | undefined>;
Expand Down Expand Up @@ -2285,6 +2292,23 @@ declare namespace CdvPurchase {
/** Bundle signature */
bundleSignature: string;
}
/**
* The signed discount applied to a payment
*
* @see {@link https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc}
*/
interface PaymentDiscount {
/** A string used to uniquely identify a discount offer for a product. */
id: string;
/** A string that identifies the key used to generate the signature. */
key: string;
/** A universally unique ID (UUID) value that you define. */
nonce: string;
/** A string representing the properties of a specific promotional offer, cryptographically signed. */
signature: string;
/** The date and time of the signature's creation in milliseconds, formatted in Unix epoch time. */
timestamp: string;
}
namespace Bridge {
/**
* Product as loaded from AppStore
Expand Down Expand Up @@ -2417,7 +2441,7 @@ declare namespace CdvPurchase {
constructor();
init(options: Partial<BridgeOptions>, success: () => void, error: (code: ErrorCode, message: string) => void): void;
processPendingTransactions(): void;
purchase(productId: string, quantity: number, applicationUsername: string | undefined, discount: string | undefined, success: () => void, error: () => void): void;
purchase(productId: string, quantity: number, applicationUsername: string | undefined, discount: PaymentDiscount | undefined, success: () => void, error: () => void): void;
canMakePayments(success: () => void, error: (message: string) => void): void;
restore(callback?: Callback<any>): void;
manageSubscriptions(callback?: Callback<any>): void;
Expand Down
14 changes: 11 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.1';
CdvPurchase.PLUGIN_VERSION = '13.3.2';
/**
* Entry class of the plugin.
*/
Expand Down Expand Up @@ -2482,9 +2482,10 @@ var CdvPurchase;
});
});
}
async order(offer) {
async order(offer, additionalData) {
let resolved = false;
return new Promise(resolve => {
var _a;
const callResolve = (result) => {
if (resolved)
return;
Expand All @@ -2494,6 +2495,13 @@ var CdvPurchase;
};
this.log.info('order');
const discountId = offer.id !== AppleAppStore.DEFAULT_OFFER_ID ? offer.id : undefined;
const discount = (_a = additionalData === null || additionalData === void 0 ? void 0 : additionalData.appStore) === null || _a === void 0 ? void 0 : _a.discount;
if (discountId && !discount) {
return callResolve(CdvPurchase.storeError(CdvPurchase.ErrorCode.MISSING_OFFER_PARAMS, 'Missing additionalData.appStore.discount when ordering a discount offer'));
}
if (discountId && ((discount === null || discount === void 0 ? void 0 : discount.id) !== discountId)) {
return callResolve(CdvPurchase.storeError(CdvPurchase.ErrorCode.INVALID_OFFER_IDENTIFIER, 'Offer identifier does not match additionalData.appStore.discount.id'));
}
this.setPaymentMonitor((status, code, message) => {
this.log.info('order.paymentMonitor => ' + status + ' ' + (code !== null && code !== void 0 ? code : '') + ' ' + (message !== null && message !== void 0 ? message : ''));
if (resolved)
Expand Down Expand Up @@ -2526,7 +2534,7 @@ var CdvPurchase;
// When we switch AppStore user, the cached receipt isn't from the new user.
// so after a purchase, we want to make sure we're using the receipt from the logged in user.
this.forceReceiptReload = true;
this.bridge.purchase(offer.productId, 1, this.context.getApplicationUsername(), discountId, success, error);
this.bridge.purchase(offer.productId, 1, this.context.getApplicationUsername(), discount, success, error);
});
}
finish(transaction) {
Expand Down

0 comments on commit 69b17b3

Please sign in to comment.