react-native-iap 14.4.45 → 14.4.47
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/NitroIap.podspec +2 -2
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +113 -3
- package/ios/HybridRnIap.swift +61 -2
- package/lib/module/hooks/useIAP.js +9 -1
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +68 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +5 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/errorMapping.js +32 -6
- package/lib/module/utils/errorMapping.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +5 -1
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +34 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +72 -26
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +109 -51
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +76 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JIapkitPurchaseState.hpp +80 -0
- package/nitrogen/generated/android/c++/JIapkitStore.hpp +59 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitAppleProps.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitGoogleProps.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitProps.hpp +70 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitResult.hpp +68 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderProps.hpp +70 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderResult.hpp +86 -0
- package/nitrogen/generated/android/c++/JPurchaseVerificationProvider.hpp +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapkitPurchaseState.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapkitStore.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitAppleProps.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitGoogleProps.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitProps.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitResult.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithProviderProps.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithProviderResult.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseVerificationProvider.kt +21 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +123 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +27 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +43 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroVerifyPurchaseWithProviderResult.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +45 -0
- package/nitrogen/generated/ios/swift/IapkitPurchaseState.swift +68 -0
- package/nitrogen/generated/ios/swift/IapkitStore.swift +40 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitAppleProps.swift +35 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitGoogleProps.swift +35 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitProps.swift +100 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitResult.swift +57 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderProps.swift +58 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderResult.swift +58 -0
- package/nitrogen/generated/ios/swift/PurchaseVerificationProvider.swift +40 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +8 -0
- package/nitrogen/generated/shared/c++/IapkitPurchaseState.hpp +104 -0
- package/nitrogen/generated/shared/c++/IapkitStore.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitAppleProps.hpp +75 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitGoogleProps.hpp +75 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitProps.hpp +89 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitResult.hpp +87 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderProps.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderResult.hpp +84 -0
- package/nitrogen/generated/shared/c++/PurchaseVerificationProvider.hpp +76 -0
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/src/hooks/useIAP.ts +32 -0
- package/src/index.ts +74 -5
- package/src/specs/RnIap.nitro.ts +101 -28
- package/src/types.ts +126 -57
- package/src/utils/errorMapping.ts +32 -4
package/src/types.ts
CHANGED
|
@@ -28,6 +28,11 @@ export interface ActiveSubscription {
|
|
|
28
28
|
renewalInfoIOS?: (RenewalInfoIOS | null);
|
|
29
29
|
transactionDate: number;
|
|
30
30
|
transactionId: string;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated iOS only - use daysUntilExpirationIOS instead.
|
|
33
|
+
* Whether the subscription will expire soon (within 7 days).
|
|
34
|
+
* Consider using daysUntilExpirationIOS for more precise control.
|
|
35
|
+
*/
|
|
31
36
|
willExpireSoon?: (boolean | null);
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -131,6 +136,9 @@ export enum ErrorCode {
|
|
|
131
136
|
NotPrepared = 'not-prepared',
|
|
132
137
|
Pending = 'pending',
|
|
133
138
|
PurchaseError = 'purchase-error',
|
|
139
|
+
PurchaseVerificationFailed = 'purchase-verification-failed',
|
|
140
|
+
PurchaseVerificationFinishFailed = 'purchase-verification-finish-failed',
|
|
141
|
+
PurchaseVerificationFinished = 'purchase-verification-finished',
|
|
134
142
|
QueryProduct = 'query-product',
|
|
135
143
|
ReceiptFailed = 'receipt-failed',
|
|
136
144
|
ReceiptFinished = 'receipt-finished',
|
|
@@ -172,6 +180,11 @@ export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product
|
|
|
172
180
|
|
|
173
181
|
export type IapPlatform = 'ios' | 'android';
|
|
174
182
|
|
|
183
|
+
/** Unified purchase states from IAPKit verification response. */
|
|
184
|
+
export type IapkitPurchaseState = 'entitled' | 'pending-acknowledgment' | 'pending' | 'canceled' | 'expired' | 'ready-to-consume' | 'consumed' | 'unknown' | 'inauthentic';
|
|
185
|
+
|
|
186
|
+
export type IapkitStore = 'apple' | 'google';
|
|
187
|
+
|
|
175
188
|
/** Connection initialization configuration */
|
|
176
189
|
export interface InitConnectionConfig {
|
|
177
190
|
/**
|
|
@@ -241,8 +254,15 @@ export interface Mutation {
|
|
|
241
254
|
showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;
|
|
242
255
|
/** Force a StoreKit sync for transactions (iOS 15+) */
|
|
243
256
|
syncIOS: Promise<boolean>;
|
|
244
|
-
/**
|
|
245
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Validate purchase receipts with the configured providers
|
|
259
|
+
* @deprecated Use verifyPurchase
|
|
260
|
+
*/
|
|
261
|
+
validateReceipt: Promise<VerifyPurchaseResult>;
|
|
262
|
+
/** Verify purchases with the configured providers */
|
|
263
|
+
verifyPurchase: Promise<VerifyPurchaseResult>;
|
|
264
|
+
/** Verify purchases with a specific provider (e.g., IAPKit) */
|
|
265
|
+
verifyPurchaseWithProvider: Promise<VerifyPurchaseWithProviderResult>;
|
|
246
266
|
}
|
|
247
267
|
|
|
248
268
|
|
|
@@ -282,7 +302,11 @@ export type MutationRequestPurchaseArgs =
|
|
|
282
302
|
};
|
|
283
303
|
|
|
284
304
|
|
|
285
|
-
export type MutationValidateReceiptArgs =
|
|
305
|
+
export type MutationValidateReceiptArgs = VerifyPurchaseProps;
|
|
306
|
+
|
|
307
|
+
export type MutationVerifyPurchaseArgs = VerifyPurchaseProps;
|
|
308
|
+
|
|
309
|
+
export type MutationVerifyPurchaseWithProviderArgs = VerifyPurchaseWithProviderProps;
|
|
286
310
|
|
|
287
311
|
export type PaymentModeIOS = 'empty' | 'free-trial' | 'pay-as-you-go' | 'pay-up-front';
|
|
288
312
|
|
|
@@ -330,11 +354,11 @@ export interface ProductCommon {
|
|
|
330
354
|
displayName?: (string | null);
|
|
331
355
|
displayPrice: string;
|
|
332
356
|
id: string;
|
|
333
|
-
platform:
|
|
357
|
+
platform: 'android' | 'ios';
|
|
334
358
|
price?: (number | null);
|
|
335
359
|
title: string;
|
|
336
|
-
type:
|
|
337
|
-
}
|
|
360
|
+
type: 'in-app' | 'subs';
|
|
361
|
+
}
|
|
338
362
|
|
|
339
363
|
export interface ProductIOS extends ProductCommon {
|
|
340
364
|
currency: string;
|
|
@@ -522,6 +546,8 @@ export interface PurchaseOptions {
|
|
|
522
546
|
|
|
523
547
|
export type PurchaseState = 'pending' | 'purchased' | 'failed' | 'restored' | 'deferred' | 'unknown';
|
|
524
548
|
|
|
549
|
+
export type PurchaseVerificationProvider = 'iapkit';
|
|
550
|
+
|
|
525
551
|
export interface Query {
|
|
526
552
|
/** Check if external purchase notice sheet can be presented (iOS 18.2+) */
|
|
527
553
|
canPresentExternalPurchaseNoticeIOS: Promise<boolean>;
|
|
@@ -560,8 +586,11 @@ export interface Query {
|
|
|
560
586
|
latestTransactionIOS?: Promise<(PurchaseIOS | null)>;
|
|
561
587
|
/** Get StoreKit 2 subscription status details (iOS 15+) */
|
|
562
588
|
subscriptionStatusIOS: Promise<SubscriptionStatusIOS[]>;
|
|
563
|
-
/**
|
|
564
|
-
|
|
589
|
+
/**
|
|
590
|
+
* Validate a receipt for a specific product
|
|
591
|
+
* @deprecated Use verifyPurchase
|
|
592
|
+
*/
|
|
593
|
+
validateReceiptIOS: Promise<VerifyPurchaseResultIOS>;
|
|
565
594
|
}
|
|
566
595
|
|
|
567
596
|
|
|
@@ -586,55 +615,7 @@ export type QueryLatestTransactionIosArgs = string;
|
|
|
586
615
|
|
|
587
616
|
export type QuerySubscriptionStatusIosArgs = string;
|
|
588
617
|
|
|
589
|
-
export type QueryValidateReceiptIosArgs =
|
|
590
|
-
|
|
591
|
-
export interface ReceiptValidationAndroidOptions {
|
|
592
|
-
accessToken: string;
|
|
593
|
-
isSub?: (boolean | null);
|
|
594
|
-
packageName: string;
|
|
595
|
-
productToken: string;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
export interface ReceiptValidationProps {
|
|
599
|
-
/** Android-specific validation options */
|
|
600
|
-
androidOptions?: (ReceiptValidationAndroidOptions | null);
|
|
601
|
-
/** Product SKU to validate */
|
|
602
|
-
sku: string;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
export type ReceiptValidationResult = ReceiptValidationResultAndroid | ReceiptValidationResultIOS;
|
|
606
|
-
|
|
607
|
-
export interface ReceiptValidationResultAndroid {
|
|
608
|
-
autoRenewing: boolean;
|
|
609
|
-
betaProduct: boolean;
|
|
610
|
-
cancelDate?: (number | null);
|
|
611
|
-
cancelReason?: (string | null);
|
|
612
|
-
deferredDate?: (number | null);
|
|
613
|
-
deferredSku?: (string | null);
|
|
614
|
-
freeTrialEndDate: number;
|
|
615
|
-
gracePeriodEndDate: number;
|
|
616
|
-
parentProductId: string;
|
|
617
|
-
productId: string;
|
|
618
|
-
productType: string;
|
|
619
|
-
purchaseDate: number;
|
|
620
|
-
quantity: number;
|
|
621
|
-
receiptId: string;
|
|
622
|
-
renewalDate: number;
|
|
623
|
-
term: string;
|
|
624
|
-
termSku: string;
|
|
625
|
-
testTransaction: boolean;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
export interface ReceiptValidationResultIOS {
|
|
629
|
-
/** Whether the receipt is valid */
|
|
630
|
-
isValid: boolean;
|
|
631
|
-
/** JWS representation */
|
|
632
|
-
jwsRepresentation: string;
|
|
633
|
-
/** Latest transaction if available */
|
|
634
|
-
latestTransaction?: (Purchase | null);
|
|
635
|
-
/** Receipt data string */
|
|
636
|
-
receiptData: string;
|
|
637
|
-
}
|
|
618
|
+
export type QueryValidateReceiptIosArgs = VerifyPurchaseProps;
|
|
638
619
|
|
|
639
620
|
export interface RefundResultIOS {
|
|
640
621
|
message?: (string | null);
|
|
@@ -769,6 +750,33 @@ export interface RequestSubscriptionPropsByPlatforms {
|
|
|
769
750
|
ios?: (RequestSubscriptionIosProps | null);
|
|
770
751
|
}
|
|
771
752
|
|
|
753
|
+
export interface RequestVerifyPurchaseWithIapkitAppleProps {
|
|
754
|
+
/** The JWS token returned with the purchase response. */
|
|
755
|
+
jws: string;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
export interface RequestVerifyPurchaseWithIapkitGoogleProps {
|
|
759
|
+
/** The token provided to the user's device when the product or subscription was purchased. */
|
|
760
|
+
purchaseToken: string;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
export interface RequestVerifyPurchaseWithIapkitProps {
|
|
764
|
+
/** API key used for the Authorization header (Bearer {apiKey}). */
|
|
765
|
+
apiKey?: (string | null);
|
|
766
|
+
/** Apple verification parameters. */
|
|
767
|
+
apple?: (RequestVerifyPurchaseWithIapkitAppleProps | null);
|
|
768
|
+
/** Google verification parameters. */
|
|
769
|
+
google?: (RequestVerifyPurchaseWithIapkitGoogleProps | null);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
export interface RequestVerifyPurchaseWithIapkitResult {
|
|
773
|
+
/** Whether the purchase is valid (not falsified). */
|
|
774
|
+
isValid: boolean;
|
|
775
|
+
/** The current state of the purchase. */
|
|
776
|
+
state: IapkitPurchaseState;
|
|
777
|
+
store: IapkitStore;
|
|
778
|
+
}
|
|
779
|
+
|
|
772
780
|
export interface Subscription {
|
|
773
781
|
/** Fires when the App Store surfaces a promoted product (iOS only) */
|
|
774
782
|
promotedProductIOS: string;
|
|
@@ -826,6 +834,65 @@ export interface UserChoiceBillingDetails {
|
|
|
826
834
|
products: string[];
|
|
827
835
|
}
|
|
828
836
|
|
|
837
|
+
export interface VerifyPurchaseAndroidOptions {
|
|
838
|
+
accessToken: string;
|
|
839
|
+
isSub?: (boolean | null);
|
|
840
|
+
packageName: string;
|
|
841
|
+
productToken: string;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
export interface VerifyPurchaseProps {
|
|
845
|
+
/** Android-specific validation options */
|
|
846
|
+
androidOptions?: (VerifyPurchaseAndroidOptions | null);
|
|
847
|
+
/** Product SKU to validate */
|
|
848
|
+
sku: string;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
export type VerifyPurchaseResult = VerifyPurchaseResultAndroid | VerifyPurchaseResultIOS;
|
|
852
|
+
|
|
853
|
+
export interface VerifyPurchaseResultAndroid {
|
|
854
|
+
autoRenewing: boolean;
|
|
855
|
+
betaProduct: boolean;
|
|
856
|
+
cancelDate?: (number | null);
|
|
857
|
+
cancelReason?: (string | null);
|
|
858
|
+
deferredDate?: (number | null);
|
|
859
|
+
deferredSku?: (string | null);
|
|
860
|
+
freeTrialEndDate: number;
|
|
861
|
+
gracePeriodEndDate: number;
|
|
862
|
+
parentProductId: string;
|
|
863
|
+
productId: string;
|
|
864
|
+
productType: string;
|
|
865
|
+
purchaseDate: number;
|
|
866
|
+
quantity: number;
|
|
867
|
+
receiptId: string;
|
|
868
|
+
renewalDate: number;
|
|
869
|
+
term: string;
|
|
870
|
+
termSku: string;
|
|
871
|
+
testTransaction: boolean;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
export interface VerifyPurchaseResultIOS {
|
|
875
|
+
/** Whether the receipt is valid */
|
|
876
|
+
isValid: boolean;
|
|
877
|
+
/** JWS representation */
|
|
878
|
+
jwsRepresentation: string;
|
|
879
|
+
/** Latest transaction if available */
|
|
880
|
+
latestTransaction?: (Purchase | null);
|
|
881
|
+
/** Receipt data string */
|
|
882
|
+
receiptData: string;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export interface VerifyPurchaseWithProviderProps {
|
|
886
|
+
iapkit?: (RequestVerifyPurchaseWithIapkitProps | null);
|
|
887
|
+
provider: PurchaseVerificationProvider;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
export interface VerifyPurchaseWithProviderResult {
|
|
891
|
+
/** IAPKit verification results (can include Apple and Google entries) */
|
|
892
|
+
iapkit: RequestVerifyPurchaseWithIapkitResult[];
|
|
893
|
+
provider: PurchaseVerificationProvider;
|
|
894
|
+
}
|
|
895
|
+
|
|
829
896
|
export type VoidResult = void;
|
|
830
897
|
|
|
831
898
|
// -- Query helper types (auto-generated)
|
|
@@ -884,6 +951,8 @@ export type MutationArgsMap = {
|
|
|
884
951
|
showManageSubscriptionsIOS: never;
|
|
885
952
|
syncIOS: never;
|
|
886
953
|
validateReceipt: MutationValidateReceiptArgs;
|
|
954
|
+
verifyPurchase: MutationVerifyPurchaseArgs;
|
|
955
|
+
verifyPurchaseWithProvider: MutationVerifyPurchaseWithProviderArgs;
|
|
887
956
|
};
|
|
888
957
|
|
|
889
958
|
export type MutationField<K extends keyof Mutation> =
|
|
@@ -11,6 +11,18 @@ const ERROR_CODE_ALIASES: Record<string, ErrorCode> = {
|
|
|
11
11
|
USER_CANCELED: ErrorCode.UserCancelled,
|
|
12
12
|
E_USER_CANCELLED: ErrorCode.UserCancelled,
|
|
13
13
|
USER_CANCELLED: ErrorCode.UserCancelled,
|
|
14
|
+
// Deprecated error code mappings (map old Receipt* codes to new PurchaseVerification* codes)
|
|
15
|
+
// These ensure backwards compatibility while preferring new codes
|
|
16
|
+
RECEIPT_FAILED: ErrorCode.PurchaseVerificationFailed,
|
|
17
|
+
E_RECEIPT_FAILED: ErrorCode.PurchaseVerificationFailed,
|
|
18
|
+
RECEIPT_FINISHED: ErrorCode.PurchaseVerificationFinished,
|
|
19
|
+
E_RECEIPT_FINISHED: ErrorCode.PurchaseVerificationFinished,
|
|
20
|
+
RECEIPT_FINISHED_FAILED: ErrorCode.PurchaseVerificationFinishFailed,
|
|
21
|
+
E_RECEIPT_FINISHED_FAILED: ErrorCode.PurchaseVerificationFinishFailed,
|
|
22
|
+
// Also handle kebab-case versions
|
|
23
|
+
'receipt-failed': ErrorCode.PurchaseVerificationFailed,
|
|
24
|
+
'receipt-finished': ErrorCode.PurchaseVerificationFinished,
|
|
25
|
+
'receipt-finished-failed': ErrorCode.PurchaseVerificationFinishFailed,
|
|
14
26
|
};
|
|
15
27
|
|
|
16
28
|
const toKebabCase = (str: string): string => {
|
|
@@ -86,6 +98,11 @@ const COMMON_ERROR_CODE_MAP: Record<ErrorCode, string> = {
|
|
|
86
98
|
[ErrorCode.BillingUnavailable]: ErrorCode.BillingUnavailable,
|
|
87
99
|
[ErrorCode.FeatureNotSupported]: ErrorCode.FeatureNotSupported,
|
|
88
100
|
[ErrorCode.EmptySkuList]: ErrorCode.EmptySkuList,
|
|
101
|
+
[ErrorCode.PurchaseVerificationFailed]: ErrorCode.PurchaseVerificationFailed,
|
|
102
|
+
[ErrorCode.PurchaseVerificationFinishFailed]:
|
|
103
|
+
ErrorCode.PurchaseVerificationFinishFailed,
|
|
104
|
+
[ErrorCode.PurchaseVerificationFinished]:
|
|
105
|
+
ErrorCode.PurchaseVerificationFinished,
|
|
89
106
|
};
|
|
90
107
|
|
|
91
108
|
export const ErrorCodeMapping = {
|
|
@@ -293,8 +310,6 @@ export function getUserFriendlyErrorMessage(error: ErrorLike): string {
|
|
|
293
310
|
return 'Purchase cancelled';
|
|
294
311
|
case ErrorCode.NetworkError:
|
|
295
312
|
return 'Network connection error. Please check your internet connection and try again.';
|
|
296
|
-
case ErrorCode.ReceiptFinished:
|
|
297
|
-
return 'Receipt already finished';
|
|
298
313
|
case ErrorCode.ServiceDisconnected:
|
|
299
314
|
return 'Billing service disconnected. Please try again.';
|
|
300
315
|
case ErrorCode.BillingUnavailable:
|
|
@@ -320,7 +335,14 @@ export function getUserFriendlyErrorMessage(error: ErrorLike): string {
|
|
|
320
335
|
case ErrorCode.TransactionValidationFailed:
|
|
321
336
|
return 'Transaction could not be verified';
|
|
322
337
|
case ErrorCode.ReceiptFailed:
|
|
323
|
-
|
|
338
|
+
case ErrorCode.PurchaseVerificationFailed:
|
|
339
|
+
return 'Purchase verification failed';
|
|
340
|
+
case ErrorCode.ReceiptFinished:
|
|
341
|
+
case ErrorCode.PurchaseVerificationFinished:
|
|
342
|
+
return 'Purchase verification completed';
|
|
343
|
+
case ErrorCode.ReceiptFinishedFailed:
|
|
344
|
+
case ErrorCode.PurchaseVerificationFinishFailed:
|
|
345
|
+
return 'Failed to complete purchase verification';
|
|
324
346
|
case ErrorCode.EmptySkuList:
|
|
325
347
|
return 'No product IDs provided';
|
|
326
348
|
case ErrorCode.InitConnection:
|
|
@@ -345,12 +367,18 @@ export const normalizeErrorCodeFromNative = (code: unknown): ErrorCode => {
|
|
|
345
367
|
if (typeof code === 'string') {
|
|
346
368
|
const upper = code.toUpperCase();
|
|
347
369
|
|
|
348
|
-
// Check aliases first
|
|
370
|
+
// Check aliases first (includes deprecated Receipt* -> PurchaseVerification* mappings)
|
|
349
371
|
const alias = ERROR_CODE_ALIASES[upper];
|
|
350
372
|
if (alias) {
|
|
351
373
|
return alias;
|
|
352
374
|
}
|
|
353
375
|
|
|
376
|
+
// Also check lowercase alias for kebab-case codes
|
|
377
|
+
const lowerAlias = ERROR_CODE_ALIASES[code];
|
|
378
|
+
if (lowerAlias) {
|
|
379
|
+
return lowerAlias;
|
|
380
|
+
}
|
|
381
|
+
|
|
354
382
|
// Handle various user cancelled formats
|
|
355
383
|
if (
|
|
356
384
|
upper === 'USER_CANCELLED' ||
|