expo-iap 2.8.0 → 2.8.1
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/CHANGELOG.md +38 -1
- package/CLAUDE.md +44 -7
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +52 -35
- package/build/ExpoIap.types.d.ts +19 -20
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js +0 -1
- package/build/ExpoIap.types.js.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/types/ExpoIapAndroid.types.d.ts +50 -15
- package/build/types/ExpoIapAndroid.types.d.ts.map +1 -1
- package/build/types/ExpoIapAndroid.types.js +11 -6
- package/build/types/ExpoIapAndroid.types.js.map +1 -1
- package/build/types/ExpoIapIOS.types.d.ts +43 -22
- package/build/types/ExpoIapIOS.types.d.ts.map +1 -1
- package/build/types/ExpoIapIOS.types.js.map +1 -1
- package/ios/ExpoIapModule.swift +87 -5
- package/package.json +1 -1
- package/src/ExpoIap.types.ts +38 -37
- package/src/index.ts +2 -2
- package/src/types/ExpoIapAndroid.types.ts +62 -15
- package/src/types/ExpoIapIOS.types.ts +49 -25
package/ios/ExpoIapModule.swift
CHANGED
|
@@ -106,10 +106,26 @@ func serializeTransaction(_ transaction: Transaction, jwsRepresentationIOS: Stri
|
|
|
106
106
|
|
|
107
107
|
if #available(iOS 15.4, *), let jsonData = jsonData {
|
|
108
108
|
if let price = jsonData["price"] as? NSNumber {
|
|
109
|
+
// START: Deprecated - will be removed in v2.9.0
|
|
110
|
+
// Use currencyCodeIOS, currencySymbolIOS, countryCodeIOS instead
|
|
109
111
|
purchaseMap["priceIOS"] = price.doubleValue
|
|
112
|
+
// END: Deprecated - will be removed in v2.9.0
|
|
110
113
|
}
|
|
111
114
|
if let currency = jsonData["currency"] as? String {
|
|
115
|
+
purchaseMap["currencyCodeIOS"] = currency
|
|
116
|
+
|
|
117
|
+
// Try to get currency symbol from locale
|
|
118
|
+
let locale = Locale(identifier: Locale.identifier(fromComponents: [NSLocale.Key.currencyCode.rawValue: currency]))
|
|
119
|
+
purchaseMap["currencySymbolIOS"] = locale.currencySymbol
|
|
120
|
+
|
|
121
|
+
// START: Deprecated - will be removed in v2.9.0
|
|
122
|
+
// Use currencyCodeIOS instead
|
|
112
123
|
purchaseMap["currencyIOS"] = currency
|
|
124
|
+
// END: Deprecated - will be removed in v2.9.0
|
|
125
|
+
}
|
|
126
|
+
// Extract country code from storefront if available
|
|
127
|
+
if let storefront = jsonData["storefront"] as? String {
|
|
128
|
+
purchaseMap["countryCodeIOS"] = storefront
|
|
113
129
|
}
|
|
114
130
|
}
|
|
115
131
|
|
|
@@ -162,20 +178,86 @@ func serializeSubscription(_ s: Product.SubscriptionInfo?) -> [String: Any?]? {
|
|
|
162
178
|
|
|
163
179
|
@available(iOS 15.0, *)
|
|
164
180
|
func serializeProduct(_ p: Product) -> [String: Any?] {
|
|
181
|
+
// Convert Product.ProductType to our expected 'inapp' or 'subs' string
|
|
182
|
+
let productType: String = p.subscription != nil ? "subs" : "inapp"
|
|
183
|
+
|
|
184
|
+
// For subscription products, add discounts and introductory price
|
|
185
|
+
var discounts: [[String: Any?]]? = nil
|
|
186
|
+
var introductoryPrice: String? = nil
|
|
187
|
+
var introductoryPriceAsAmountIOS: String? = nil
|
|
188
|
+
var introductoryPricePaymentModeIOS: String? = nil
|
|
189
|
+
var introductoryPriceNumberOfPeriodsIOS: String? = nil
|
|
190
|
+
var introductoryPriceSubscriptionPeriodIOS: String? = nil
|
|
191
|
+
var subscriptionPeriodNumberIOS: String? = nil
|
|
192
|
+
var subscriptionPeriodUnitIOS: String? = nil
|
|
193
|
+
|
|
194
|
+
if let subscription = p.subscription {
|
|
195
|
+
// Extract discount information from promotional offers
|
|
196
|
+
if !subscription.promotionalOffers.isEmpty {
|
|
197
|
+
discounts = subscription.promotionalOffers.compactMap { offer in
|
|
198
|
+
return [
|
|
199
|
+
"identifier": offer.id ?? "",
|
|
200
|
+
"type": offer.type.rawValue,
|
|
201
|
+
"numberOfPeriods": "\(offer.periodCount)",
|
|
202
|
+
"price": "\(offer.price)",
|
|
203
|
+
"localizedPrice": offer.displayPrice,
|
|
204
|
+
"paymentMode": offer.paymentMode.rawValue,
|
|
205
|
+
"subscriptionPeriod": getPeriodIOS(offer.period.unit)
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Extract introductory price from introductory offer
|
|
211
|
+
if let introOffer = subscription.introductoryOffer {
|
|
212
|
+
introductoryPrice = introOffer.displayPrice
|
|
213
|
+
introductoryPriceAsAmountIOS = "\(introOffer.price)"
|
|
214
|
+
introductoryPricePaymentModeIOS = introOffer.paymentMode.rawValue
|
|
215
|
+
introductoryPriceNumberOfPeriodsIOS = "\(introOffer.periodCount)"
|
|
216
|
+
introductoryPriceSubscriptionPeriodIOS = getPeriodIOS(introOffer.period.unit)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Extract subscription period information
|
|
220
|
+
subscriptionPeriodNumberIOS = "\(subscription.subscriptionPeriod.value)"
|
|
221
|
+
subscriptionPeriodUnitIOS = getPeriodIOS(subscription.subscriptionPeriod.unit)
|
|
222
|
+
}
|
|
223
|
+
|
|
165
224
|
return [
|
|
166
225
|
"debugDescription": serializeDebug(p.debugDescription),
|
|
167
226
|
"description": p.description,
|
|
168
|
-
|
|
227
|
+
// New iOS-suffixed fields
|
|
228
|
+
"displayNameIOS": p.displayName,
|
|
229
|
+
"discountsIOS": discounts,
|
|
230
|
+
"introductoryPriceIOS": introductoryPrice,
|
|
231
|
+
"introductoryPriceAsAmountIOS": introductoryPriceAsAmountIOS,
|
|
232
|
+
"introductoryPricePaymentModeIOS": introductoryPricePaymentModeIOS,
|
|
233
|
+
"introductoryPriceNumberOfPeriodsIOS": introductoryPriceNumberOfPeriodsIOS,
|
|
234
|
+
"introductoryPriceSubscriptionPeriodIOS": introductoryPriceSubscriptionPeriodIOS,
|
|
235
|
+
"subscriptionPeriodNumberIOS": subscriptionPeriodNumberIOS,
|
|
236
|
+
"subscriptionPeriodUnitIOS": subscriptionPeriodUnitIOS,
|
|
169
237
|
"displayPrice": p.displayPrice,
|
|
170
238
|
"id": p.id,
|
|
171
239
|
"title": p.displayName,
|
|
172
|
-
"
|
|
173
|
-
"
|
|
240
|
+
"isFamilyShareableIOS": p.isFamilyShareable,
|
|
241
|
+
"jsonRepresentationIOS": String(data: p.jsonRepresentation, encoding: .utf8),
|
|
174
242
|
"price": p.price,
|
|
175
|
-
"
|
|
176
|
-
"type":
|
|
243
|
+
"subscriptionInfoIOS": serializeSubscription(p.subscription),
|
|
244
|
+
"type": productType,
|
|
177
245
|
"currency": p.priceFormatStyle.currencyCode,
|
|
178
246
|
"platform": "ios",
|
|
247
|
+
// START: Deprecated - will be removed in v2.9.0
|
|
248
|
+
// Use displayNameIOS instead of displayName
|
|
249
|
+
"displayName": p.displayName,
|
|
250
|
+
// Use discountsIOS instead of discounts
|
|
251
|
+
"discounts": discounts,
|
|
252
|
+
// Use introductoryPriceIOS instead of introductoryPrice
|
|
253
|
+
"introductoryPrice": introductoryPrice,
|
|
254
|
+
// Use isFamilyShareableIOS instead of isFamilyShareable
|
|
255
|
+
"isFamilyShareable": p.isFamilyShareable,
|
|
256
|
+
// Use jsonRepresentationIOS instead of jsonRepresentation
|
|
257
|
+
"jsonRepresentation": String(data: p.jsonRepresentation, encoding: .utf8),
|
|
258
|
+
// Use subscriptionInfoIOS instead of subscription
|
|
259
|
+
"subscription": serializeSubscription(p.subscription),
|
|
260
|
+
// END: Deprecated - will be removed in v2.9.0
|
|
179
261
|
]
|
|
180
262
|
}
|
|
181
263
|
|
package/package.json
CHANGED
package/src/ExpoIap.types.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProductAndroid,
|
|
3
3
|
ProductPurchaseAndroid,
|
|
4
|
-
|
|
4
|
+
ProductSubscriptionAndroid,
|
|
5
5
|
} from './types/ExpoIapAndroid.types';
|
|
6
6
|
import {
|
|
7
7
|
ProductIOS,
|
|
8
8
|
ProductPurchaseIOS,
|
|
9
|
-
|
|
9
|
+
ProductSubscriptionIOS,
|
|
10
10
|
} from './types/ExpoIapIOS.types';
|
|
11
11
|
import {NATIVE_ERROR_CODES} from './ExpoIapModule';
|
|
12
12
|
|
|
@@ -16,7 +16,11 @@ export type ChangeEventPayload = {
|
|
|
16
16
|
|
|
17
17
|
export type ProductType = 'inapp' | 'subs';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// =============================================================================
|
|
20
|
+
// COMMON TYPES (Base types shared across all platforms)
|
|
21
|
+
// =============================================================================
|
|
22
|
+
|
|
23
|
+
export type ProductCommon = {
|
|
20
24
|
id: string;
|
|
21
25
|
title: string;
|
|
22
26
|
description: string;
|
|
@@ -25,15 +29,23 @@ export type ProductBase = {
|
|
|
25
29
|
displayPrice: string;
|
|
26
30
|
currency: string;
|
|
27
31
|
price?: number;
|
|
32
|
+
debugDescription?: string;
|
|
33
|
+
platform?: string;
|
|
28
34
|
};
|
|
29
35
|
|
|
30
|
-
export type
|
|
36
|
+
export type PurchaseCommon = {
|
|
31
37
|
id: string; // Transaction identifier - used by finishTransaction
|
|
32
38
|
productId: string; // Product identifier - which product was purchased
|
|
39
|
+
ids?: string[]; // Product identifiers for purchases that include multiple products
|
|
33
40
|
transactionId?: string; // @deprecated - use id instead
|
|
34
41
|
transactionDate: number;
|
|
35
42
|
transactionReceipt: string;
|
|
36
43
|
purchaseToken?: string; // Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android)
|
|
44
|
+
platform?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type ProductSubscriptionCommon = ProductCommon & {
|
|
48
|
+
type: 'subs';
|
|
37
49
|
};
|
|
38
50
|
|
|
39
51
|
// Define literal platform types for better type discrimination
|
|
@@ -46,35 +58,35 @@ export type Product =
|
|
|
46
58
|
| (ProductIOS & IosPlatform);
|
|
47
59
|
|
|
48
60
|
export type SubscriptionProduct =
|
|
49
|
-
| (
|
|
50
|
-
| (
|
|
51
|
-
|
|
52
|
-
// ============================================================================
|
|
53
|
-
// Legacy Types (For backward compatibility with useIAP hook)
|
|
54
|
-
// ============================================================================
|
|
55
|
-
|
|
56
|
-
// Re-export platform-specific purchase types for legacy compatibility
|
|
57
|
-
export type {ProductPurchaseAndroid} from './types/ExpoIapAndroid.types';
|
|
58
|
-
export type {ProductPurchaseIOS} from './types/ExpoIapIOS.types';
|
|
61
|
+
| (ProductSubscriptionAndroid & AndroidPlatform)
|
|
62
|
+
| (ProductSubscriptionIOS & IosPlatform);
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
// Re-export platform-specific types
|
|
65
|
+
export type {
|
|
66
|
+
ProductPurchaseAndroid,
|
|
67
|
+
PurchaseAndroid,
|
|
68
|
+
ProductSubscriptionAndroid,
|
|
69
|
+
SubscriptionProductAndroid, // Legacy
|
|
70
|
+
} from './types/ExpoIapAndroid.types';
|
|
71
|
+
export type {
|
|
72
|
+
ProductPurchaseIOS,
|
|
73
|
+
PurchaseIOS,
|
|
74
|
+
ProductSubscriptionIOS,
|
|
75
|
+
SubscriptionProductIOS, // Legacy
|
|
76
|
+
} from './types/ExpoIapIOS.types';
|
|
64
77
|
|
|
65
|
-
// Union type for platform-specific purchase types
|
|
78
|
+
// Union type for platform-specific purchase types
|
|
66
79
|
export type ProductPurchase =
|
|
67
80
|
| (ProductPurchaseAndroid & AndroidPlatform)
|
|
68
81
|
| (ProductPurchaseIOS & IosPlatform);
|
|
69
82
|
|
|
70
|
-
// Union type for platform-specific subscription purchase types
|
|
83
|
+
// Union type for platform-specific subscription purchase types
|
|
71
84
|
export type SubscriptionPurchase =
|
|
72
85
|
| (ProductPurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})
|
|
73
86
|
| (ProductPurchaseIOS & IosPlatform);
|
|
74
87
|
|
|
75
88
|
export type Purchase = ProductPurchase | SubscriptionPurchase;
|
|
76
89
|
|
|
77
|
-
// Legacy result type
|
|
78
90
|
export type PurchaseResult = {
|
|
79
91
|
responseCode?: number;
|
|
80
92
|
debugMessage?: string;
|
|
@@ -310,7 +322,7 @@ export interface UnifiedRequestPurchaseProps {
|
|
|
310
322
|
readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)
|
|
311
323
|
|
|
312
324
|
// iOS-specific properties (ignored on Android)
|
|
313
|
-
readonly
|
|
325
|
+
readonly andDangerouslyFinishTransactionAutomatically?: boolean;
|
|
314
326
|
readonly appAccountToken?: string;
|
|
315
327
|
readonly quantity?: number;
|
|
316
328
|
readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;
|
|
@@ -328,9 +340,9 @@ export interface UnifiedRequestPurchaseProps {
|
|
|
328
340
|
/**
|
|
329
341
|
* iOS-specific purchase request parameters
|
|
330
342
|
*/
|
|
331
|
-
export interface
|
|
343
|
+
export interface RequestPurchaseIosProps {
|
|
332
344
|
readonly sku: string;
|
|
333
|
-
readonly
|
|
345
|
+
readonly andDangerouslyFinishTransactionAutomatically?: boolean;
|
|
334
346
|
readonly appAccountToken?: string;
|
|
335
347
|
readonly quantity?: number;
|
|
336
348
|
readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;
|
|
@@ -364,7 +376,7 @@ export interface RequestSubscriptionAndroidProps
|
|
|
364
376
|
* Allows clear separation of iOS and Android parameters
|
|
365
377
|
*/
|
|
366
378
|
export interface RequestPurchasePropsByPlatforms {
|
|
367
|
-
readonly ios?:
|
|
379
|
+
readonly ios?: RequestPurchaseIosProps;
|
|
368
380
|
readonly android?: RequestPurchaseAndroidProps;
|
|
369
381
|
}
|
|
370
382
|
|
|
@@ -372,7 +384,7 @@ export interface RequestPurchasePropsByPlatforms {
|
|
|
372
384
|
* Modern platform-specific subscription request structure (v2.7.0+)
|
|
373
385
|
*/
|
|
374
386
|
export interface RequestSubscriptionPropsByPlatforms {
|
|
375
|
-
readonly ios?:
|
|
387
|
+
readonly ios?: RequestPurchaseIosProps;
|
|
376
388
|
readonly android?: RequestSubscriptionAndroidProps;
|
|
377
389
|
}
|
|
378
390
|
|
|
@@ -387,14 +399,3 @@ export type RequestPurchaseProps = RequestPurchasePropsByPlatforms;
|
|
|
387
399
|
* This is the recommended API moving forward
|
|
388
400
|
*/
|
|
389
401
|
export type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;
|
|
390
|
-
|
|
391
|
-
// ============================================================================
|
|
392
|
-
// Deprecated Aliases for Backward Compatibility
|
|
393
|
-
// ============================================================================
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* @deprecated Use RequestPurchaseIOSProps instead. This alias will be removed in v3.0.0.
|
|
397
|
-
*/
|
|
398
|
-
export type RequestPurchaseIosProps = RequestPurchaseIOSProps;
|
|
399
|
-
|
|
400
|
-
// Note: Type guard functions are exported from index.ts to avoid conflicts
|
package/src/index.ts
CHANGED
|
@@ -429,7 +429,7 @@ export const requestPurchase = (
|
|
|
429
429
|
|
|
430
430
|
const {
|
|
431
431
|
sku,
|
|
432
|
-
|
|
432
|
+
andDangerouslyFinishTransactionAutomatically = false,
|
|
433
433
|
appAccountToken,
|
|
434
434
|
quantity,
|
|
435
435
|
withOffer,
|
|
@@ -439,7 +439,7 @@ export const requestPurchase = (
|
|
|
439
439
|
const offer = offerToRecordIOS(withOffer);
|
|
440
440
|
const purchase = await ExpoIapModule.buyProduct(
|
|
441
441
|
sku,
|
|
442
|
-
|
|
442
|
+
andDangerouslyFinishTransactionAutomatically,
|
|
443
443
|
appAccountToken,
|
|
444
444
|
quantity ?? -1,
|
|
445
445
|
offer,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {PurchaseCommon, ProductCommon} from '../ExpoIap.types';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type ProductAndroidOneTimePurchaseOfferDetail = {
|
|
4
4
|
priceCurrencyCode: string;
|
|
5
5
|
formattedPrice: string;
|
|
6
6
|
priceAmountMicros: string;
|
|
@@ -20,21 +20,34 @@ type PricingPhasesAndroid = {
|
|
|
20
20
|
pricingPhaseList: PricingPhaseAndroid[];
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
type
|
|
23
|
+
type ProductSubscriptionAndroidOfferDetail = {
|
|
24
24
|
basePlanId: string;
|
|
25
|
-
offerId: string;
|
|
25
|
+
offerId: string | null;
|
|
26
26
|
offerToken: string;
|
|
27
27
|
offerTags: string[];
|
|
28
28
|
pricingPhases: PricingPhasesAndroid;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export type ProductAndroid =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
export type ProductAndroid = ProductCommon & {
|
|
32
|
+
nameAndroid: string;
|
|
33
|
+
oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail;
|
|
34
|
+
platform: 'android';
|
|
35
|
+
subscriptionOfferDetailsAndroid?: ProductSubscriptionAndroidOfferDetail[];
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use `nameAndroid` instead. This field will be removed in v2.9.0.
|
|
38
|
+
*/
|
|
39
|
+
name?: string;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `oneTimePurchaseOfferDetailsAndroid` instead. This field will be removed in v2.9.0.
|
|
42
|
+
*/
|
|
43
|
+
oneTimePurchaseOfferDetails?: ProductAndroidOneTimePurchaseOfferDetail;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `subscriptionOfferDetailsAndroid` instead. This field will be removed in v2.9.0.
|
|
46
|
+
*/
|
|
47
|
+
subscriptionOfferDetails?: ProductSubscriptionAndroidOfferDetail[];
|
|
35
48
|
};
|
|
36
49
|
|
|
37
|
-
type
|
|
50
|
+
type ProductSubscriptionAndroidOfferDetails = {
|
|
38
51
|
basePlanId: string;
|
|
39
52
|
offerId: string | null;
|
|
40
53
|
offerToken: string;
|
|
@@ -42,10 +55,17 @@ type SubscriptionOfferAndroid = {
|
|
|
42
55
|
offerTags: string[];
|
|
43
56
|
};
|
|
44
57
|
|
|
45
|
-
export type
|
|
46
|
-
|
|
58
|
+
export type ProductSubscriptionAndroid = ProductAndroid & {
|
|
59
|
+
subscriptionOfferDetailsAndroid: ProductSubscriptionAndroidOfferDetails[];
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use `subscriptionOfferDetailsAndroid` instead. This field will be removed in v2.9.0.
|
|
62
|
+
*/
|
|
63
|
+
subscriptionOfferDetails?: ProductSubscriptionAndroidOfferDetails[];
|
|
47
64
|
};
|
|
48
65
|
|
|
66
|
+
// Legacy naming for backward compatibility
|
|
67
|
+
export type SubscriptionProductAndroid = ProductSubscriptionAndroid;
|
|
68
|
+
|
|
49
69
|
export type RequestPurchaseAndroidProps = {
|
|
50
70
|
skus: string[];
|
|
51
71
|
obfuscatedAccountIdAndroid?: string;
|
|
@@ -110,14 +130,21 @@ export enum FeatureTypeAndroid {
|
|
|
110
130
|
SUBSCRIPTIONS_UPDATE = 'SUBSCRIPTIONS_UPDATE',
|
|
111
131
|
}
|
|
112
132
|
|
|
113
|
-
export enum
|
|
133
|
+
export enum PurchaseAndroidState {
|
|
114
134
|
UNSPECIFIED_STATE = 0,
|
|
115
135
|
PURCHASED = 1,
|
|
116
136
|
PENDING = 2,
|
|
117
137
|
}
|
|
118
138
|
|
|
119
|
-
|
|
120
|
-
|
|
139
|
+
// Legacy naming for backward compatibility
|
|
140
|
+
/**
|
|
141
|
+
* @deprecated Use `PurchaseAndroidState` instead. This enum will be removed in v2.9.0.
|
|
142
|
+
*/
|
|
143
|
+
export const PurchaseStateAndroid = PurchaseAndroidState;
|
|
144
|
+
|
|
145
|
+
// Legacy naming for backward compatibility
|
|
146
|
+
export type ProductPurchaseAndroid = PurchaseCommon & {
|
|
147
|
+
platform: 'android';
|
|
121
148
|
/**
|
|
122
149
|
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
123
150
|
*/
|
|
@@ -125,10 +152,30 @@ export type ProductPurchaseAndroid = PurchaseBase & {
|
|
|
125
152
|
dataAndroid?: string;
|
|
126
153
|
signatureAndroid?: string;
|
|
127
154
|
autoRenewingAndroid?: boolean;
|
|
128
|
-
purchaseStateAndroid?:
|
|
155
|
+
purchaseStateAndroid?: PurchaseAndroidState;
|
|
129
156
|
isAcknowledgedAndroid?: boolean;
|
|
130
157
|
packageNameAndroid?: string;
|
|
131
158
|
developerPayloadAndroid?: string;
|
|
132
159
|
obfuscatedAccountIdAndroid?: string;
|
|
133
160
|
obfuscatedProfileIdAndroid?: string;
|
|
134
161
|
};
|
|
162
|
+
|
|
163
|
+
// Preferred naming
|
|
164
|
+
export type PurchaseAndroid = ProductPurchaseAndroid;
|
|
165
|
+
|
|
166
|
+
// Legacy type aliases for backward compatibility
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated Use `ProductAndroidOneTimePurchaseOfferDetail` instead. This type will be removed in v2.9.0.
|
|
169
|
+
*/
|
|
170
|
+
export type OneTimePurchaseOfferDetails =
|
|
171
|
+
ProductAndroidOneTimePurchaseOfferDetail;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated Use `ProductSubscriptionAndroidOfferDetail` instead. This type will be removed in v2.9.0.
|
|
175
|
+
*/
|
|
176
|
+
export type SubscriptionOfferDetail = ProductSubscriptionAndroidOfferDetail;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated Use `ProductSubscriptionAndroidOfferDetails` instead. This type will be removed in v2.9.0.
|
|
180
|
+
*/
|
|
181
|
+
export type SubscriptionOfferAndroid = ProductSubscriptionAndroidOfferDetails;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {PurchaseCommon, ProductCommon} from '../ExpoIap.types';
|
|
2
2
|
|
|
3
3
|
type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';
|
|
4
4
|
type PaymentMode = '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';
|
|
@@ -26,10 +26,27 @@ type SubscriptionInfo = {
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export type ProductIOS =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
export type ProductIOS = ProductCommon & {
|
|
30
|
+
displayNameIOS: string;
|
|
31
|
+
isFamilyShareableIOS: boolean;
|
|
32
|
+
jsonRepresentationIOS: string;
|
|
33
|
+
platform: 'ios';
|
|
34
|
+
subscriptionInfoIOS?: SubscriptionInfo;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use `displayNameIOS` instead. This field will be removed in v2.9.0.
|
|
37
|
+
*/
|
|
38
|
+
displayName?: string;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use `isFamilyShareableIOS` instead. This field will be removed in v2.9.0.
|
|
41
|
+
*/
|
|
42
|
+
isFamilyShareable?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use `jsonRepresentationIOS` instead. This field will be removed in v2.9.0.
|
|
45
|
+
*/
|
|
46
|
+
jsonRepresentation?: string;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use `subscriptionInfoIOS` instead. This field will be removed in v2.9.0.
|
|
49
|
+
*/
|
|
33
50
|
subscription?: SubscriptionInfo;
|
|
34
51
|
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
35
52
|
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
|
|
@@ -45,17 +62,29 @@ export type Discount = {
|
|
|
45
62
|
subscriptionPeriod: string;
|
|
46
63
|
};
|
|
47
64
|
|
|
48
|
-
export type
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
export type ProductSubscriptionIOS = ProductIOS & {
|
|
66
|
+
discountsIOS?: Discount[];
|
|
67
|
+
introductoryPriceIOS?: string;
|
|
51
68
|
introductoryPriceAsAmountIOS?: string;
|
|
52
69
|
introductoryPricePaymentModeIOS?: PaymentMode;
|
|
53
70
|
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
54
71
|
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
|
|
72
|
+
platform: 'ios';
|
|
55
73
|
subscriptionPeriodNumberIOS?: string;
|
|
56
74
|
subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use `discountsIOS` instead. This field will be removed in v2.9.0.
|
|
77
|
+
*/
|
|
78
|
+
discounts?: Discount[];
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Use `introductoryPriceIOS` instead. This field will be removed in v2.9.0.
|
|
81
|
+
*/
|
|
82
|
+
introductoryPrice?: string;
|
|
57
83
|
};
|
|
58
84
|
|
|
85
|
+
// Legacy naming for backward compatibility
|
|
86
|
+
export type SubscriptionProductIOS = ProductSubscriptionIOS;
|
|
87
|
+
|
|
59
88
|
export type PaymentDiscount = {
|
|
60
89
|
/**
|
|
61
90
|
* A string used to uniquely identify a discount offer for a product.
|
|
@@ -79,9 +108,9 @@ export type PaymentDiscount = {
|
|
|
79
108
|
timestamp: number;
|
|
80
109
|
};
|
|
81
110
|
|
|
82
|
-
export type
|
|
111
|
+
export type RequestPurchaseIosProps = {
|
|
83
112
|
sku: string;
|
|
84
|
-
|
|
113
|
+
andDangerouslyFinishTransactionAutomatically?: boolean;
|
|
85
114
|
/**
|
|
86
115
|
* UUID representing user account
|
|
87
116
|
*/
|
|
@@ -90,18 +119,6 @@ export type RequestPurchaseIOSProps = {
|
|
|
90
119
|
withOffer?: PaymentDiscount;
|
|
91
120
|
};
|
|
92
121
|
|
|
93
|
-
export type RequestSubscriptionIOSProps = RequestPurchaseIOSProps;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @deprecated Use RequestPurchaseIOSProps instead. This alias will be removed in v3.0.0.
|
|
97
|
-
*/
|
|
98
|
-
export type RequestPurchaseIosProps = RequestPurchaseIOSProps;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated Use RequestSubscriptionIOSProps instead. This alias will be removed in v3.0.0.
|
|
102
|
-
*/
|
|
103
|
-
export type RequestSubscriptionIosProps = RequestSubscriptionIOSProps;
|
|
104
|
-
|
|
105
122
|
type SubscriptionStatus =
|
|
106
123
|
| 'expired'
|
|
107
124
|
| 'inBillingRetryPeriod'
|
|
@@ -120,8 +137,10 @@ export type ProductStatusIOS = {
|
|
|
120
137
|
renewalInfo?: RenewalInfo;
|
|
121
138
|
};
|
|
122
139
|
|
|
123
|
-
|
|
140
|
+
// Legacy naming for backward compatibility
|
|
141
|
+
export type ProductPurchaseIOS = PurchaseCommon & {
|
|
124
142
|
// iOS basic fields
|
|
143
|
+
platform: 'ios';
|
|
125
144
|
quantityIOS?: number;
|
|
126
145
|
originalTransactionDateIOS?: number;
|
|
127
146
|
originalTransactionIdentifierIOS?: string;
|
|
@@ -146,8 +165,10 @@ export type ProductPurchaseIOS = PurchaseBase & {
|
|
|
146
165
|
type: string;
|
|
147
166
|
paymentMode: string;
|
|
148
167
|
};
|
|
149
|
-
|
|
150
|
-
|
|
168
|
+
// Price locale fields
|
|
169
|
+
currencyCodeIOS?: string;
|
|
170
|
+
currencySymbolIOS?: string;
|
|
171
|
+
countryCodeIOS?: string;
|
|
151
172
|
/**
|
|
152
173
|
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
153
174
|
* iOS 15+ JWS representation is now available through the `purchaseToken` field.
|
|
@@ -155,6 +176,9 @@ export type ProductPurchaseIOS = PurchaseBase & {
|
|
|
155
176
|
jwsRepresentationIOS?: string;
|
|
156
177
|
};
|
|
157
178
|
|
|
179
|
+
// Preferred naming
|
|
180
|
+
export type PurchaseIOS = ProductPurchaseIOS;
|
|
181
|
+
|
|
158
182
|
export type AppTransactionIOS = {
|
|
159
183
|
appTransactionId?: string; // Only available in iOS 18.4+
|
|
160
184
|
originalPlatform?: string; // Only available in iOS 18.4+
|