cordova-plugin-purchase
Advanced tools
Comparing version 13.3.1 to 13.3.2
@@ -417,3 +417,3 @@ # Class: Adapter | ||
▸ **order**(`offer`): `Promise`<`undefined` \| [`IError`](../interfaces/CdvPurchase.IError.md)\> | ||
▸ **order**(`offer`, `additionalData`): `Promise`<`undefined` \| [`IError`](../interfaces/CdvPurchase.IError.md)\> | ||
@@ -427,2 +427,3 @@ Initializes an order. | ||
| `offer` | [`Offer`](CdvPurchase.Offer.md) | | ||
| `additionalData` | [`AdditionalData`](../interfaces/CdvPurchase.AdditionalData.md) | | ||
@@ -429,0 +430,0 @@ #### Returns |
@@ -297,3 +297,3 @@ # Class: Bridge | ||
| `applicationUsername` | `undefined` \| `string` | | ||
| `discount` | `undefined` \| `string` | | ||
| `discount` | `undefined` \| [`PaymentDiscount`](../interfaces/CdvPurchase.AppleAppStore.PaymentDiscount.md) | | ||
| `success` | () => `void` | | ||
@@ -300,0 +300,0 @@ | `error` | () => `void` | |
@@ -16,2 +16,3 @@ # Interface: AdditionalData | ||
- [appStore](CdvPurchase.AdditionalData.md#appstore) | ||
- [applicationUsername](CdvPurchase.AdditionalData.md#applicationusername) | ||
@@ -23,2 +24,10 @@ - [braintree](CdvPurchase.AdditionalData.md#braintree) | ||
### appStore | ||
• `Optional` **appStore**: [`AdditionalData`](CdvPurchase.AppleAppStore.AdditionalData.md) | ||
Apple AppStore specific additional data | ||
___ | ||
### applicationUsername | ||
@@ -25,0 +34,0 @@ |
@@ -25,4 +25,6 @@ # Namespace: AppleAppStore | ||
- [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) | ||
@@ -29,0 +31,0 @@ ### Type Aliases |
@@ -156,3 +156,3 @@ # Namespace: CdvPurchase | ||
• `Const` **PLUGIN\_VERSION**: ``"13.3.1"`` | ||
• `Const` **PLUGIN\_VERSION**: ``"13.3.2"`` | ||
@@ -159,0 +159,0 @@ Current release number of the plugin. |
{ | ||
"name": "cordova-plugin-purchase", | ||
"version": "13.3.1", | ||
"version": "13.3.2", | ||
"description": "Cordova Purchase plugin for iOS, Android, Windows (AppStore, Play, UWP)", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -17,2 +17,9 @@ /// <reference path="../../types.ts" /> | ||
/** Additional data passed with an order on AppStore */ | ||
export interface AdditionalData { | ||
/** Information about the payment discount */ | ||
discount?: PaymentDiscount; | ||
} | ||
/** | ||
@@ -492,3 +499,3 @@ * Determine which discount the user is eligible to. | ||
async order(offer: Offer): Promise<undefined | IError> { | ||
async order(offer: Offer, additionalData: CdvPurchase.AdditionalData): Promise<undefined | IError> { | ||
let resolved = false; | ||
@@ -504,2 +511,9 @@ return new Promise(resolve => { | ||
const discountId = offer.id !== DEFAULT_OFFER_ID ? offer.id : undefined; | ||
const discount = additionalData?.appStore?.discount; | ||
if (discountId && !discount) { | ||
return callResolve(storeError(ErrorCode.MISSING_OFFER_PARAMS, 'Missing additionalData.appStore.discount when ordering a discount offer')); | ||
} | ||
if (discountId && (discount?.id !== discountId)) { | ||
return callResolve(storeError(ErrorCode.INVALID_OFFER_IDENTIFIER, 'Offer identifier does not match additionalData.appStore.discount.id')); | ||
} | ||
this.setPaymentMonitor((status: PaymentMonitorStatus, code?: ErrorCode, message?: string) => { | ||
@@ -536,3 +550,3 @@ this.log.info('order.paymentMonitor => ' + status + ' ' + (code ?? '') + ' ' + (message ?? '')); | ||
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); | ||
}); | ||
@@ -539,0 +553,0 @@ } |
@@ -20,2 +20,20 @@ namespace CdvPurchase { | ||
/** | ||
* The signed discount applied to a payment | ||
* | ||
* @see {@link https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc} | ||
*/ | ||
export 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; | ||
} | ||
export namespace Bridge { | ||
@@ -344,3 +362,3 @@ | ||
*/ | ||
purchase(productId: string, quantity: number, applicationUsername: string | undefined, discount: string | undefined, success: () => void, error: () => void) { | ||
purchase(productId: string, quantity: number, applicationUsername: string | undefined, discount: PaymentDiscount | undefined, success: () => void, error: () => void) { | ||
quantity = (quantity | 0) || 1; | ||
@@ -347,0 +365,0 @@ const options = this.options; |
@@ -27,3 +27,3 @@ /// <reference path="validator/validator.ts" /> | ||
*/ | ||
export const PLUGIN_VERSION = '13.3.1'; | ||
export const PLUGIN_VERSION = '13.3.2'; | ||
@@ -30,0 +30,0 @@ /** |
@@ -210,2 +210,5 @@ /// <reference path="store.ts" /> | ||
braintree?: Braintree.AdditionalData; | ||
/** Apple AppStore specific additional data */ | ||
appStore?: AppleAppStore.AdditionalData; | ||
} | ||
@@ -212,0 +215,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1889748
305
24340