react-native-iap 12.0.3 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/iap.js +143 -110
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js +2 -1
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js.map +1 -1
- package/lib/commonjs/internal/platform.js +28 -1
- package/lib/commonjs/internal/platform.js.map +1 -1
- package/lib/commonjs/modules/android.js.map +1 -1
- package/lib/commonjs/modules/ios.js.map +1 -1
- package/lib/commonjs/types/appleSk2.js +3 -0
- package/lib/commonjs/types/appleSk2.js.map +1 -1
- package/lib/commonjs/types/index.js +15 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/iap.js +143 -111
- package/lib/module/iap.js.map +1 -1
- package/lib/module/internal/fillProductsWithAdditionalData.js +2 -1
- package/lib/module/internal/fillProductsWithAdditionalData.js.map +1 -1
- package/lib/module/internal/platform.js +24 -0
- package/lib/module/internal/platform.js.map +1 -1
- package/lib/module/modules/android.js.map +1 -1
- package/lib/module/modules/ios.js.map +1 -1
- package/lib/module/types/appleSk2.js +2 -0
- package/lib/module/types/appleSk2.js.map +1 -1
- package/lib/module/types/index.js +12 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/iap.d.ts +4 -4
- package/lib/typescript/internal/fillProductsWithAdditionalData.d.ts +2 -1
- package/lib/typescript/internal/platform.d.ts +9 -0
- package/lib/typescript/modules/android.d.ts +1 -1
- package/lib/typescript/modules/ios.d.ts +4 -4
- package/lib/typescript/types/index.d.ts +54 -28
- package/package.json +1 -1
- package/src/iap.ts +130 -74
- package/src/internal/fillProductsWithAdditionalData.ts +3 -2
- package/src/internal/platform.ts +20 -0
- package/src/modules/android.ts +1 -1
- package/src/modules/ios.ts +5 -5
- package/src/types/appleSk2.ts +2 -0
- package/src/types/index.ts +70 -30
package/src/types/index.ts
CHANGED
|
@@ -54,10 +54,7 @@ export interface ProductCommon {
|
|
|
54
54
|
description: string;
|
|
55
55
|
price: string;
|
|
56
56
|
currency: string;
|
|
57
|
-
|
|
58
|
-
* For Android use subscription.subscriptionOfferDetails[*].pricingPhases.pricingPhaseList[*].formattedPrice
|
|
59
|
-
*/
|
|
60
|
-
localizedPrice?: string;
|
|
57
|
+
localizedPrice: string;
|
|
61
58
|
countryCode?: string;
|
|
62
59
|
}
|
|
63
60
|
|
|
@@ -129,33 +126,61 @@ export interface ProductIOS extends ProductCommon {
|
|
|
129
126
|
|
|
130
127
|
export type Product = ProductAndroid & ProductIOS;
|
|
131
128
|
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Can be used to distinguish the different platforms' subscription information
|
|
131
|
+
*/
|
|
132
|
+
export enum SubscriptionPlatform {
|
|
133
|
+
android = 'android',
|
|
134
|
+
amazon = 'amazon',
|
|
135
|
+
ios = 'ios',
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Android Billing v5 type */
|
|
139
|
+
export interface SubscriptionAndroid {
|
|
140
|
+
platform: SubscriptionPlatform.android;
|
|
141
|
+
productType: 'subs';
|
|
142
|
+
name: string;
|
|
143
|
+
title: string;
|
|
144
|
+
description: string;
|
|
145
|
+
productId: string;
|
|
146
|
+
subscriptionOfferDetails: SubscriptionOfferAndroid[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface SubscriptionOfferAndroid {
|
|
150
|
+
offerToken: string;
|
|
151
|
+
pricingPhases: {
|
|
152
|
+
pricingPhaseList: PricingPhaseAndroid[];
|
|
153
|
+
};
|
|
154
|
+
offerTags: string[];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface PricingPhaseAndroid {
|
|
158
|
+
formattedPrice: string;
|
|
159
|
+
priceCurrencyCode: string;
|
|
160
|
+
/**
|
|
161
|
+
* P1W, P1M, P1Y
|
|
162
|
+
*/
|
|
163
|
+
billingPeriod: string;
|
|
164
|
+
billingCycleCount: number;
|
|
165
|
+
priceAmountMicros: string;
|
|
166
|
+
recurrenceMode: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* TODO: As of 2022-10-10, this typing is not verified against the real
|
|
171
|
+
* Amazon API. Please update this if you have a more accurate type.
|
|
172
|
+
*/
|
|
173
|
+
export interface SubscriptionAmazon extends ProductCommon {
|
|
174
|
+
platform: SubscriptionPlatform.amazon;
|
|
134
175
|
type: 'subs';
|
|
135
176
|
|
|
136
177
|
productType?: string;
|
|
137
178
|
name?: string;
|
|
138
|
-
subscriptionOfferDetails?: {
|
|
139
|
-
offerToken: string;
|
|
140
|
-
pricingPhases: {
|
|
141
|
-
pricingPhaseList: {
|
|
142
|
-
formattedPrice: string;
|
|
143
|
-
priceCurrencyCode: string;
|
|
144
|
-
/**
|
|
145
|
-
* P1W, P1M, P1Y
|
|
146
|
-
*/
|
|
147
|
-
billingPeriod: string;
|
|
148
|
-
billingCycleCount: number;
|
|
149
|
-
priceAmountMicros: string;
|
|
150
|
-
recurrenceMode: number;
|
|
151
|
-
}[];
|
|
152
|
-
};
|
|
153
|
-
offerTags: string[];
|
|
154
|
-
}[];
|
|
155
179
|
}
|
|
156
180
|
|
|
157
181
|
export type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';
|
|
158
182
|
export interface SubscriptionIOS extends ProductCommon {
|
|
183
|
+
platform: SubscriptionPlatform.ios;
|
|
159
184
|
type: 'subs';
|
|
160
185
|
discounts?: Discount[];
|
|
161
186
|
introductoryPrice?: string;
|
|
@@ -172,7 +197,11 @@ export interface SubscriptionIOS extends ProductCommon {
|
|
|
172
197
|
subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
|
|
173
198
|
}
|
|
174
199
|
|
|
175
|
-
export type Subscription =
|
|
200
|
+
export type Subscription =
|
|
201
|
+
| SubscriptionAndroid
|
|
202
|
+
| SubscriptionAmazon
|
|
203
|
+
| SubscriptionIOS;
|
|
204
|
+
|
|
176
205
|
export interface RequestPurchaseBaseAndroid {
|
|
177
206
|
obfuscatedAccountIdAndroid?: string;
|
|
178
207
|
obfuscatedProfileIdAndroid?: string;
|
|
@@ -180,11 +209,11 @@ export interface RequestPurchaseBaseAndroid {
|
|
|
180
209
|
}
|
|
181
210
|
|
|
182
211
|
export interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {
|
|
183
|
-
skus
|
|
212
|
+
skus: Sku[];
|
|
184
213
|
}
|
|
185
214
|
|
|
186
215
|
export interface RequestPurchaseIOS {
|
|
187
|
-
sku
|
|
216
|
+
sku: Sku;
|
|
188
217
|
andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
|
|
189
218
|
/**
|
|
190
219
|
* UUID representing user account
|
|
@@ -194,7 +223,13 @@ export interface RequestPurchaseIOS {
|
|
|
194
223
|
withOffer?: Apple.PaymentDiscount;
|
|
195
224
|
}
|
|
196
225
|
|
|
197
|
-
|
|
226
|
+
/** As of 2022-10-12, we only use the `sku` field for Amazon purchases */
|
|
227
|
+
export type RequestPurchaseAmazon = RequestPurchaseIOS;
|
|
228
|
+
|
|
229
|
+
export type RequestPurchase =
|
|
230
|
+
| RequestPurchaseAndroid
|
|
231
|
+
| RequestPurchaseAmazon
|
|
232
|
+
| RequestPurchaseIOS;
|
|
198
233
|
|
|
199
234
|
/**
|
|
200
235
|
* In order to purchase a new subscription, every sku must have a selected offerToken
|
|
@@ -208,13 +243,18 @@ export interface SubscriptionOffer {
|
|
|
208
243
|
export interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {
|
|
209
244
|
purchaseTokenAndroid?: string;
|
|
210
245
|
prorationModeAndroid?: ProrationModesAndroid;
|
|
211
|
-
subscriptionOffers
|
|
246
|
+
subscriptionOffers: SubscriptionOffer[];
|
|
212
247
|
}
|
|
213
248
|
|
|
214
249
|
export type RequestSubscriptionIOS = RequestPurchaseIOS;
|
|
215
250
|
|
|
216
|
-
|
|
217
|
-
|
|
251
|
+
/** As of 2022-10-12, we only use the `sku` field for Amazon subscriptions */
|
|
252
|
+
export type RequestSubscriptionAmazon = RequestSubscriptionIOS;
|
|
253
|
+
|
|
254
|
+
export type RequestSubscription =
|
|
255
|
+
| RequestSubscriptionAndroid
|
|
256
|
+
| RequestSubscriptionAmazon
|
|
257
|
+
| RequestSubscriptionIOS;
|
|
218
258
|
|
|
219
259
|
declare module 'react-native' {
|
|
220
260
|
interface NativeModulesStatic {
|