From 5d52fae81498887670af414f39edc69407e45cf2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hoelt Date: Sat, 6 Aug 2022 10:12:52 +0200 Subject: [PATCH] Update documentation and typescript definitions --- RELEASE_NOTES.md | 8 ++++- src/js/index.d.ts | 92 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 84 insertions(+), 16 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index de9041ea..df41215c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -66,7 +66,13 @@ export interface IPricingPhase { export type RecurrenceMode = "NON_RECURRING" | "FINITE_RECURRING" | "INFINITE_RECURRING"; ``` -You can also keep the plugin in `v10` compatibility mode using `store.compatibility`, in which case the legacy "introPrice", "billingPeriod" and such will be filled using the content of the pricingPhases array. Notice that this legacy mode can only support **at most** 2 pricing phases. +You can also keep the plugin in `v11` compatibility mode using `store.compatibility = 11` (or lower), in which case the legacy "introPrice", "billingPeriod" and such will be filled using the content of the pricingPhases array. Notice that this legacy mode can only support **at most** 2 pricing phases. + +When in `v11` compatibility mode: + + - prices and billing periods will be set using values from the last of the pricing phases. + - intro prices and billing periods will be set with the values from the first pricing phase (if there are more than one) + - product prices and billing periods will be set using values from the first offer for that product. ### NEW: `store.compatibility` - Legacy compatibility diff --git a/src/js/index.d.ts b/src/js/index.d.ts index 8b65ddd2..40882707 100644 --- a/src/js/index.d.ts +++ b/src/js/index.d.ts @@ -486,14 +486,17 @@ declare namespace IapStore { export interface ITransaction { /** Transaction identifier */ id?: string; - // Android only + /** Payment processing platform */ type: TransactionType; /** @deprecated */ developerPayload?: string; + /** Purchase token on Google Play */ purchaseToken?: string; + /** Receipt data on Google Play */ receipt?: string; - // iOS only + /** Receipt data on iOS >= 7 */ appStoreReceipt?: string; + /** Receipt data iOS <7 only */ transactionReceipt?: string; } @@ -534,14 +537,29 @@ declare namespace IapStore { export interface IStoreProduct extends IRegisterRequest { /** Additional data possibly required for product purchase */ additionalData: any; - /** Duration of the billing period for a subscription, in the units specified by the billingPeriodUnit property. (not available on iOS < 11.2) */ + + /** Duration of the billing period for a subscription, in the units specified by the billingPeriodUnit property. (not available on iOS < 11.2) + * + * @deprecated Use pricingPhases instead */ billingPeriod?: number; - /** Units of the billing period for a subscription. Possible values: Minute, Hour, Day, Week, Month, Year. (not available on iOS < 11.2) */ - billingPeriodUnit: IPeriodUnit; + /** Units of the billing period for a subscription. Possible values: Minute, Hour, Day, Week, Month, Year. (not available on iOS < 11.2) + * + * @deprecated Use pricingPhases instead */ + billingPeriodUnit?: IPeriodUnit; + /** ISO 8601 duration of the billing period (https://en.wikipedia.org/wiki/ISO_8601#Durations) + * + * @deprecated Use pricingPhases instead */ + billingPeriodISO?: string; + /** Number of recurrence cycles (if recurrenceMode is FINITE_RECURRING) + * + * @deprecated Use pricingPhases instead */ + billingCycles?: number; + /** Product is in a state where it can be purchased */ canPurchase: boolean; /** Country code. Available only on iOS */ countryCode: string; + /** Currency code */ currency?: string; /** Purchase has been initiated but is waiting for external action (for example, Ask to Buy on iOS) */ @@ -550,43 +568,86 @@ declare namespace IapStore { description: string; /** Array of discounts available for the product. */ discounts?: IStoreDiscount[]; + /** Product is downloading non-consumable content */ downloading: boolean; /** Non-consumable content has been successfully downloaded for this product */ downloaded: boolean; /** Latest known expiry date for a subscription (a javascript Date) */ expiryDate?: Date; - /** Localized introductory price (if applicable), with currency symbol */ + + /** Localized introductory price (if applicable), with currency symbol + * + * @deprecated Use pricingPhases instead */ introPrice?: string; - /** Introductory price in micro-units, if applicable (divide by 1000000 to get numeric price) */ + /** Introductory price in micro-units, if applicable (divide by 1000000 to get numeric price) + * + * @deprecated Use pricingPhases instead */ introPriceMicros?: number; - /** Duration the introductory price is available (in period-unit) */ + /** Duration the introductory price is available (in period-unit) + * + * @deprecated Use pricingPhases instead */ introPricePeriod?: string; - /** Period for the introductory price ("Day", "Week", "Month" or "Year") */ + /** Period for the introductory price ("Day", "Week", "Month" or "Year") + * + * @deprecated Use pricingPhases instead */ introPricePeriodUnit?: IPeriodUnit; - /** Payment mode for the introductory price ("PayAsYouGo", "UpFront", or "FreeTrial") */ + /** Duration of the introductory price in ISO 8601 (https://en.wikipedia.org/wiki/ISO_8601#Durations) + * + * @deprecated Use pricingPhases instead */ + introPeriodISO?: string; + /** Payment mode for the introductory price ("PayAsYouGo", "UpFront", or "FreeTrial") + * + * @deprecated Use pricingPhases instead */ introPricePaymentMode?: IPaymentMode; + /** Number of recurrence cycles for the introductory period (if introRecurrenceMode is FINITE_RECURRING) + * + * @deprecated Use pricingPhases instead */ + introCycles?: number; + /** Mode of payment for the introductory period ("PayAsYouGo", "UpFront", or "FreeTrial") + * + * @deprecated Use pricingPhases instead */ + introPaymentMode?: IPaymentMode; + /** Type of recurring payment for the introductory period + * + * @deprecated Use pricingPhases instead */ + introRecurrenceMode?: RecurrenceMode; + /** True when a trial or introductory price has been applied to a subscription. - * Only available after receipt validation. Only on iOS */ + * Only available after receipt validation. Only on iOS. */ ineligibleForIntroPrice?: boolean; - /** Latest date a subscription was renewed (a javascript Date) */ + /** Latest date a subscription was renewed (a javascript Date) + * Only available after receipt validation. Only on iOS. */ lastRenewalDate?: Date; /** Product has been loaded from server, however it can still be either valid or not */ loaded: string | boolean; /** Product is owned */ owned: boolean; + /** Human formatted price + * + * @deprecated Use pricingPhases instead */ price: string; - /** Price in micro-units (divide by 1000000 to get numeric price) */ + /** Price in micro-units (divide by 1000000 to get numeric price) + * + * @deprecated Use pricingPhases instead */ priceMicros?: number; + /** Type of recurring payment + * + * @deprecated Use pricingPhases instead */ + recurrenceMode?: RecurrenceMode; /** Current state the product is in (see life-cycle in the API documentatin). */ state: StoreProductState; /** Localized name or short description, as loaded from the store */ title: string; /** Latest transaction data for this product. */ transaction: ITransaction; - /** Duration of the trial period for the subscription, in the units specified by the trialPeriodUnit property (windows only) */ + /** Duration of the trial period for the subscription, in the units specified by the trialPeriodUnit property (windows only) + * + * @deprecated Use pricingPhases instead */ trialPeriod?: number; - /** Units of the trial period for a subscription (windows only) */ + /** Units of the trial period for a subscription (windows only) + * + * @deprecated Use pricingPhases instead */ trialPeriodUnit?: IPeriodUnit; /** Product has been loaded and is a valid product. * @@ -727,4 +788,5 @@ declare namespace store { export type ITransaction = IapStore.ITransaction; export type IRegisterRequest = IapStore.IRegisterRequest; export type IStoreProduct = IapStore.IStoreProduct; + export type RecurrenceMode = IapStore.RecurrenceMode; }