react-native-iap 14.3.2 → 14.3.3
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/module/helpers/subscription.js +2 -2
- package/lib/module/helpers/subscription.js.map +1 -1
- package/lib/module/hooks/useIAP.js +14 -8
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +76 -23
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +90 -190
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/error.js +4 -4
- package/lib/module/utils/error.js.map +1 -1
- package/lib/module/utils/errorMapping.js +34 -10
- package/lib/module/utils/errorMapping.js.map +1 -1
- package/lib/module/utils/type-bridge.js +217 -173
- package/lib/module/utils/type-bridge.js.map +1 -1
- package/lib/typescript/src/helpers/subscription.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +8 -11
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +11 -10
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +2 -2
- package/lib/typescript/src/types.d.ts +606 -518
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/errorMapping.d.ts +2 -1
- package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
- package/lib/typescript/src/utils/type-bridge.d.ts +13 -14
- package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +4 -4
- package/nitrogen/generated/android/c++/{JNitroAndroidReceiptValidationOptions.hpp → JNitroReceiptValidationAndroidOptions.hpp} +9 -9
- package/nitrogen/generated/android/c++/JNitroReceiptValidationParams.hpp +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/{NitroAndroidReceiptValidationOptions.kt → NitroReceiptValidationAndroidOptions.kt} +3 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationParams.kt +1 -1
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +10 -10
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +3 -3
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +3 -3
- package/nitrogen/generated/ios/swift/{NitroAndroidReceiptValidationOptions.swift → NitroReceiptValidationAndroidOptions.swift} +5 -5
- package/nitrogen/generated/ios/swift/NitroReceiptValidationParams.swift +9 -9
- package/nitrogen/generated/shared/c++/{NitroAndroidReceiptValidationOptions.hpp → NitroReceiptValidationAndroidOptions.hpp} +10 -10
- package/nitrogen/generated/shared/c++/NitroReceiptValidationParams.hpp +8 -8
- package/package.json +1 -1
- package/src/helpers/subscription.ts +8 -9
- package/src/hooks/useIAP.ts +52 -47
- package/src/index.ts +123 -35
- package/src/specs/RnIap.nitro.ts +2 -2
- package/src/types.ts +651 -616
- package/src/utils/error.ts +4 -4
- package/src/utils/errorMapping.ts +47 -19
- package/src/utils/type-bridge.ts +308 -204
package/src/types.ts
CHANGED
|
@@ -1,665 +1,583 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// ⚠️ IMPORTANT: DO NOT MODIFY THIS FILE
|
|
6
|
-
//
|
|
7
|
-
// This types.ts file is based on the original react-native-iap library
|
|
8
|
-
// and maintains backward compatibility for existing users.
|
|
9
|
-
//
|
|
10
|
-
// Any changes to these types could break existing applications.
|
|
11
|
-
// New Nitro-specific types are defined in src/specs/RnIap.nitro.ts
|
|
12
|
-
//
|
|
2
|
+
// AUTO-GENERATED TYPES — DO NOT EDIT DIRECTLY
|
|
3
|
+
// Run `npm run generate` after updating any *.graphql schema file.
|
|
13
4
|
// ============================================================================
|
|
14
5
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
export interface ActiveSubscription {
|
|
7
|
+
autoRenewingAndroid?: boolean | null;
|
|
8
|
+
daysUntilExpirationIOS?: number | null;
|
|
9
|
+
environmentIOS?: string | null;
|
|
10
|
+
expirationDateIOS?: number | null;
|
|
11
|
+
isActive: boolean;
|
|
12
|
+
productId: string;
|
|
13
|
+
purchaseToken?: string | null;
|
|
14
|
+
transactionDate: number;
|
|
15
|
+
transactionId: string;
|
|
16
|
+
willExpireSoon?: boolean | null;
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
nonRenewingSubscription = 'nonRenewingSubscription',
|
|
19
|
+
export interface AndroidSubscriptionOfferInput {
|
|
20
|
+
/** Offer token */
|
|
21
|
+
offerToken: string;
|
|
22
|
+
/** Product SKU */
|
|
23
|
+
sku: string;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
export interface AppTransaction {
|
|
27
|
+
appId: number;
|
|
28
|
+
appTransactionId?: string | null;
|
|
29
|
+
appVersion: string;
|
|
30
|
+
appVersionId: number;
|
|
31
|
+
bundleId: string;
|
|
32
|
+
deviceVerification: string;
|
|
33
|
+
deviceVerificationNonce: string;
|
|
34
|
+
environment: string;
|
|
35
|
+
originalAppVersion: string;
|
|
36
|
+
originalPlatform?: string | null;
|
|
37
|
+
originalPurchaseDate: number;
|
|
38
|
+
preorderDate?: number | null;
|
|
39
|
+
signedDate: number;
|
|
40
|
+
}
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/** Product title displayed to users */
|
|
38
|
-
title: string;
|
|
39
|
-
/** Product description */
|
|
40
|
-
description: string;
|
|
41
|
-
/** Product type: 'inapp' or 'subs' for Android compatibility */
|
|
42
|
-
type: 'inapp' | 'subs'; // Note: this is the actual product type, not for filtering
|
|
43
|
-
/** Display name for the product */
|
|
44
|
-
displayName?: string;
|
|
45
|
-
/** Formatted price string for display (e.g., "$9.99") */
|
|
46
|
-
displayPrice: string;
|
|
47
|
-
/** Currency code (e.g., "USD", "EUR") */
|
|
48
|
-
currency: string;
|
|
49
|
-
/** Raw price value as number */
|
|
50
|
-
price?: number;
|
|
51
|
-
/** Debug description for development */
|
|
52
|
-
debugDescription?: string;
|
|
53
|
-
/** Platform identifier ('ios' or 'android') */
|
|
54
|
-
platform?: string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Base purchase information shared across all platforms
|
|
59
|
-
* Represents both consumables, non-consumables, and subscriptions
|
|
60
|
-
*/
|
|
61
|
-
export type PurchaseCommon = {
|
|
62
|
-
/** Transaction identifier - used by finishTransaction */
|
|
63
|
-
id: string;
|
|
64
|
-
/** Product identifier - which product was purchased */
|
|
65
|
-
productId: string;
|
|
66
|
-
/** Product identifiers for purchases that include multiple products */
|
|
67
|
-
ids?: string[];
|
|
68
|
-
/** @deprecated - use id instead */
|
|
69
|
-
transactionId?: string;
|
|
70
|
-
/** Transaction timestamp in milliseconds */
|
|
71
|
-
transactionDate: number;
|
|
72
|
-
/** Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android) */
|
|
73
|
-
purchaseToken?: string;
|
|
74
|
-
/** Platform identifier ('ios' or 'android') */
|
|
75
|
-
platform?: string;
|
|
76
|
-
/** Purchase quantity (defaults to 1) */
|
|
77
|
-
quantity: number;
|
|
78
|
-
/** Purchase state (common field) */
|
|
79
|
-
purchaseState: PurchaseState;
|
|
80
|
-
/** Auto-renewable subscription flag (common field) */
|
|
81
|
-
isAutoRenewing: boolean;
|
|
82
|
-
};
|
|
42
|
+
export interface DeepLinkOptions {
|
|
43
|
+
/** Android package name to target (required on Android) */
|
|
44
|
+
packageNameAndroid?: string | null;
|
|
45
|
+
/** Android SKU to open (required on Android) */
|
|
46
|
+
skuAndroid?: string | null;
|
|
47
|
+
}
|
|
83
48
|
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
49
|
+
export interface DiscountIOS {
|
|
50
|
+
identifier: string;
|
|
51
|
+
localizedPrice?: string | null;
|
|
52
|
+
numberOfPeriods: number;
|
|
53
|
+
paymentMode: PaymentModeIOS;
|
|
54
|
+
price: string;
|
|
55
|
+
priceAmount: number;
|
|
56
|
+
subscriptionPeriod: string;
|
|
57
|
+
type: string;
|
|
91
58
|
}
|
|
92
59
|
|
|
93
|
-
export
|
|
94
|
-
|
|
95
|
-
|
|
60
|
+
export interface DiscountOfferIOS {
|
|
61
|
+
/** Discount identifier */
|
|
62
|
+
identifier: string;
|
|
63
|
+
/** Key identifier for validation */
|
|
64
|
+
keyIdentifier: string;
|
|
65
|
+
/** Cryptographic nonce */
|
|
66
|
+
nonce: string;
|
|
67
|
+
/** Signature for validation */
|
|
68
|
+
signature: string;
|
|
69
|
+
/** Timestamp of discount offer */
|
|
70
|
+
timestamp: number;
|
|
71
|
+
}
|
|
96
72
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
73
|
+
export interface DiscountOfferInputIOS {
|
|
74
|
+
/** Discount identifier */
|
|
75
|
+
identifier: string;
|
|
76
|
+
/** Key identifier for validation */
|
|
77
|
+
keyIdentifier: string;
|
|
78
|
+
/** Cryptographic nonce */
|
|
79
|
+
nonce: string;
|
|
80
|
+
/** Signature for validation */
|
|
81
|
+
signature: string;
|
|
82
|
+
/** Timestamp of discount offer */
|
|
83
|
+
timestamp: number;
|
|
84
|
+
}
|
|
100
85
|
|
|
101
|
-
export
|
|
102
|
-
|
|
86
|
+
export interface EntitlementIOS {
|
|
87
|
+
jsonRepresentation: string;
|
|
88
|
+
sku: string;
|
|
89
|
+
transactionId: string;
|
|
90
|
+
}
|
|
103
91
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
export enum ErrorCode {
|
|
93
|
+
ActivityUnavailable = 'ACTIVITY_UNAVAILABLE',
|
|
94
|
+
AlreadyOwned = 'ALREADY_OWNED',
|
|
95
|
+
AlreadyPrepared = 'ALREADY_PREPARED',
|
|
96
|
+
BillingResponseJsonParseError = 'BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
97
|
+
BillingUnavailable = 'BILLING_UNAVAILABLE',
|
|
98
|
+
ConnectionClosed = 'CONNECTION_CLOSED',
|
|
99
|
+
DeferredPayment = 'DEFERRED_PAYMENT',
|
|
100
|
+
DeveloperError = 'DEVELOPER_ERROR',
|
|
101
|
+
EmptySkuList = 'EMPTY_SKU_LIST',
|
|
102
|
+
FeatureNotSupported = 'FEATURE_NOT_SUPPORTED',
|
|
103
|
+
IapNotAvailable = 'IAP_NOT_AVAILABLE',
|
|
104
|
+
InitConnection = 'INIT_CONNECTION',
|
|
105
|
+
Interrupted = 'INTERRUPTED',
|
|
106
|
+
ItemNotOwned = 'ITEM_NOT_OWNED',
|
|
107
|
+
ItemUnavailable = 'ITEM_UNAVAILABLE',
|
|
108
|
+
NetworkError = 'NETWORK_ERROR',
|
|
109
|
+
NotEnded = 'NOT_ENDED',
|
|
110
|
+
NotPrepared = 'NOT_PREPARED',
|
|
111
|
+
Pending = 'PENDING',
|
|
112
|
+
PurchaseError = 'PURCHASE_ERROR',
|
|
113
|
+
QueryProduct = 'QUERY_PRODUCT',
|
|
114
|
+
ReceiptFailed = 'RECEIPT_FAILED',
|
|
115
|
+
ReceiptFinished = 'RECEIPT_FINISHED',
|
|
116
|
+
ReceiptFinishedFailed = 'RECEIPT_FINISHED_FAILED',
|
|
117
|
+
RemoteError = 'REMOTE_ERROR',
|
|
118
|
+
ServiceDisconnected = 'SERVICE_DISCONNECTED',
|
|
119
|
+
ServiceError = 'SERVICE_ERROR',
|
|
120
|
+
SkuNotFound = 'SKU_NOT_FOUND',
|
|
121
|
+
SkuOfferMismatch = 'SKU_OFFER_MISMATCH',
|
|
122
|
+
SyncError = 'SYNC_ERROR',
|
|
123
|
+
TransactionValidationFailed = 'TRANSACTION_VALIDATION_FAILED',
|
|
124
|
+
Unknown = 'UNKNOWN',
|
|
125
|
+
UserCancelled = 'USER_CANCELLED',
|
|
126
|
+
UserError = 'USER_ERROR',
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface FetchProductsResult {
|
|
130
|
+
products?: Product[] | null;
|
|
131
|
+
subscriptions?: ProductSubscription[] | null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export enum IapEvent {
|
|
135
|
+
PromotedProductIos = 'PROMOTED_PRODUCT_IOS',
|
|
136
|
+
PurchaseError = 'PURCHASE_ERROR',
|
|
137
|
+
PurchaseUpdated = 'PURCHASE_UPDATED',
|
|
138
|
+
}
|
|
107
139
|
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
export interface Mutation {
|
|
141
|
+
/** Acknowledge a non-consumable purchase or subscription */
|
|
142
|
+
acknowledgePurchaseAndroid: Promise<VoidResult>;
|
|
143
|
+
/** Initiate a refund request for a product (iOS 15+) */
|
|
144
|
+
beginRefundRequestIOS: Promise<RefundResultIOS>;
|
|
145
|
+
/** Clear pending transactions from the StoreKit payment queue */
|
|
146
|
+
clearTransactionIOS: Promise<VoidResult>;
|
|
147
|
+
/** Consume a purchase token so it can be repurchased */
|
|
148
|
+
consumePurchaseAndroid: Promise<VoidResult>;
|
|
149
|
+
/** Open the native subscription management surface */
|
|
150
|
+
deepLinkToSubscriptions: Promise<VoidResult>;
|
|
151
|
+
/** Close the platform billing connection */
|
|
152
|
+
endConnection: Promise<boolean>;
|
|
153
|
+
/** Finish a transaction after validating receipts */
|
|
154
|
+
finishTransaction: Promise<VoidResult>;
|
|
155
|
+
/** Establish the platform billing connection */
|
|
156
|
+
initConnection: Promise<boolean>;
|
|
157
|
+
/** Present the App Store code redemption sheet */
|
|
158
|
+
presentCodeRedemptionSheetIOS: Promise<VoidResult>;
|
|
159
|
+
/** Initiate a purchase flow; rely on events for final state */
|
|
160
|
+
requestPurchase?: Promise<RequestPurchaseResult | null>;
|
|
161
|
+
/** Purchase the promoted product surfaced by the App Store */
|
|
162
|
+
requestPurchaseOnPromotedProductIOS: Promise<PurchaseIOS>;
|
|
163
|
+
/** Restore completed purchases across platforms */
|
|
164
|
+
restorePurchases: Promise<VoidResult>;
|
|
165
|
+
/** Open subscription management UI and return changed purchases (iOS 15+) */
|
|
166
|
+
showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;
|
|
167
|
+
/** Force a StoreKit sync for transactions (iOS 15+) */
|
|
168
|
+
syncIOS: Promise<VoidResult>;
|
|
169
|
+
/** Validate purchase receipts with the configured providers */
|
|
170
|
+
validateReceipt: Promise<ReceiptValidationResult>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface MutationacknowledgePurchaseAndroidArgs {
|
|
174
|
+
purchaseToken: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface MutationbeginRefundRequestIOSArgs {
|
|
178
|
+
sku: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface MutationconsumePurchaseAndroidArgs {
|
|
182
|
+
purchaseToken: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface MutationdeepLinkToSubscriptionsArgs {
|
|
186
|
+
options?: DeepLinkOptions | null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface MutationfinishTransactionArgs {
|
|
190
|
+
isConsumable?: boolean | null;
|
|
191
|
+
purchase: PurchaseInput;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface MutationrequestPurchaseArgs {
|
|
195
|
+
params: PurchaseParams;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface MutationvalidateReceiptArgs {
|
|
199
|
+
options: ReceiptValidationProps;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export enum PaymentModeIOS {
|
|
203
|
+
Empty = 'EMPTY',
|
|
204
|
+
FreeTrial = 'FREE_TRIAL',
|
|
205
|
+
PayAsYouGo = 'PAY_AS_YOU_GO',
|
|
206
|
+
PayUpFront = 'PAY_UP_FRONT',
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export enum Platform {
|
|
210
|
+
Android = 'ANDROID',
|
|
211
|
+
Ios = 'IOS',
|
|
212
|
+
}
|
|
110
213
|
|
|
111
|
-
|
|
214
|
+
export interface PricingPhaseAndroid {
|
|
215
|
+
billingCycleCount: number;
|
|
216
|
+
billingPeriod: string;
|
|
217
|
+
formattedPrice: string;
|
|
218
|
+
priceAmountMicros: string;
|
|
219
|
+
priceCurrencyCode: string;
|
|
220
|
+
recurrenceMode: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface PricingPhasesAndroid {
|
|
224
|
+
pricingPhaseList: PricingPhaseAndroid[];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export type Product = ProductAndroid | ProductIOS;
|
|
228
|
+
|
|
229
|
+
export interface ProductAndroid extends ProductCommon {
|
|
230
|
+
currency: string;
|
|
231
|
+
debugDescription?: string | null;
|
|
232
|
+
description: string;
|
|
233
|
+
displayName?: string | null;
|
|
112
234
|
displayPrice: string;
|
|
113
235
|
id: string;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
236
|
+
nameAndroid: string;
|
|
237
|
+
oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail | null;
|
|
238
|
+
platform: Platform;
|
|
239
|
+
price?: number | null;
|
|
240
|
+
subscriptionOfferDetailsAndroid?:
|
|
241
|
+
| ProductSubscriptionAndroidOfferDetails[]
|
|
242
|
+
| null;
|
|
243
|
+
title: string;
|
|
244
|
+
type: ProductType;
|
|
245
|
+
}
|
|
123
246
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
unit: SubscriptionIosPeriod;
|
|
130
|
-
value: number;
|
|
131
|
-
};
|
|
132
|
-
};
|
|
247
|
+
export interface ProductAndroidOneTimePurchaseOfferDetail {
|
|
248
|
+
formattedPrice: string;
|
|
249
|
+
priceAmountMicros: string;
|
|
250
|
+
priceCurrencyCode: string;
|
|
251
|
+
}
|
|
133
252
|
|
|
134
|
-
export
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
253
|
+
export interface ProductCommon {
|
|
254
|
+
currency: string;
|
|
255
|
+
debugDescription?: string | null;
|
|
256
|
+
description: string;
|
|
257
|
+
displayName?: string | null;
|
|
258
|
+
displayPrice: string;
|
|
259
|
+
id: string;
|
|
260
|
+
platform: Platform;
|
|
261
|
+
price?: number | null;
|
|
262
|
+
title: string;
|
|
263
|
+
type: ProductType;
|
|
264
|
+
}
|
|
143
265
|
|
|
144
|
-
export
|
|
266
|
+
export interface ProductIOS extends ProductCommon {
|
|
267
|
+
currency: string;
|
|
268
|
+
debugDescription?: string | null;
|
|
269
|
+
description: string;
|
|
270
|
+
displayName?: string | null;
|
|
145
271
|
displayNameIOS: string;
|
|
272
|
+
displayPrice: string;
|
|
273
|
+
id: string;
|
|
146
274
|
isFamilyShareableIOS: boolean;
|
|
147
275
|
jsonRepresentationIOS: string;
|
|
148
|
-
platform:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
jsonRepresentation?: string;
|
|
155
|
-
subscription?: SubscriptionInfo;
|
|
156
|
-
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
157
|
-
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export type ProductSubscriptionIOS = ProductIOS & {
|
|
161
|
-
discountsIOS?: Discount[];
|
|
162
|
-
introductoryPriceIOS?: string;
|
|
163
|
-
introductoryPriceAsAmountIOS?: string;
|
|
164
|
-
introductoryPricePaymentModeIOS?: PaymentMode;
|
|
165
|
-
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
166
|
-
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
|
|
167
|
-
platform: 'ios';
|
|
168
|
-
subscriptionPeriodNumberIOS?: string;
|
|
169
|
-
subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
|
|
170
|
-
// deprecated
|
|
171
|
-
discounts?: Discount[];
|
|
172
|
-
introductoryPrice?: string;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
export type PurchaseIOS = PurchaseCommon & {
|
|
176
|
-
platform: 'ios';
|
|
177
|
-
quantityIOS?: number;
|
|
178
|
-
originalTransactionDateIOS?: number;
|
|
179
|
-
originalTransactionIdentifierIOS?: string;
|
|
180
|
-
appAccountToken?: string;
|
|
181
|
-
// iOS additional fields from StoreKit 2
|
|
182
|
-
expirationDateIOS?: number;
|
|
183
|
-
webOrderLineItemIdIOS?: number;
|
|
184
|
-
environmentIOS?: string;
|
|
185
|
-
storefrontCountryCodeIOS?: string;
|
|
186
|
-
appBundleIdIOS?: string;
|
|
187
|
-
productTypeIOS?: string;
|
|
188
|
-
subscriptionGroupIdIOS?: string;
|
|
189
|
-
isUpgradedIOS?: boolean;
|
|
190
|
-
ownershipTypeIOS?: string;
|
|
191
|
-
reasonIOS?: string;
|
|
192
|
-
reasonStringRepresentationIOS?: string;
|
|
193
|
-
transactionReasonIOS?: 'PURCHASE' | 'RENEWAL' | string;
|
|
194
|
-
revocationDateIOS?: number;
|
|
195
|
-
revocationReasonIOS?: string;
|
|
196
|
-
offerIOS?: {
|
|
197
|
-
id: string;
|
|
198
|
-
type: string;
|
|
199
|
-
paymentMode: string;
|
|
200
|
-
};
|
|
201
|
-
// Price locale fields
|
|
202
|
-
currencyCodeIOS?: string;
|
|
203
|
-
currencySymbolIOS?: string;
|
|
204
|
-
countryCodeIOS?: string;
|
|
205
|
-
/**
|
|
206
|
-
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
207
|
-
* iOS 15+ JWS representation is now available through the `purchaseToken` field.
|
|
208
|
-
*/
|
|
209
|
-
jwsRepresentationIOS?: string;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* iOS subscription renewal info
|
|
214
|
-
*/
|
|
215
|
-
export interface SubscriptionRenewalInfoIOS {
|
|
216
|
-
autoRenewStatus: boolean;
|
|
217
|
-
autoRenewPreference?: string;
|
|
218
|
-
expirationReason?: number;
|
|
219
|
-
gracePeriodExpirationDate?: number;
|
|
220
|
-
currentProductID?: string;
|
|
221
|
-
platform: 'ios';
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* iOS subscription status entry
|
|
226
|
-
*/
|
|
227
|
-
export interface SubscriptionStatusIOS {
|
|
228
|
-
state: number;
|
|
229
|
-
platform: 'ios';
|
|
230
|
-
renewalInfo?: SubscriptionRenewalInfoIOS;
|
|
276
|
+
platform: Platform;
|
|
277
|
+
price?: number | null;
|
|
278
|
+
subscriptionInfoIOS?: SubscriptionInfoIOS | null;
|
|
279
|
+
title: string;
|
|
280
|
+
type: ProductType;
|
|
281
|
+
typeIOS: ProductTypeIOS;
|
|
231
282
|
}
|
|
232
283
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
284
|
+
export enum ProductQueryType {
|
|
285
|
+
All = 'ALL',
|
|
286
|
+
InApp = 'IN_APP',
|
|
287
|
+
Subs = 'SUBS',
|
|
288
|
+
}
|
|
236
289
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
290
|
+
export interface ProductRequest {
|
|
291
|
+
skus: string[];
|
|
292
|
+
type?: ProductQueryType | null;
|
|
293
|
+
}
|
|
242
294
|
|
|
243
|
-
type
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
billingPeriod: string; // P1W, P1M, P1Y
|
|
247
|
-
billingCycleCount: number;
|
|
248
|
-
priceAmountMicros: string;
|
|
249
|
-
recurrenceMode: number;
|
|
250
|
-
};
|
|
295
|
+
export type ProductSubscription =
|
|
296
|
+
| ProductSubscriptionAndroid
|
|
297
|
+
| ProductSubscriptionIOS;
|
|
251
298
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
299
|
+
export interface ProductSubscriptionAndroid extends ProductCommon {
|
|
300
|
+
currency: string;
|
|
301
|
+
debugDescription?: string | null;
|
|
302
|
+
description: string;
|
|
303
|
+
displayName?: string | null;
|
|
304
|
+
displayPrice: string;
|
|
305
|
+
id: string;
|
|
306
|
+
nameAndroid: string;
|
|
307
|
+
oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail | null;
|
|
308
|
+
platform: Platform;
|
|
309
|
+
price?: number | null;
|
|
310
|
+
subscriptionOfferDetailsAndroid: ProductSubscriptionAndroidOfferDetails[];
|
|
311
|
+
title: string;
|
|
312
|
+
type: ProductType;
|
|
313
|
+
}
|
|
255
314
|
|
|
256
|
-
|
|
315
|
+
export interface ProductSubscriptionAndroidOfferDetails {
|
|
257
316
|
basePlanId: string;
|
|
258
|
-
offerId
|
|
259
|
-
offerToken: string;
|
|
317
|
+
offerId?: string | null;
|
|
260
318
|
offerTags: string[];
|
|
261
|
-
pricingPhases: PricingPhasesAndroid;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
type ProductSubscriptionAndroidOfferDetails = {
|
|
265
|
-
basePlanId: string;
|
|
266
|
-
offerId: string | null;
|
|
267
319
|
offerToken: string;
|
|
268
320
|
pricingPhases: PricingPhasesAndroid;
|
|
269
|
-
|
|
270
|
-
};
|
|
321
|
+
}
|
|
271
322
|
|
|
272
|
-
export
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
/** @deprecated Use the common `isAutoRenewing` field instead */
|
|
298
|
-
autoRenewingAndroid?: boolean;
|
|
299
|
-
isAcknowledgedAndroid?: boolean;
|
|
300
|
-
packageNameAndroid?: string;
|
|
301
|
-
developerPayloadAndroid?: string;
|
|
302
|
-
obfuscatedAccountIdAndroid?: string;
|
|
303
|
-
obfuscatedProfileIdAndroid?: string;
|
|
304
|
-
};
|
|
323
|
+
export interface ProductSubscriptionIOS extends ProductCommon {
|
|
324
|
+
currency: string;
|
|
325
|
+
debugDescription?: string | null;
|
|
326
|
+
description: string;
|
|
327
|
+
discountsIOS?: DiscountIOS[] | null;
|
|
328
|
+
displayName?: string | null;
|
|
329
|
+
displayNameIOS: string;
|
|
330
|
+
displayPrice: string;
|
|
331
|
+
id: string;
|
|
332
|
+
introductoryPriceAsAmountIOS?: string | null;
|
|
333
|
+
introductoryPriceIOS?: string | null;
|
|
334
|
+
introductoryPriceNumberOfPeriodsIOS?: string | null;
|
|
335
|
+
introductoryPricePaymentModeIOS?: PaymentModeIOS | null;
|
|
336
|
+
introductoryPriceSubscriptionPeriodIOS?: SubscriptionPeriodIOS | null;
|
|
337
|
+
isFamilyShareableIOS: boolean;
|
|
338
|
+
jsonRepresentationIOS: string;
|
|
339
|
+
platform: Platform;
|
|
340
|
+
price?: number | null;
|
|
341
|
+
subscriptionInfoIOS?: SubscriptionInfoIOS | null;
|
|
342
|
+
subscriptionPeriodNumberIOS?: string | null;
|
|
343
|
+
subscriptionPeriodUnitIOS?: SubscriptionPeriodIOS | null;
|
|
344
|
+
title: string;
|
|
345
|
+
type: ProductType;
|
|
346
|
+
typeIOS: ProductTypeIOS;
|
|
347
|
+
}
|
|
305
348
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
349
|
+
export enum ProductType {
|
|
350
|
+
InApp = 'IN_APP',
|
|
351
|
+
Subs = 'SUBS',
|
|
352
|
+
}
|
|
309
353
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
354
|
+
export enum ProductTypeIOS {
|
|
355
|
+
AutoRenewableSubscription = 'AUTO_RENEWABLE_SUBSCRIPTION',
|
|
356
|
+
Consumable = 'CONSUMABLE',
|
|
357
|
+
NonConsumable = 'NON_CONSUMABLE',
|
|
358
|
+
NonRenewingSubscription = 'NON_RENEWING_SUBSCRIPTION',
|
|
359
|
+
}
|
|
313
360
|
|
|
314
|
-
|
|
315
|
-
export type SubscriptionProductIOS = ProductSubscriptionIOS;
|
|
316
|
-
export type SubscriptionProductAndroid = ProductSubscriptionAndroid;
|
|
361
|
+
export type Purchase = PurchaseAndroid | PurchaseIOS;
|
|
317
362
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
363
|
+
export interface PurchaseAndroid extends PurchaseCommon {
|
|
364
|
+
autoRenewingAndroid?: boolean | null;
|
|
365
|
+
dataAndroid?: string | null;
|
|
366
|
+
developerPayloadAndroid?: string | null;
|
|
367
|
+
id: string;
|
|
368
|
+
ids?: string[] | null;
|
|
369
|
+
isAcknowledgedAndroid?: boolean | null;
|
|
370
|
+
isAutoRenewing: boolean;
|
|
371
|
+
obfuscatedAccountIdAndroid?: string | null;
|
|
372
|
+
obfuscatedProfileIdAndroid?: string | null;
|
|
373
|
+
packageNameAndroid?: string | null;
|
|
374
|
+
platform: Platform;
|
|
375
|
+
productId: string;
|
|
376
|
+
purchaseState: PurchaseState;
|
|
377
|
+
purchaseToken?: string | null;
|
|
378
|
+
quantity: number;
|
|
379
|
+
signatureAndroid?: string | null;
|
|
380
|
+
transactionDate: number;
|
|
381
|
+
}
|
|
321
382
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
* Both types appear in getAvailablePurchases until finishTransaction is called
|
|
335
|
-
*/
|
|
336
|
-
export type ProductPurchase =
|
|
337
|
-
| (PurchaseAndroid & AndroidPlatform)
|
|
338
|
-
| (PurchaseIOS & IosPlatform);
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Active subscription purchase
|
|
342
|
-
* Appears in getAvailablePurchases while subscription is active
|
|
343
|
-
*/
|
|
344
|
-
export type SubscriptionPurchase =
|
|
345
|
-
| (PurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})
|
|
346
|
-
| (PurchaseIOS & IosPlatform);
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Combined purchase type that includes all purchase types
|
|
350
|
-
* Used as return type for getAvailablePurchases
|
|
351
|
-
*/
|
|
352
|
-
export type Purchase =
|
|
353
|
-
| (PurchaseAndroid & AndroidPlatform)
|
|
354
|
-
| (PurchaseIOS & IosPlatform);
|
|
383
|
+
export interface PurchaseCommon {
|
|
384
|
+
id: string;
|
|
385
|
+
ids?: string[] | null;
|
|
386
|
+
isAutoRenewing: boolean;
|
|
387
|
+
platform: Platform;
|
|
388
|
+
productId: string;
|
|
389
|
+
purchaseState: PurchaseState;
|
|
390
|
+
/** Unified purchase token (iOS JWS, Android purchaseToken) */
|
|
391
|
+
purchaseToken?: string | null;
|
|
392
|
+
quantity: number;
|
|
393
|
+
transactionDate: number;
|
|
394
|
+
}
|
|
355
395
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
396
|
+
export interface PurchaseError {
|
|
397
|
+
code: ErrorCode;
|
|
398
|
+
message: string;
|
|
399
|
+
productId?: string | null;
|
|
400
|
+
}
|
|
359
401
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
402
|
+
export interface PurchaseIOS extends PurchaseCommon {
|
|
403
|
+
appAccountToken?: string | null;
|
|
404
|
+
appBundleIdIOS?: string | null;
|
|
405
|
+
countryCodeIOS?: string | null;
|
|
406
|
+
currencyCodeIOS?: string | null;
|
|
407
|
+
currencySymbolIOS?: string | null;
|
|
408
|
+
environmentIOS?: string | null;
|
|
409
|
+
expirationDateIOS?: number | null;
|
|
410
|
+
id: string;
|
|
411
|
+
ids?: string[] | null;
|
|
412
|
+
isAutoRenewing: boolean;
|
|
413
|
+
isUpgradedIOS?: boolean | null;
|
|
414
|
+
offerIOS?: PurchaseOfferIOS | null;
|
|
415
|
+
originalTransactionDateIOS?: number | null;
|
|
416
|
+
originalTransactionIdentifierIOS?: string | null;
|
|
417
|
+
ownershipTypeIOS?: string | null;
|
|
418
|
+
platform: Platform;
|
|
419
|
+
productId: string;
|
|
420
|
+
purchaseState: PurchaseState;
|
|
421
|
+
purchaseToken?: string | null;
|
|
422
|
+
quantity: number;
|
|
423
|
+
quantityIOS?: number | null;
|
|
424
|
+
reasonIOS?: string | null;
|
|
425
|
+
reasonStringRepresentationIOS?: string | null;
|
|
426
|
+
revocationDateIOS?: number | null;
|
|
427
|
+
revocationReasonIOS?: string | null;
|
|
428
|
+
storefrontCountryCodeIOS?: string | null;
|
|
429
|
+
subscriptionGroupIdIOS?: string | null;
|
|
430
|
+
transactionDate: number;
|
|
431
|
+
transactionReasonIOS?: string | null;
|
|
432
|
+
webOrderLineItemIdIOS?: string | null;
|
|
366
433
|
}
|
|
367
434
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
435
|
+
export interface PurchaseInput {
|
|
436
|
+
id: string;
|
|
437
|
+
ids?: string[] | null;
|
|
438
|
+
isAutoRenewing: boolean;
|
|
439
|
+
platform: Platform;
|
|
440
|
+
productId: string;
|
|
441
|
+
purchaseState: PurchaseState;
|
|
442
|
+
purchaseToken?: string | null;
|
|
443
|
+
quantity: number;
|
|
444
|
+
transactionDate: number;
|
|
375
445
|
}
|
|
376
446
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
readonly obfuscatedProfileIdAndroid?: string;
|
|
382
|
-
readonly isOfferPersonalized?: boolean;
|
|
447
|
+
export interface PurchaseOfferIOS {
|
|
448
|
+
id: string;
|
|
449
|
+
paymentMode: string;
|
|
450
|
+
type: string;
|
|
383
451
|
}
|
|
384
452
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
readonly subscriptionOffers: {
|
|
391
|
-
sku: string;
|
|
392
|
-
offerToken: string;
|
|
393
|
-
}[];
|
|
453
|
+
export interface PurchaseOptions {
|
|
454
|
+
/** Also emit results through the iOS event listeners */
|
|
455
|
+
alsoPublishToEventListenerIOS?: boolean | null;
|
|
456
|
+
/** Limit to currently active items on iOS */
|
|
457
|
+
onlyIncludeActiveItemsIOS?: boolean | null;
|
|
394
458
|
}
|
|
395
459
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
460
|
+
export interface PurchaseParams {
|
|
461
|
+
/** Per-platform purchase request props */
|
|
462
|
+
requestPurchase?: RequestPurchasePropsByPlatforms | null;
|
|
463
|
+
/** Per-platform subscription request props */
|
|
464
|
+
requestSubscription?: RequestSubscriptionPropsByPlatforms | null;
|
|
465
|
+
/** Explicit purchase type hint (defaults to in-app) */
|
|
466
|
+
type?: ProductQueryType | null;
|
|
400
467
|
}
|
|
401
468
|
|
|
402
|
-
export
|
|
403
|
-
|
|
404
|
-
|
|
469
|
+
export enum PurchaseState {
|
|
470
|
+
Deferred = 'DEFERRED',
|
|
471
|
+
Failed = 'FAILED',
|
|
472
|
+
Pending = 'PENDING',
|
|
473
|
+
Purchased = 'PURCHASED',
|
|
474
|
+
Restored = 'RESTORED',
|
|
475
|
+
Unknown = 'UNKNOWN',
|
|
405
476
|
}
|
|
406
477
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
478
|
+
export interface Query {
|
|
479
|
+
/** Get current StoreKit 2 entitlements (iOS 15+) */
|
|
480
|
+
currentEntitlementIOS: Promise<EntitlementIOS[]>;
|
|
481
|
+
/** Retrieve products or subscriptions from the store */
|
|
482
|
+
fetchProducts: Promise<FetchProductsResult>;
|
|
483
|
+
/** Get active subscriptions (filters by subscriptionIds when provided) */
|
|
484
|
+
getActiveSubscriptions: Promise<ActiveSubscription[]>;
|
|
485
|
+
/** Fetch the current app transaction (iOS 16+) */
|
|
486
|
+
getAppTransactionIOS?: Promise<AppTransaction | null>;
|
|
487
|
+
/** Get all available purchases for the current user */
|
|
488
|
+
getAvailablePurchases: Promise<Purchase[]>;
|
|
489
|
+
/** Retrieve all pending transactions in the StoreKit queue */
|
|
490
|
+
getPendingTransactionsIOS: Promise<PurchaseIOS[]>;
|
|
491
|
+
/** Get the currently promoted product (iOS 11+) */
|
|
492
|
+
getPromotedProductIOS?: Promise<ProductIOS | null>;
|
|
493
|
+
/** Get base64-encoded receipt data for validation */
|
|
494
|
+
getReceiptDataIOS: Promise<string>;
|
|
495
|
+
/** Get the current App Store storefront country code */
|
|
496
|
+
getStorefrontIOS: Promise<string>;
|
|
497
|
+
/** Get the transaction JWS (StoreKit 2) */
|
|
498
|
+
getTransactionJwsIOS: Promise<string>;
|
|
499
|
+
/** Check whether the user has active subscriptions */
|
|
500
|
+
hasActiveSubscriptions: Promise<boolean>;
|
|
501
|
+
/** Check introductory offer eligibility for specific products */
|
|
502
|
+
isEligibleForIntroOfferIOS: Promise<boolean>;
|
|
503
|
+
/** Verify a StoreKit 2 transaction signature */
|
|
504
|
+
isTransactionVerifiedIOS: Promise<boolean>;
|
|
505
|
+
/** Get the latest transaction for a product using StoreKit 2 */
|
|
506
|
+
latestTransactionIOS?: Promise<PurchaseIOS | null>;
|
|
507
|
+
/** Get StoreKit 2 subscription status details (iOS 15+) */
|
|
508
|
+
subscriptionStatusIOS: Promise<SubscriptionStatusIOS[]>;
|
|
509
|
+
}
|
|
410
510
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
511
|
+
export interface QuerycurrentEntitlementIOSArgs {
|
|
512
|
+
skus?: string[] | null;
|
|
513
|
+
}
|
|
414
514
|
|
|
415
|
-
export
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
E_USER_ERROR = 'E_USER_ERROR',
|
|
419
|
-
E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',
|
|
420
|
-
E_REMOTE_ERROR = 'E_REMOTE_ERROR',
|
|
421
|
-
E_NETWORK_ERROR = 'E_NETWORK_ERROR',
|
|
422
|
-
E_SERVICE_ERROR = 'E_SERVICE_ERROR',
|
|
423
|
-
E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',
|
|
424
|
-
E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',
|
|
425
|
-
E_NOT_PREPARED = 'E_NOT_PREPARED',
|
|
426
|
-
E_NOT_ENDED = 'E_NOT_ENDED',
|
|
427
|
-
E_ALREADY_OWNED = 'E_ALREADY_OWNED',
|
|
428
|
-
E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',
|
|
429
|
-
E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
430
|
-
E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',
|
|
431
|
-
E_INTERRUPTED = 'E_INTERRUPTED',
|
|
432
|
-
E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',
|
|
433
|
-
E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',
|
|
434
|
-
E_SYNC_ERROR = 'E_SYNC_ERROR',
|
|
435
|
-
E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',
|
|
436
|
-
E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',
|
|
437
|
-
E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',
|
|
438
|
-
E_PENDING = 'E_PENDING',
|
|
439
|
-
E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',
|
|
440
|
-
E_INIT_CONNECTION = 'E_INIT_CONNECTION',
|
|
441
|
-
E_SERVICE_DISCONNECTED = 'E_SERVICE_DISCONNECTED',
|
|
442
|
-
E_QUERY_PRODUCT = 'E_QUERY_PRODUCT',
|
|
443
|
-
E_SKU_NOT_FOUND = 'E_SKU_NOT_FOUND',
|
|
444
|
-
E_SKU_OFFER_MISMATCH = 'E_SKU_OFFER_MISMATCH',
|
|
445
|
-
E_ITEM_NOT_OWNED = 'E_ITEM_NOT_OWNED',
|
|
446
|
-
E_BILLING_UNAVAILABLE = 'E_BILLING_UNAVAILABLE',
|
|
447
|
-
E_FEATURE_NOT_SUPPORTED = 'E_FEATURE_NOT_SUPPORTED',
|
|
448
|
-
E_EMPTY_SKU_LIST = 'E_EMPTY_SKU_LIST',
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
export type PurchaseResult = {
|
|
452
|
-
responseCode?: number;
|
|
453
|
-
debugMessage?: string;
|
|
454
|
-
code?: string;
|
|
455
|
-
message?: string;
|
|
456
|
-
/**
|
|
457
|
-
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
458
|
-
*/
|
|
459
|
-
purchaseTokenAndroid?: string;
|
|
460
|
-
purchaseToken?: string;
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
// Additional iOS types
|
|
464
|
-
export type DiscountOffer = {
|
|
465
|
-
identifier: string;
|
|
466
|
-
keyIdentifier: string;
|
|
467
|
-
nonce: string;
|
|
468
|
-
signature: string;
|
|
469
|
-
timestamp: number;
|
|
470
|
-
};
|
|
515
|
+
export interface QueryfetchProductsArgs {
|
|
516
|
+
params: ProductRequest;
|
|
517
|
+
}
|
|
471
518
|
|
|
472
|
-
export
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
bundleId: string;
|
|
476
|
-
appVersion: string;
|
|
477
|
-
originalAppVersion: string;
|
|
478
|
-
originalPurchaseDate: number;
|
|
479
|
-
deviceVerification: string;
|
|
480
|
-
deviceVerificationNonce: string;
|
|
481
|
-
environment: string;
|
|
482
|
-
signedDate: number;
|
|
483
|
-
appId?: number;
|
|
484
|
-
appVersionId?: number;
|
|
485
|
-
preorderDate?: number;
|
|
486
|
-
};
|
|
519
|
+
export interface QuerygetActiveSubscriptionsArgs {
|
|
520
|
+
subscriptionIds?: string[] | null;
|
|
521
|
+
}
|
|
487
522
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
523
|
+
export interface QuerygetAvailablePurchasesArgs {
|
|
524
|
+
options?: PurchaseOptions | null;
|
|
525
|
+
}
|
|
491
526
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
*/
|
|
495
|
-
export interface PurchaseOptions {
|
|
496
|
-
/** Whether to also publish purchases to event listener */
|
|
497
|
-
alsoPublishToEventListenerIOS?: boolean;
|
|
498
|
-
/** Whether to only include active items (subscriptions that are still active) */
|
|
499
|
-
onlyIncludeActiveItemsIOS?: boolean;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Parameters for finishTransaction method
|
|
504
|
-
*/
|
|
505
|
-
export interface FinishTransactionParams {
|
|
506
|
-
/** The purchase to finish/consume */
|
|
507
|
-
purchase: Purchase;
|
|
508
|
-
/**
|
|
509
|
-
* Whether this is a consumable product that should be consumed.
|
|
510
|
-
* - Set to true for consumable products (e.g., "20 credits", "100 coins")
|
|
511
|
-
* - Set to false (or omit) for non-consumable products (e.g., "remove ads", "premium features")
|
|
512
|
-
* - Do NOT set to true for subscriptions - they are managed automatically
|
|
513
|
-
* Note: On iOS, this flag doesn't affect behavior as StoreKit handles this automatically.
|
|
514
|
-
* On Android, consumables must be consumed to allow repurchase.
|
|
515
|
-
*/
|
|
516
|
-
isConsumable?: boolean;
|
|
527
|
+
export interface QuerygetTransactionJwsIOSArgs {
|
|
528
|
+
transactionId: string;
|
|
517
529
|
}
|
|
518
530
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
531
|
+
export interface QueryhasActiveSubscriptionsArgs {
|
|
532
|
+
subscriptionIds?: string[] | null;
|
|
533
|
+
}
|
|
522
534
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
// Connection methods
|
|
546
|
-
/** Initialize connection to the store */
|
|
547
|
-
initConnection(): Promise<boolean>;
|
|
548
|
-
/** End connection to the store */
|
|
549
|
-
endConnection(): Promise<boolean>;
|
|
550
|
-
/** Sync purchases (iOS only) */
|
|
551
|
-
sync(): Promise<void>;
|
|
552
|
-
|
|
553
|
-
// Product methods
|
|
554
|
-
/**
|
|
555
|
-
* Fetch products from the store
|
|
556
|
-
* @param params.skus - Array of product SKUs to fetch
|
|
557
|
-
* @param params.type - Type of products: 'inapp' for regular products, 'subs' for subscriptions, 'all' to fetch both. Defaults to 'inapp'
|
|
558
|
-
*/
|
|
559
|
-
fetchProducts(params: {
|
|
560
|
-
skus: string[];
|
|
561
|
-
type?: 'inapp' | 'subs' | 'all'; // Defaults to 'inapp'
|
|
562
|
-
}): Promise<Product[] | SubscriptionProduct[]>;
|
|
563
|
-
|
|
564
|
-
// Purchase methods
|
|
565
|
-
/**
|
|
566
|
-
* Request a purchase for products or subscriptions
|
|
567
|
-
* @param params.request - Platform-specific purchase parameters
|
|
568
|
-
* @param params.type - Type of purchase: 'inapp' for products or 'subs' for subscriptions
|
|
569
|
-
*/
|
|
570
|
-
requestPurchase(params: {
|
|
571
|
-
request: RequestPurchaseProps | RequestSubscriptionProps;
|
|
572
|
-
type?: 'inapp' | 'subs'; // defaults to 'inapp'
|
|
573
|
-
}): Promise<Purchase | Purchase[] | void>;
|
|
574
|
-
/**
|
|
575
|
-
* Finish a transaction and consume if applicable.
|
|
576
|
-
* IMPORTANT: Every purchase must be finished to complete the transaction.
|
|
577
|
-
* - For consumables: Set isConsumable=true to allow repurchase
|
|
578
|
-
* - For non-consumables & subscriptions: Set isConsumable=false or omit
|
|
579
|
-
*/
|
|
580
|
-
finishTransaction(
|
|
581
|
-
params: FinishTransactionParams,
|
|
582
|
-
): Promise<PurchaseResult | boolean>;
|
|
583
|
-
|
|
584
|
-
// Purchase history methods
|
|
585
|
-
/**
|
|
586
|
-
* Get all available purchases for the current user.
|
|
587
|
-
* Returns:
|
|
588
|
-
* - Consumables that haven't been consumed (finished with isConsumable=true)
|
|
589
|
-
* - Non-consumables that haven't been finished
|
|
590
|
-
* - Active subscriptions
|
|
591
|
-
*/
|
|
592
|
-
getAvailablePurchases(options?: PurchaseOptions): Promise<Purchase[]>;
|
|
593
|
-
|
|
594
|
-
// Receipt validation
|
|
595
|
-
/** Validate a receipt (server-side validation recommended) */
|
|
596
|
-
validateReceipt(
|
|
597
|
-
sku: string,
|
|
598
|
-
androidOptions?: {
|
|
599
|
-
packageName: string;
|
|
600
|
-
productToken: string;
|
|
601
|
-
accessToken: string;
|
|
602
|
-
isSub?: boolean;
|
|
603
|
-
},
|
|
604
|
-
): Promise<ReceiptValidationResult>;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Purchase error type
|
|
609
|
-
*/
|
|
610
|
-
export interface PurchaseError {
|
|
611
|
-
/** Error code constant */
|
|
612
|
-
code: string;
|
|
613
|
-
/** Human-readable error message */
|
|
614
|
-
message: string;
|
|
615
|
-
/** Related product SKU */
|
|
616
|
-
productId?: string;
|
|
535
|
+
export interface QueryisEligibleForIntroOfferIOSArgs {
|
|
536
|
+
productIds: string[];
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export interface QueryisTransactionVerifiedIOSArgs {
|
|
540
|
+
transactionId: string;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export interface QuerylatestTransactionIOSArgs {
|
|
544
|
+
sku: string;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export interface QuerysubscriptionStatusIOSArgs {
|
|
548
|
+
skus?: string[] | null;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export interface ReceiptValidationAndroidOptions {
|
|
552
|
+
accessToken: string;
|
|
553
|
+
isSub?: boolean | null;
|
|
554
|
+
packageName: string;
|
|
555
|
+
productToken: string;
|
|
617
556
|
}
|
|
618
557
|
|
|
619
|
-
/**
|
|
620
|
-
* Validation options for receipt validation
|
|
621
|
-
*/
|
|
622
558
|
export interface ReceiptValidationProps {
|
|
559
|
+
/** Android-specific validation options */
|
|
560
|
+
androidOptions?: ReceiptValidationAndroidOptions | null;
|
|
623
561
|
/** Product SKU to validate */
|
|
624
562
|
sku: string;
|
|
625
|
-
/** Android-specific validation options */
|
|
626
|
-
androidOptions?: {
|
|
627
|
-
packageName: string;
|
|
628
|
-
productToken: string;
|
|
629
|
-
accessToken: string;
|
|
630
|
-
isSub?: boolean;
|
|
631
|
-
};
|
|
632
563
|
}
|
|
633
564
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
export interface ReceiptValidationResultIOS {
|
|
638
|
-
/** Whether the receipt is valid */
|
|
639
|
-
isValid: boolean;
|
|
640
|
-
/** Receipt data string */
|
|
641
|
-
receiptData: string;
|
|
642
|
-
/** JWS representation */
|
|
643
|
-
jwsRepresentation: string;
|
|
644
|
-
/** Latest transaction if available */
|
|
645
|
-
latestTransaction?: Purchase;
|
|
646
|
-
}
|
|
565
|
+
export type ReceiptValidationResult =
|
|
566
|
+
| ReceiptValidationResultAndroid
|
|
567
|
+
| ReceiptValidationResultIOS;
|
|
647
568
|
|
|
648
|
-
/**
|
|
649
|
-
* Android receipt validation result
|
|
650
|
-
*/
|
|
651
569
|
export interface ReceiptValidationResultAndroid {
|
|
652
570
|
autoRenewing: boolean;
|
|
653
571
|
betaProduct: boolean;
|
|
654
|
-
cancelDate
|
|
655
|
-
cancelReason
|
|
656
|
-
deferredDate
|
|
657
|
-
deferredSku
|
|
572
|
+
cancelDate?: number | null;
|
|
573
|
+
cancelReason?: string | null;
|
|
574
|
+
deferredDate?: number | null;
|
|
575
|
+
deferredSku?: number | null;
|
|
658
576
|
freeTrialEndDate: number;
|
|
659
577
|
gracePeriodEndDate: number;
|
|
660
578
|
parentProductId: string;
|
|
661
579
|
productId: string;
|
|
662
|
-
productType:
|
|
580
|
+
productType: string;
|
|
663
581
|
purchaseDate: number;
|
|
664
582
|
quantity: number;
|
|
665
583
|
receiptId: string;
|
|
@@ -669,35 +587,152 @@ export interface ReceiptValidationResultAndroid {
|
|
|
669
587
|
testTransaction: boolean;
|
|
670
588
|
}
|
|
671
589
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
590
|
+
export interface ReceiptValidationResultIOS {
|
|
591
|
+
/** Whether the receipt is valid */
|
|
592
|
+
isValid: boolean;
|
|
593
|
+
/** JWS representation */
|
|
594
|
+
jwsRepresentation: string;
|
|
595
|
+
/** Latest transaction if available */
|
|
596
|
+
latestTransaction?: Purchase | null;
|
|
597
|
+
/** Receipt data string */
|
|
598
|
+
receiptData: string;
|
|
599
|
+
}
|
|
678
600
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
|
|
695
|
-
/**
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
601
|
+
export interface RefundResultIOS {
|
|
602
|
+
message?: string | null;
|
|
603
|
+
status: string;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
export interface RenewalInfoIOS {
|
|
607
|
+
autoRenewPreference?: string | null;
|
|
608
|
+
jsonRepresentation?: string | null;
|
|
609
|
+
willAutoRenew: boolean;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export interface RequestPurchaseAndroidProps {
|
|
613
|
+
/** Personalized offer flag */
|
|
614
|
+
isOfferPersonalized?: boolean | null;
|
|
615
|
+
/** Obfuscated account ID */
|
|
616
|
+
obfuscatedAccountIdAndroid?: string | null;
|
|
617
|
+
/** Obfuscated profile ID */
|
|
618
|
+
obfuscatedProfileIdAndroid?: string | null;
|
|
619
|
+
/** List of product SKUs */
|
|
620
|
+
skus: string[];
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export interface RequestPurchaseIosProps {
|
|
624
|
+
/** Auto-finish transaction (dangerous) */
|
|
625
|
+
andDangerouslyFinishTransactionAutomatically?: boolean | null;
|
|
626
|
+
/** App account token for user tracking */
|
|
627
|
+
appAccountToken?: string | null;
|
|
628
|
+
/** Purchase quantity */
|
|
629
|
+
quantity?: number | null;
|
|
630
|
+
/** Product SKU */
|
|
631
|
+
sku: string;
|
|
632
|
+
/** Discount offer to apply */
|
|
633
|
+
withOffer?: DiscountOfferInputIOS | null;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
export interface RequestPurchaseProps {
|
|
637
|
+
/** Android-specific purchase parameters */
|
|
638
|
+
android?: RequestPurchaseAndroidProps | null;
|
|
639
|
+
/** iOS-specific purchase parameters */
|
|
640
|
+
ios?: RequestPurchaseIosProps | null;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export interface RequestPurchasePropsByPlatforms {
|
|
644
|
+
/** Android-specific purchase parameters */
|
|
645
|
+
android?: RequestPurchaseAndroidProps | null;
|
|
646
|
+
/** iOS-specific purchase parameters */
|
|
647
|
+
ios?: RequestPurchaseIosProps | null;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export interface RequestPurchaseResult {
|
|
651
|
+
purchase?: Purchase | null;
|
|
652
|
+
purchases?: Purchase[] | null;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export interface RequestSubscriptionAndroidProps {
|
|
656
|
+
/** Personalized offer flag */
|
|
657
|
+
isOfferPersonalized?: boolean | null;
|
|
658
|
+
/** Obfuscated account ID */
|
|
659
|
+
obfuscatedAccountIdAndroid?: string | null;
|
|
660
|
+
/** Obfuscated profile ID */
|
|
661
|
+
obfuscatedProfileIdAndroid?: string | null;
|
|
662
|
+
/** Purchase token for upgrades/downgrades */
|
|
663
|
+
purchaseTokenAndroid?: string | null;
|
|
664
|
+
/** Replacement mode for subscription changes */
|
|
665
|
+
replacementModeAndroid?: number | null;
|
|
666
|
+
/** List of subscription SKUs */
|
|
667
|
+
skus: string[];
|
|
668
|
+
/** Subscription offers */
|
|
669
|
+
subscriptionOffers?: AndroidSubscriptionOfferInput[] | null;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export interface RequestSubscriptionIosProps {
|
|
673
|
+
andDangerouslyFinishTransactionAutomatically?: boolean | null;
|
|
674
|
+
appAccountToken?: string | null;
|
|
675
|
+
quantity?: number | null;
|
|
676
|
+
sku: string;
|
|
677
|
+
withOffer?: DiscountOfferInputIOS | null;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export interface RequestSubscriptionPropsByPlatforms {
|
|
681
|
+
/** Android-specific subscription parameters */
|
|
682
|
+
android?: RequestSubscriptionAndroidProps | null;
|
|
683
|
+
/** iOS-specific subscription parameters */
|
|
684
|
+
ios?: RequestPurchaseIosProps | null;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export interface Subscription {
|
|
688
|
+
/** Fires when the App Store surfaces a promoted product (iOS only) */
|
|
689
|
+
promotedProductIOS: string;
|
|
690
|
+
/** Fires when a purchase fails or is cancelled */
|
|
691
|
+
purchaseError: PurchaseError;
|
|
692
|
+
/** Fires when a purchase completes successfully or a pending purchase resolves */
|
|
693
|
+
purchaseUpdated: Purchase;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export interface SubscriptionInfoIOS {
|
|
697
|
+
introductoryOffer?: SubscriptionOfferIOS | null;
|
|
698
|
+
promotionalOffers?: SubscriptionOfferIOS[] | null;
|
|
699
|
+
subscriptionGroupId: string;
|
|
700
|
+
subscriptionPeriod: SubscriptionPeriodValueIOS;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
export interface SubscriptionOfferIOS {
|
|
704
|
+
displayPrice: string;
|
|
705
|
+
id: string;
|
|
706
|
+
paymentMode: PaymentModeIOS;
|
|
707
|
+
period: SubscriptionPeriodValueIOS;
|
|
708
|
+
periodCount: number;
|
|
709
|
+
price: number;
|
|
710
|
+
type: SubscriptionOfferTypeIOS;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export enum SubscriptionOfferTypeIOS {
|
|
714
|
+
Introductory = 'INTRODUCTORY',
|
|
715
|
+
Promotional = 'PROMOTIONAL',
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
export enum SubscriptionPeriodIOS {
|
|
719
|
+
Day = 'DAY',
|
|
720
|
+
Empty = 'EMPTY',
|
|
721
|
+
Month = 'MONTH',
|
|
722
|
+
Week = 'WEEK',
|
|
723
|
+
Year = 'YEAR',
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export interface SubscriptionPeriodValueIOS {
|
|
727
|
+
unit: SubscriptionPeriodIOS;
|
|
728
|
+
value: number;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export interface SubscriptionStatusIOS {
|
|
732
|
+
renewalInfo?: RenewalInfoIOS | null;
|
|
733
|
+
state: string;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
export interface VoidResult {
|
|
737
|
+
success: boolean;
|
|
703
738
|
}
|