react-native-iap 13.0.4 → 14.0.0-rc.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/NitroIap.podspec +33 -0
- package/README.md +163 -51
- package/android/CMakeLists.txt +32 -0
- package/android/build.gradle +107 -138
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -13
- package/android/src/main/AndroidManifest.xml +1 -4
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +843 -0
- package/android/src/main/java/com/margelo/nitro/iap/NitroIapPackage.java +33 -0
- package/android/src/main/java/com/margelo/nitro/iap/Types.kt +173 -0
- package/ios/Bridge.h +8 -0
- package/ios/ErrorUtils.swift +153 -0
- package/ios/HybridRnIap.swift +1326 -0
- package/ios/ProductStore.swift +33 -0
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/lib/module/helpers/subscription.js +56 -0
- package/lib/module/helpers/subscription.js.map +1 -0
- package/lib/module/hooks/useIAP.js +175 -123
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +1015 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/specs/RnIap.nitro.js +4 -0
- package/lib/{commonjs/modules/common.js.map → module/specs/RnIap.nitro.js.map} +1 -1
- package/lib/module/types.js +187 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/error.js +80 -0
- package/lib/module/utils/error.js.map +1 -0
- package/lib/module/utils/type-bridge.js +202 -0
- package/lib/module/utils/type-bridge.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/plugin/src/withIAP.d.ts +2 -7
- package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
- package/lib/typescript/scripts/check-nitro-versions.d.ts +3 -0
- package/lib/typescript/scripts/check-nitro-versions.d.ts.map +1 -0
- package/lib/typescript/src/helpers/subscription.d.ts +14 -0
- package/lib/typescript/src/helpers/subscription.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useIAP.d.ts +42 -26
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +356 -8
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +404 -0
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +544 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utils/error.d.ts +30 -0
- package/lib/typescript/src/utils/error.d.ts.map +1 -0
- package/lib/typescript/src/utils/type-bridge.d.ts +40 -0
- package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/NitroIap+autolinking.cmake +80 -0
- package/nitrogen/generated/android/NitroIap+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroIapOnLoad.cpp +50 -0
- package/nitrogen/generated/android/NitroIapOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JFunc_void_NitroProduct.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_NitroPurchase.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_NitroPurchaseResult.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +577 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +93 -0
- package/nitrogen/generated/android/c++/JNitroAndroidReceiptValidationOptions.hpp +66 -0
- package/nitrogen/generated/android/c++/JNitroAvailablePurchasesAndroidOptions.hpp +54 -0
- package/nitrogen/generated/android/c++/JNitroAvailablePurchasesIosOptions.hpp +65 -0
- package/nitrogen/generated/android/c++/JNitroAvailablePurchasesOptions.hpp +62 -0
- package/nitrogen/generated/android/c++/JNitroFinishTransactionAndroidParams.hpp +58 -0
- package/nitrogen/generated/android/c++/JNitroFinishTransactionIosParams.hpp +53 -0
- package/nitrogen/generated/android/c++/JNitroFinishTransactionParams.hpp +62 -0
- package/nitrogen/generated/android/c++/JNitroProduct.hpp +154 -0
- package/nitrogen/generated/android/c++/JNitroPurchase.hpp +122 -0
- package/nitrogen/generated/android/c++/JNitroPurchaseRequest.hpp +66 -0
- package/nitrogen/generated/android/c++/JNitroPurchaseResult.hpp +70 -0
- package/nitrogen/generated/android/c++/JNitroReceiptValidationParams.hpp +60 -0
- package/nitrogen/generated/android/c++/JNitroReceiptValidationResultAndroid.hpp +122 -0
- package/nitrogen/generated/android/c++/JNitroReceiptValidationResultIOS.hpp +68 -0
- package/nitrogen/generated/android/c++/JNitroRequestPurchaseAndroid.hpp +115 -0
- package/nitrogen/generated/android/c++/JNitroRequestPurchaseIos.hpp +84 -0
- package/nitrogen/generated/android/c++/JNitroSubscriptionOffer.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroSubscriptionRenewalInfo.hpp +74 -0
- package/nitrogen/generated/android/c++/JNitroSubscriptionStatus.hpp +64 -0
- package/nitrogen/generated/android/c++/JVariant_Boolean_NitroPurchaseResult.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_Boolean_NitroPurchaseResult.hpp +71 -0
- package/nitrogen/generated/android/c++/JVariant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.hpp +75 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroProduct.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroPurchase.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroPurchaseResult.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +198 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAndroidReceiptValidationOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesAndroidOptions.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesIosOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesOptions.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroFinishTransactionAndroidParams.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroFinishTransactionIosParams.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroFinishTransactionParams.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroIapOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroProduct.kt +104 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseRequest.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseResult.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationParams.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationResultAndroid.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationResultIOS.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRequestPurchaseAndroid.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRequestPurchaseIos.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroSubscriptionOffer.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroSubscriptionRenewalInfo.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroSubscriptionStatus.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_Boolean_NitroPurchaseResult.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.kt +42 -0
- package/nitrogen/generated/ios/NitroIap+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +152 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +1061 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +107 -0
- package/nitrogen/generated/ios/NitroIapAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroIapAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +355 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroProduct.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroPurchase.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroPurchaseResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_NitroProduct_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_NitroPurchase_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__vector_NitroSubscriptionStatus__.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_NitroReceiptValidationResultIOS__NitroReceiptValidationResultAndroid_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_bool__NitroPurchaseResult_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_NitroProduct_.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_NitroPurchase_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +78 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +750 -0
- package/nitrogen/generated/ios/swift/NitroAndroidReceiptValidationOptions.swift +80 -0
- package/nitrogen/generated/ios/swift/NitroAvailablePurchasesAndroidOptions.swift +54 -0
- package/nitrogen/generated/ios/swift/NitroAvailablePurchasesIosOptions.swift +116 -0
- package/nitrogen/generated/ios/swift/NitroAvailablePurchasesOptions.swift +84 -0
- package/nitrogen/generated/ios/swift/NitroFinishTransactionAndroidParams.swift +58 -0
- package/nitrogen/generated/ios/swift/NitroFinishTransactionIosParams.swift +35 -0
- package/nitrogen/generated/ios/swift/NitroFinishTransactionParams.swift +84 -0
- package/nitrogen/generated/ios/swift/NitroProduct.swift +653 -0
- package/nitrogen/generated/ios/swift/NitroPurchase.swift +453 -0
- package/nitrogen/generated/ios/swift/NitroPurchaseRequest.swift +84 -0
- package/nitrogen/generated/ios/swift/NitroPurchaseResult.swift +117 -0
- package/nitrogen/generated/ios/swift/NitroReceiptValidationParams.swift +65 -0
- package/nitrogen/generated/ios/swift/NitroReceiptValidationResultAndroid.swift +258 -0
- package/nitrogen/generated/ios/swift/NitroReceiptValidationResultIOS.swift +87 -0
- package/nitrogen/generated/ios/swift/NitroRequestPurchaseAndroid.swift +225 -0
- package/nitrogen/generated/ios/swift/NitroRequestPurchaseIos.swift +161 -0
- package/nitrogen/generated/ios/swift/NitroSubscriptionOffer.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroSubscriptionRenewalInfo.swift +152 -0
- package/nitrogen/generated/ios/swift/NitroSubscriptionStatus.swift +76 -0
- package/nitrogen/generated/ios/swift/Variant_Bool_NitroPurchaseResult.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.swift +18 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +50 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +125 -0
- package/nitrogen/generated/shared/c++/NitroAndroidReceiptValidationOptions.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroAvailablePurchasesAndroidOptions.hpp +68 -0
- package/nitrogen/generated/shared/c++/NitroAvailablePurchasesIosOptions.hpp +79 -0
- package/nitrogen/generated/shared/c++/NitroAvailablePurchasesOptions.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroFinishTransactionAndroidParams.hpp +72 -0
- package/nitrogen/generated/shared/c++/NitroFinishTransactionIosParams.hpp +67 -0
- package/nitrogen/generated/shared/c++/NitroFinishTransactionParams.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroProduct.hpp +168 -0
- package/nitrogen/generated/shared/c++/NitroPurchase.hpp +136 -0
- package/nitrogen/generated/shared/c++/NitroPurchaseRequest.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroPurchaseResult.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroReceiptValidationParams.hpp +74 -0
- package/nitrogen/generated/shared/c++/NitroReceiptValidationResultAndroid.hpp +136 -0
- package/nitrogen/generated/shared/c++/NitroReceiptValidationResultIOS.hpp +82 -0
- package/nitrogen/generated/shared/c++/NitroRequestPurchaseAndroid.hpp +95 -0
- package/nitrogen/generated/shared/c++/NitroRequestPurchaseIos.hpp +85 -0
- package/nitrogen/generated/shared/c++/NitroSubscriptionOffer.hpp +71 -0
- package/nitrogen/generated/shared/c++/NitroSubscriptionRenewalInfo.hpp +88 -0
- package/nitrogen/generated/shared/c++/NitroSubscriptionStatus.hpp +78 -0
- package/package.json +145 -104
- package/plugin/build/src/withIAP.d.ts +3 -0
- package/plugin/build/src/withIAP.js +81 -0
- package/plugin/build/tsconfig.tsbuildinfo +1 -0
- package/plugin/build/withIAP.d.ts +2 -7
- package/plugin/build/withIAP.js +62 -51
- package/plugin/src/withIAP.ts +119 -0
- package/plugin/tsconfig.json +18 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
- package/src/helpers/subscription.ts +65 -0
- package/src/hooks/useIAP.ts +361 -222
- package/src/index.ts +1194 -9
- package/src/specs/RnIap.nitro.ts +501 -0
- package/src/types.ts +680 -0
- package/src/utils/error.ts +97 -0
- package/src/utils/type-bridge.ts +209 -0
- package/LICENSE +0 -21
- package/RNIap.podspec +0 -36
- package/android/src/amazon/AndroidManifest.xml +0 -14
- package/android/src/amazon/java/com/dooboolab/rniap/EventSender.kt +0 -10
- package/android/src/amazon/java/com/dooboolab/rniap/PurchasingServiceProxy.kt +0 -29
- package/android/src/amazon/java/com/dooboolab/rniap/PurchasingServiceProxyAmazonImpl.kt +0 -31
- package/android/src/amazon/java/com/dooboolab/rniap/RNIapActivityListener.kt +0 -55
- package/android/src/amazon/java/com/dooboolab/rniap/RNIapAmazonListener.kt +0 -325
- package/android/src/amazon/java/com/dooboolab/rniap/RNIapAmazonModule.kt +0 -244
- package/android/src/amazon/java/com/dooboolab/rniap/RNIapPackage.kt +0 -17
- package/android/src/amazon/java/com/dooboolab/rniap/modifysubscription/RNIapAmazonModifySubscriptionListener.kt +0 -88
- package/android/src/amazon/java/com/dooboolab/rniap/utils/Extensions.kt +0 -22
- package/android/src/main/java/com/dooboolab/rniap/PromiseUtils.kt +0 -62
- package/android/src/main/java/com/dooboolab/rniap/PromiseUtlis.kt +0 -43
- package/android/src/play/java/com/dooboolab/rniap/PlayUtils.kt +0 -114
- package/android/src/play/java/com/dooboolab/rniap/RNIapActivityListener.kt +0 -15
- package/android/src/play/java/com/dooboolab/rniap/RNIapModule.kt +0 -911
- package/android/src/play/java/com/dooboolab/rniap/RNIapPackage.kt +0 -17
- package/android/src/testAmazon/java/com/dooboolab/rniap/RNIapAmazonModuleTest.kt +0 -170
- package/app.plugin.js +0 -1
- package/ios/IapSerializationUtils.swift +0 -290
- package/ios/IapTypes.swift +0 -56
- package/ios/IapUtils.swift +0 -40
- package/ios/LatestPromiseKeeper.swift +0 -52
- package/ios/RNIapIos-Bridging-Header.h +0 -2
- package/ios/RNIapIos.m +0 -69
- package/ios/RNIapIos.swift +0 -868
- package/ios/RNIapIos.xcodeproj/project.pbxproj +0 -289
- package/ios/RNIapIosSk2.m +0 -126
- package/ios/RNIapIosSk2.swift +0 -1413
- package/ios/ThreadSafe.swift +0 -18
- package/lib/commonjs/eventEmitter.js +0 -195
- package/lib/commonjs/eventEmitter.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -17
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/useIAP.js +0 -203
- package/lib/commonjs/hooks/useIAP.js.map +0 -1
- package/lib/commonjs/hooks/withIAPContext.js +0 -95
- package/lib/commonjs/hooks/withIAPContext.js.map +0 -1
- package/lib/commonjs/iap.js +0 -836
- package/lib/commonjs/iap.js.map +0 -1
- package/lib/commonjs/index.js +0 -105
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/internal/enhancedFetch.js +0 -26
- package/lib/commonjs/internal/enhancedFetch.js.map +0 -1
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js +0 -50
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js.map +0 -1
- package/lib/commonjs/internal/index.js +0 -39
- package/lib/commonjs/internal/index.js.map +0 -1
- package/lib/commonjs/internal/platform.js +0 -119
- package/lib/commonjs/internal/platform.js.map +0 -1
- package/lib/commonjs/modules/amazon.js +0 -50
- package/lib/commonjs/modules/amazon.js.map +0 -1
- package/lib/commonjs/modules/android.js +0 -92
- package/lib/commonjs/modules/android.js.map +0 -1
- package/lib/commonjs/modules/common.js +0 -2
- package/lib/commonjs/modules/index.js +0 -50
- package/lib/commonjs/modules/index.js.map +0 -1
- package/lib/commonjs/modules/ios.js +0 -160
- package/lib/commonjs/modules/ios.js.map +0 -1
- package/lib/commonjs/modules/iosSk2.js +0 -113
- package/lib/commonjs/modules/iosSk2.js.map +0 -1
- package/lib/commonjs/purchaseError.js +0 -170
- package/lib/commonjs/purchaseError.js.map +0 -1
- package/lib/commonjs/types/amazon.js +0 -2
- package/lib/commonjs/types/amazon.js.map +0 -1
- package/lib/commonjs/types/android.js +0 -67
- package/lib/commonjs/types/android.js.map +0 -1
- package/lib/commonjs/types/apple.js +0 -24
- package/lib/commonjs/types/apple.js.map +0 -1
- package/lib/commonjs/types/appleSk2.js +0 -137
- package/lib/commonjs/types/appleSk2.js.map +0 -1
- package/lib/commonjs/types/index.js +0 -67
- package/lib/commonjs/types/index.js.map +0 -1
- package/lib/commonjs/utils/errorMapping.js +0 -83
- package/lib/commonjs/utils/errorMapping.js.map +0 -1
- package/lib/commonjs/utils/typeGuards.js +0 -74
- package/lib/commonjs/utils/typeGuards.js.map +0 -1
- package/lib/module/eventEmitter.js +0 -185
- package/lib/module/eventEmitter.js.map +0 -1
- package/lib/module/hooks/index.js +0 -2
- package/lib/module/hooks/index.js.map +0 -1
- package/lib/module/hooks/withIAPContext.js +0 -86
- package/lib/module/hooks/withIAPContext.js.map +0 -1
- package/lib/module/iap.js +0 -805
- package/lib/module/iap.js.map +0 -1
- package/lib/module/internal/enhancedFetch.js +0 -19
- package/lib/module/internal/enhancedFetch.js.map +0 -1
- package/lib/module/internal/fillProductsWithAdditionalData.js +0 -43
- package/lib/module/internal/fillProductsWithAdditionalData.js.map +0 -1
- package/lib/module/internal/index.js +0 -4
- package/lib/module/internal/index.js.map +0 -1
- package/lib/module/internal/platform.js +0 -102
- package/lib/module/internal/platform.js.map +0 -1
- package/lib/module/modules/amazon.js +0 -42
- package/lib/module/modules/amazon.js.map +0 -1
- package/lib/module/modules/android.js +0 -81
- package/lib/module/modules/android.js.map +0 -1
- package/lib/module/modules/common.js +0 -2
- package/lib/module/modules/common.js.map +0 -1
- package/lib/module/modules/index.js +0 -5
- package/lib/module/modules/index.js.map +0 -1
- package/lib/module/modules/ios.js +0 -145
- package/lib/module/modules/ios.js.map +0 -1
- package/lib/module/modules/iosSk2.js +0 -96
- package/lib/module/modules/iosSk2.js.map +0 -1
- package/lib/module/purchaseError.js +0 -164
- package/lib/module/purchaseError.js.map +0 -1
- package/lib/module/types/amazon.js +0 -2
- package/lib/module/types/amazon.js.map +0 -1
- package/lib/module/types/android.js +0 -63
- package/lib/module/types/android.js.map +0 -1
- package/lib/module/types/apple.js +0 -17
- package/lib/module/types/apple.js.map +0 -1
- package/lib/module/types/appleSk2.js +0 -129
- package/lib/module/types/appleSk2.js.map +0 -1
- package/lib/module/types/index.js +0 -75
- package/lib/module/types/index.js.map +0 -1
- package/lib/module/utils/errorMapping.js +0 -75
- package/lib/module/utils/errorMapping.js.map +0 -1
- package/lib/module/utils/typeGuards.js +0 -61
- package/lib/module/utils/typeGuards.js.map +0 -1
- package/lib/typescript/src/eventEmitter.d.ts +0 -151
- package/lib/typescript/src/eventEmitter.d.ts.map +0 -1
- package/lib/typescript/src/hooks/index.d.ts +0 -2
- package/lib/typescript/src/hooks/index.d.ts.map +0 -1
- package/lib/typescript/src/hooks/withIAPContext.d.ts +0 -27
- package/lib/typescript/src/hooks/withIAPContext.d.ts.map +0 -1
- package/lib/typescript/src/iap.d.ts +0 -503
- package/lib/typescript/src/iap.d.ts.map +0 -1
- package/lib/typescript/src/internal/enhancedFetch.d.ts +0 -6
- package/lib/typescript/src/internal/enhancedFetch.d.ts.map +0 -1
- package/lib/typescript/src/internal/fillProductsWithAdditionalData.d.ts +0 -7
- package/lib/typescript/src/internal/fillProductsWithAdditionalData.d.ts.map +0 -1
- package/lib/typescript/src/internal/index.d.ts +0 -4
- package/lib/typescript/src/internal/index.d.ts.map +0 -1
- package/lib/typescript/src/internal/platform.d.ts +0 -27
- package/lib/typescript/src/internal/platform.d.ts.map +0 -1
- package/lib/typescript/src/modules/amazon.d.ts +0 -55
- package/lib/typescript/src/modules/amazon.d.ts.map +0 -1
- package/lib/typescript/src/modules/android.d.ts +0 -74
- package/lib/typescript/src/modules/android.d.ts.map +0 -1
- package/lib/typescript/src/modules/common.d.ts +0 -14
- package/lib/typescript/src/modules/common.d.ts.map +0 -1
- package/lib/typescript/src/modules/index.d.ts +0 -5
- package/lib/typescript/src/modules/index.d.ts.map +0 -1
- package/lib/typescript/src/modules/ios.d.ts +0 -117
- package/lib/typescript/src/modules/ios.d.ts.map +0 -1
- package/lib/typescript/src/modules/iosSk2.d.ts +0 -140
- package/lib/typescript/src/modules/iosSk2.d.ts.map +0 -1
- package/lib/typescript/src/purchaseError.d.ts +0 -133
- package/lib/typescript/src/purchaseError.d.ts.map +0 -1
- package/lib/typescript/src/types/amazon.d.ts +0 -33
- package/lib/typescript/src/types/amazon.d.ts.map +0 -1
- package/lib/typescript/src/types/android.d.ts +0 -66
- package/lib/typescript/src/types/android.d.ts.map +0 -1
- package/lib/typescript/src/types/apple.d.ts +0 -27
- package/lib/typescript/src/types/apple.d.ts.map +0 -1
- package/lib/typescript/src/types/appleSk2.d.ts +0 -129
- package/lib/typescript/src/types/appleSk2.d.ts.map +0 -1
- package/lib/typescript/src/types/index.d.ts +0 -302
- package/lib/typescript/src/types/index.d.ts.map +0 -1
- package/lib/typescript/src/utils/errorMapping.d.ts +0 -29
- package/lib/typescript/src/utils/errorMapping.d.ts.map +0 -1
- package/lib/typescript/src/utils/typeGuards.d.ts +0 -53
- package/lib/typescript/src/utils/typeGuards.d.ts.map +0 -1
- package/src/eventEmitter.ts +0 -212
- package/src/hooks/index.ts +0 -1
- package/src/hooks/withIAPContext.tsx +0 -179
- package/src/iap.ts +0 -1046
- package/src/internal/enhancedFetch.ts +0 -25
- package/src/internal/fillProductsWithAdditionalData.ts +0 -47
- package/src/internal/index.ts +0 -3
- package/src/internal/platform.ts +0 -135
- package/src/modules/amazon.ts +0 -94
- package/src/modules/android.ts +0 -179
- package/src/modules/common.ts +0 -16
- package/src/modules/index.ts +0 -4
- package/src/modules/ios.ts +0 -229
- package/src/modules/iosSk2.ts +0 -194
- package/src/purchaseError.ts +0 -196
- package/src/types/amazon.ts +0 -40
- package/src/types/android.ts +0 -89
- package/src/types/apple.ts +0 -44
- package/src/types/appleSk2.ts +0 -275
- package/src/types/index.ts +0 -379
- package/src/utils/errorMapping.ts +0 -88
- package/src/utils/typeGuards.ts +0 -90
package/src/types/index.ts
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AmazonModuleProps,
|
|
3
|
-
AndroidModuleProps,
|
|
4
|
-
IosModuleProps,
|
|
5
|
-
} from '../modules';
|
|
6
|
-
import type {IosModulePropsSk2} from '../modules/iosSk2';
|
|
7
|
-
|
|
8
|
-
import type * as Apple from './apple';
|
|
9
|
-
|
|
10
|
-
export type Sku = string;
|
|
11
|
-
|
|
12
|
-
// Platform discrimination types
|
|
13
|
-
export type IosPlatform = {platform: 'ios'};
|
|
14
|
-
export type AndroidPlatform = {platform: 'android'};
|
|
15
|
-
export type AmazonPlatform = {platform: 'amazon'};
|
|
16
|
-
|
|
17
|
-
export type ProrationModesAmazon = '' | 'DEFERRED' | 'IMMEDIATE';
|
|
18
|
-
|
|
19
|
-
export enum ReplacementModesAndroid {
|
|
20
|
-
UNKNOWN_REPLACEMENT_MODE = 0,
|
|
21
|
-
WITH_TIME_PRORATION = 1,
|
|
22
|
-
CHARGE_PRORATED_PRICE = 2,
|
|
23
|
-
WITHOUT_PRORATION = 3,
|
|
24
|
-
CHARGE_FULL_PRICE = 5,
|
|
25
|
-
DEFERRED = 6,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export enum PurchaseStateAndroid {
|
|
29
|
-
UNSPECIFIED_STATE = 0,
|
|
30
|
-
PURCHASED = 1,
|
|
31
|
-
PENDING = 2,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const PROMOTED_PRODUCT = 'iap-promoted-product';
|
|
35
|
-
|
|
36
|
-
export enum InstallSourceAndroid {
|
|
37
|
-
NOT_SET = 0,
|
|
38
|
-
GOOGLE_PLAY = 1,
|
|
39
|
-
AMAZON = 2,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export enum ProductType {
|
|
43
|
-
/** Subscription */
|
|
44
|
-
subs = 'subs',
|
|
45
|
-
|
|
46
|
-
/** Subscription */
|
|
47
|
-
sub = 'sub',
|
|
48
|
-
|
|
49
|
-
/** Consumable */
|
|
50
|
-
inapp = 'inapp',
|
|
51
|
-
|
|
52
|
-
/** Consumable */
|
|
53
|
-
iap = 'iap',
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export enum TransactionReason {
|
|
57
|
-
PURCHASE = 'PURCHASE',
|
|
58
|
-
RENEWAL = 'RENEWAL',
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface ProductCommon {
|
|
62
|
-
type: 'subs' | 'sub' | 'inapp' | 'iap';
|
|
63
|
-
productId: string; //iOS
|
|
64
|
-
id?: string; // Alias for productId (expo-iap compatibility)
|
|
65
|
-
productIds?: string[];
|
|
66
|
-
title: string;
|
|
67
|
-
description: string;
|
|
68
|
-
price: string;
|
|
69
|
-
currency: string;
|
|
70
|
-
localizedPrice: string;
|
|
71
|
-
displayPrice?: string; // Alias for localizedPrice (expo-iap compatibility)
|
|
72
|
-
originalPrice?: string;
|
|
73
|
-
countryCode?: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface ProductPurchase {
|
|
77
|
-
productId: string;
|
|
78
|
-
id?: string; // Alias for productId (expo-iap compatibility)
|
|
79
|
-
ids?: string[]; // For Android multi-purchase support
|
|
80
|
-
transactionId?: string;
|
|
81
|
-
transactionDate: number;
|
|
82
|
-
transactionReceipt: string;
|
|
83
|
-
purchaseToken?: string;
|
|
84
|
-
//iOS
|
|
85
|
-
quantityIOS?: number;
|
|
86
|
-
originalTransactionDateIOS?: number;
|
|
87
|
-
originalTransactionIdentifierIOS?: string;
|
|
88
|
-
verificationResultIOS?: string;
|
|
89
|
-
appAccountToken?: string;
|
|
90
|
-
jwsRepresentationIos?: string;
|
|
91
|
-
environmentIos?: string; // iOS 16+
|
|
92
|
-
storefrontCountryCodeIos?: string; // iOS 17+
|
|
93
|
-
reasonIos?: string; // iOS 17+
|
|
94
|
-
offerIos?: {
|
|
95
|
-
// iOS 17.2+
|
|
96
|
-
id: string;
|
|
97
|
-
type: string;
|
|
98
|
-
paymentMode: string;
|
|
99
|
-
};
|
|
100
|
-
priceIos?: number; // iOS 15.4+
|
|
101
|
-
currencyIos?: string; // iOS 15.4+
|
|
102
|
-
// Additional iOS fields from expo-iap
|
|
103
|
-
expirationDateIos?: number;
|
|
104
|
-
webOrderLineItemIdIos?: number;
|
|
105
|
-
appBundleIdIos?: string;
|
|
106
|
-
productTypeIos?: string;
|
|
107
|
-
subscriptionGroupIdIos?: string;
|
|
108
|
-
isUpgradedIos?: boolean;
|
|
109
|
-
ownershipTypeIos?: string;
|
|
110
|
-
reasonStringRepresentationIos?: string;
|
|
111
|
-
transactionReasonIOS?: TransactionReason | string;
|
|
112
|
-
revocationDateIos?: number;
|
|
113
|
-
revocationReasonIos?: string;
|
|
114
|
-
//Android
|
|
115
|
-
productIds?: string[];
|
|
116
|
-
dataAndroid?: string;
|
|
117
|
-
signatureAndroid?: string;
|
|
118
|
-
autoRenewingAndroid?: boolean;
|
|
119
|
-
purchaseStateAndroid?: PurchaseStateAndroid;
|
|
120
|
-
isAcknowledgedAndroid?: boolean;
|
|
121
|
-
packageNameAndroid?: string;
|
|
122
|
-
developerPayloadAndroid?: string;
|
|
123
|
-
obfuscatedAccountIdAndroid?: string;
|
|
124
|
-
obfuscatedProfileIdAndroid?: string;
|
|
125
|
-
//Amazon
|
|
126
|
-
userIdAmazon?: string;
|
|
127
|
-
userMarketplaceAmazon?: string;
|
|
128
|
-
userJsonAmazon?: string;
|
|
129
|
-
isCanceledAmazon?: boolean;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export type AppTransaction = {
|
|
133
|
-
appTransactionID?: string; // iOS 18.4+
|
|
134
|
-
originalPlatform?: string; // iOS 18.4+
|
|
135
|
-
originalAppVersion: string;
|
|
136
|
-
originalPurchaseDate: number;
|
|
137
|
-
deviceVerification: string;
|
|
138
|
-
deviceVerificationNonce: string;
|
|
139
|
-
appVersion: string;
|
|
140
|
-
signedDate: number;
|
|
141
|
-
environment: string; // iOS 16+
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export interface PurchaseResult {
|
|
145
|
-
responseCode?: number;
|
|
146
|
-
debugMessage?: string;
|
|
147
|
-
code?: string;
|
|
148
|
-
message?: string;
|
|
149
|
-
purchaseToken?: string;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface SubscriptionPurchase extends ProductPurchase {
|
|
153
|
-
autoRenewingAndroid?: boolean;
|
|
154
|
-
originalTransactionDateIOS?: number;
|
|
155
|
-
originalTransactionIdentifierIOS?: string;
|
|
156
|
-
verificationResultIOS?: string;
|
|
157
|
-
transactionReasonIOS?: TransactionReason | string;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// New discriminated union type matching expo-iap
|
|
161
|
-
export type PurchaseWithPlatform =
|
|
162
|
-
| ((ProductPurchase & {productIds?: string[]}) & AndroidPlatform)
|
|
163
|
-
| ((ProductPurchase & {quantityIOS?: number}) & IosPlatform)
|
|
164
|
-
| ((ProductPurchase & {userIdAmazon?: string}) & AmazonPlatform)
|
|
165
|
-
| SubscriptionPurchase;
|
|
166
|
-
|
|
167
|
-
// For backward compatibility, keep the original Purchase type
|
|
168
|
-
export type Purchase = ProductPurchase | SubscriptionPurchase;
|
|
169
|
-
|
|
170
|
-
export interface Discount {
|
|
171
|
-
identifier: string;
|
|
172
|
-
type: string;
|
|
173
|
-
numberOfPeriods: string;
|
|
174
|
-
price: string;
|
|
175
|
-
localizedPrice: string;
|
|
176
|
-
paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';
|
|
177
|
-
subscriptionPeriod: string;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export interface ProductAndroid extends ProductCommon {
|
|
181
|
-
type: 'inapp' | 'iap';
|
|
182
|
-
name?: string;
|
|
183
|
-
oneTimePurchaseOfferDetails?: {
|
|
184
|
-
priceCurrencyCode: string;
|
|
185
|
-
formattedPrice: string;
|
|
186
|
-
priceAmountMicros: string;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
export interface ProductIOS extends ProductCommon {
|
|
190
|
-
type: 'inapp' | 'iap';
|
|
191
|
-
// iOS specific fields from expo-iap
|
|
192
|
-
displayName?: string;
|
|
193
|
-
isFamilyShareable?: boolean;
|
|
194
|
-
jsonRepresentation?: string;
|
|
195
|
-
subscription?: any; // SubscriptionInfo type
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Legacy type for backward compatibility
|
|
199
|
-
export type ProductLegacy = ProductAndroid & ProductIOS;
|
|
200
|
-
|
|
201
|
-
// New discriminated union type matching expo-iap
|
|
202
|
-
export type ProductWithPlatform =
|
|
203
|
-
| (ProductAndroid & AndroidPlatform)
|
|
204
|
-
| (ProductIOS & IosPlatform);
|
|
205
|
-
|
|
206
|
-
// For backward compatibility, keep the original Product type
|
|
207
|
-
export type Product = ProductAndroid & ProductIOS;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Can be used to distinguish the different platforms' subscription information
|
|
211
|
-
*/
|
|
212
|
-
export enum SubscriptionPlatform {
|
|
213
|
-
android = 'android',
|
|
214
|
-
amazon = 'amazon',
|
|
215
|
-
ios = 'ios',
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** Android Billing v5 type */
|
|
219
|
-
export interface SubscriptionAndroid {
|
|
220
|
-
platform: SubscriptionPlatform.android;
|
|
221
|
-
productType: 'subs';
|
|
222
|
-
name: string;
|
|
223
|
-
title: string;
|
|
224
|
-
description: string;
|
|
225
|
-
productId: string;
|
|
226
|
-
subscriptionOfferDetails: SubscriptionOfferAndroid[];
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export interface SubscriptionOfferAndroid {
|
|
230
|
-
basePlanId: string;
|
|
231
|
-
offerId: string | null;
|
|
232
|
-
offerToken: string;
|
|
233
|
-
pricingPhases: {
|
|
234
|
-
pricingPhaseList: PricingPhaseAndroid[];
|
|
235
|
-
};
|
|
236
|
-
offerTags: string[];
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export interface PricingPhaseAndroid {
|
|
240
|
-
formattedPrice: string;
|
|
241
|
-
priceCurrencyCode: string;
|
|
242
|
-
/**
|
|
243
|
-
* P1W, P1M, P1Y
|
|
244
|
-
*/
|
|
245
|
-
billingPeriod: string;
|
|
246
|
-
billingCycleCount: number;
|
|
247
|
-
priceAmountMicros: string;
|
|
248
|
-
recurrenceMode: number;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* TODO: As of 2022-10-10, this typing is not verified against the real
|
|
253
|
-
* Amazon API. Please update this if you have a more accurate type.
|
|
254
|
-
*/
|
|
255
|
-
export interface SubscriptionAmazon extends ProductCommon {
|
|
256
|
-
platform: SubscriptionPlatform.amazon;
|
|
257
|
-
type: 'subs';
|
|
258
|
-
|
|
259
|
-
productType?: string;
|
|
260
|
-
name?: string;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';
|
|
264
|
-
export interface SubscriptionIOS extends ProductCommon {
|
|
265
|
-
platform: SubscriptionPlatform.ios;
|
|
266
|
-
type: 'subs';
|
|
267
|
-
discounts?: Discount[];
|
|
268
|
-
introductoryPrice?: string;
|
|
269
|
-
introductoryPriceAsAmountIOS?: string;
|
|
270
|
-
introductoryPricePaymentModeIOS?:
|
|
271
|
-
| ''
|
|
272
|
-
| 'FREETRIAL'
|
|
273
|
-
| 'PAYASYOUGO'
|
|
274
|
-
| 'PAYUPFRONT';
|
|
275
|
-
introductoryPriceNumberOfPeriodsIOS?: string;
|
|
276
|
-
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
|
|
277
|
-
|
|
278
|
-
subscriptionPeriodNumberIOS?: string;
|
|
279
|
-
subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export type Subscription =
|
|
283
|
-
| SubscriptionAndroid
|
|
284
|
-
| SubscriptionAmazon
|
|
285
|
-
| SubscriptionIOS;
|
|
286
|
-
|
|
287
|
-
export interface RequestPurchaseBaseAndroid {
|
|
288
|
-
obfuscatedAccountIdAndroid?: string;
|
|
289
|
-
obfuscatedProfileIdAndroid?: string;
|
|
290
|
-
isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {
|
|
294
|
-
skus: Sku[];
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export interface RequestPurchaseIOS {
|
|
298
|
-
sku: Sku;
|
|
299
|
-
andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
|
|
300
|
-
/**
|
|
301
|
-
* UUID representing user account
|
|
302
|
-
*/
|
|
303
|
-
appAccountToken?: string;
|
|
304
|
-
quantity?: number;
|
|
305
|
-
withOffer?: Apple.PaymentDiscount;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/** As of 2022-10-12, we only use the `sku` field for Amazon purchases */
|
|
309
|
-
export type RequestPurchaseAmazon = RequestPurchaseIOS;
|
|
310
|
-
|
|
311
|
-
export type RequestPurchase =
|
|
312
|
-
| RequestPurchaseAndroid
|
|
313
|
-
| RequestPurchaseAmazon
|
|
314
|
-
| RequestPurchaseIOS;
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* In order to purchase a new subscription, every sku must have a selected offerToken
|
|
318
|
-
* @see SubscriptionAndroid.subscriptionOfferDetails.offerToken
|
|
319
|
-
*/
|
|
320
|
-
export interface SubscriptionOffer {
|
|
321
|
-
sku: Sku;
|
|
322
|
-
offerToken: string;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
export interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {
|
|
326
|
-
purchaseTokenAndroid?: string;
|
|
327
|
-
replacementModeAndroid?: ReplacementModesAndroid;
|
|
328
|
-
subscriptionOffers: SubscriptionOffer[];
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export type RequestSubscriptionIOS = RequestPurchaseIOS;
|
|
332
|
-
|
|
333
|
-
/** As of 2022-10-12, we only use the `sku` field for Amazon subscriptions */
|
|
334
|
-
export interface RequestSubscriptionAmazon extends RequestSubscriptionIOS {
|
|
335
|
-
prorationModeAmazon?: ProrationModesAmazon;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export type RequestSubscription =
|
|
339
|
-
| RequestSubscriptionAndroid
|
|
340
|
-
| RequestSubscriptionAmazon
|
|
341
|
-
| RequestSubscriptionIOS;
|
|
342
|
-
|
|
343
|
-
// Unified request types (expo-iap compatibility)
|
|
344
|
-
export interface UnifiedRequestPurchaseProps {
|
|
345
|
-
// Universal properties - works on both platforms
|
|
346
|
-
readonly sku?: string; // Single SKU (iOS native, Android fallback)
|
|
347
|
-
readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)
|
|
348
|
-
|
|
349
|
-
// iOS-specific properties (ignored on Android)
|
|
350
|
-
readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
|
|
351
|
-
readonly appAccountToken?: string;
|
|
352
|
-
readonly quantity?: number;
|
|
353
|
-
readonly withOffer?: Apple.PaymentDiscount;
|
|
354
|
-
|
|
355
|
-
// Android-specific properties (ignored on iOS)
|
|
356
|
-
readonly obfuscatedAccountIdAndroid?: string;
|
|
357
|
-
readonly obfuscatedProfileIdAndroid?: string;
|
|
358
|
-
readonly isOfferPersonalized?: boolean;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export interface UnifiedRequestSubscriptionProps
|
|
362
|
-
extends UnifiedRequestPurchaseProps {
|
|
363
|
-
// Android subscription-specific properties
|
|
364
|
-
readonly purchaseTokenAndroid?: string;
|
|
365
|
-
readonly replacementModeAndroid?: number;
|
|
366
|
-
readonly subscriptionOffers?: {
|
|
367
|
-
sku: string;
|
|
368
|
-
offerToken: string;
|
|
369
|
-
}[];
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
declare module 'react-native' {
|
|
373
|
-
interface NativeModulesStatic {
|
|
374
|
-
RNIapIos: IosModuleProps;
|
|
375
|
-
RNIapIosSk2: IosModulePropsSk2;
|
|
376
|
-
RNIapModule: AndroidModuleProps;
|
|
377
|
-
RNIapAmazonModule: AmazonModuleProps;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error mapping utilities for react-native-iap
|
|
3
|
-
* Provides helper functions for handling platform-specific errors
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {ErrorCode} from '../purchaseError';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Checks if an error is a user cancellation
|
|
10
|
-
* @param error Error object or error code
|
|
11
|
-
* @returns True if the error represents user cancellation
|
|
12
|
-
*/
|
|
13
|
-
export function isUserCancelledError(error: any): boolean {
|
|
14
|
-
if (typeof error === 'string') {
|
|
15
|
-
return error === ErrorCode.E_USER_CANCELLED;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (error && error.code) {
|
|
19
|
-
return error.code === ErrorCode.E_USER_CANCELLED;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Checks if an error is related to network connectivity
|
|
27
|
-
* @param error Error object or error code
|
|
28
|
-
* @returns True if the error is network-related
|
|
29
|
-
*/
|
|
30
|
-
export function isNetworkError(error: any): boolean {
|
|
31
|
-
const networkErrors = [
|
|
32
|
-
ErrorCode.E_NETWORK_ERROR,
|
|
33
|
-
ErrorCode.E_REMOTE_ERROR,
|
|
34
|
-
ErrorCode.E_SERVICE_ERROR,
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
const errorCode = typeof error === 'string' ? error : error?.code;
|
|
38
|
-
return networkErrors.includes(errorCode);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Checks if an error is recoverable (user can retry)
|
|
43
|
-
* @param error Error object or error code
|
|
44
|
-
* @returns True if the error is potentially recoverable
|
|
45
|
-
*/
|
|
46
|
-
export function isRecoverableError(error: any): boolean {
|
|
47
|
-
const recoverableErrors = [
|
|
48
|
-
ErrorCode.E_NETWORK_ERROR,
|
|
49
|
-
ErrorCode.E_REMOTE_ERROR,
|
|
50
|
-
ErrorCode.E_SERVICE_ERROR,
|
|
51
|
-
ErrorCode.E_INTERRUPTED,
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
const errorCode = typeof error === 'string' ? error : error?.code;
|
|
55
|
-
return recoverableErrors.includes(errorCode);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Gets a user-friendly error message for display
|
|
60
|
-
* @param error Error object or error code
|
|
61
|
-
* @returns User-friendly error message
|
|
62
|
-
*/
|
|
63
|
-
export function getUserFriendlyErrorMessage(error: any): string {
|
|
64
|
-
const errorCode = typeof error === 'string' ? error : error?.code;
|
|
65
|
-
|
|
66
|
-
switch (errorCode) {
|
|
67
|
-
case ErrorCode.E_USER_CANCELLED:
|
|
68
|
-
return 'Purchase was cancelled by user';
|
|
69
|
-
case ErrorCode.E_NETWORK_ERROR:
|
|
70
|
-
return 'Network connection error. Please check your internet connection and try again.';
|
|
71
|
-
case ErrorCode.E_ITEM_UNAVAILABLE:
|
|
72
|
-
return 'This item is not available for purchase';
|
|
73
|
-
case ErrorCode.E_ALREADY_OWNED:
|
|
74
|
-
return 'You already own this item';
|
|
75
|
-
case ErrorCode.E_DEFERRED_PAYMENT:
|
|
76
|
-
return 'Payment is pending approval';
|
|
77
|
-
case ErrorCode.E_NOT_PREPARED:
|
|
78
|
-
return 'In-app purchase is not ready. Please try again later.';
|
|
79
|
-
case ErrorCode.E_SERVICE_ERROR:
|
|
80
|
-
return 'Store service error. Please try again later.';
|
|
81
|
-
case ErrorCode.E_TRANSACTION_VALIDATION_FAILED:
|
|
82
|
-
return 'Transaction could not be verified';
|
|
83
|
-
case ErrorCode.E_RECEIPT_FAILED:
|
|
84
|
-
return 'Receipt processing failed';
|
|
85
|
-
default:
|
|
86
|
-
return error?.message || 'An unexpected error occurred';
|
|
87
|
-
}
|
|
88
|
-
}
|
package/src/utils/typeGuards.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guard functions for react-native-iap
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {Platform} from 'react-native';
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
Product,
|
|
9
|
-
ProductPurchase,
|
|
10
|
-
ProductWithPlatform,
|
|
11
|
-
Purchase,
|
|
12
|
-
PurchaseWithPlatform,
|
|
13
|
-
} from '../types';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Type guard to check if a product is from iOS
|
|
17
|
-
*/
|
|
18
|
-
export function isProductIos(
|
|
19
|
-
product: Product | ProductWithPlatform,
|
|
20
|
-
): product is Product & {platform?: 'ios'} {
|
|
21
|
-
return Platform.OS === 'ios' || (product as any).platform === 'ios';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Type guard to check if a product is from Android
|
|
26
|
-
*/
|
|
27
|
-
export function isProductAndroid(
|
|
28
|
-
product: Product | ProductWithPlatform,
|
|
29
|
-
): product is Product & {platform?: 'android'} {
|
|
30
|
-
return Platform.OS === 'android' || (product as any).platform === 'android';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Type guard to check if a purchase is from iOS
|
|
35
|
-
*/
|
|
36
|
-
export function isPurchaseIos(
|
|
37
|
-
purchase: Purchase | PurchaseWithPlatform,
|
|
38
|
-
): purchase is Purchase & {platform?: 'ios'} {
|
|
39
|
-
return Platform.OS === 'ios' || (purchase as any).platform === 'ios';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Type guard to check if a purchase is from Android
|
|
44
|
-
*/
|
|
45
|
-
export function isPurchaseAndroid(
|
|
46
|
-
purchase: Purchase | PurchaseWithPlatform,
|
|
47
|
-
): purchase is Purchase & {platform?: 'android'} {
|
|
48
|
-
return Platform.OS === 'android' || (purchase as any).platform === 'android';
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Type guard to check if a purchase is from Amazon
|
|
53
|
-
*/
|
|
54
|
-
export function isPurchaseAmazon(
|
|
55
|
-
purchase: Purchase | PurchaseWithPlatform,
|
|
56
|
-
): purchase is Purchase & {platform?: 'amazon'} {
|
|
57
|
-
return (
|
|
58
|
-
(purchase as any).platform === 'amazon' || !!(purchase as any).userIdAmazon
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Type guard to check if an item is a ProductPurchase
|
|
64
|
-
*/
|
|
65
|
-
export function isProductPurchase(item: unknown): item is ProductPurchase {
|
|
66
|
-
return (
|
|
67
|
-
item != null &&
|
|
68
|
-
typeof item === 'object' &&
|
|
69
|
-
'productId' in item &&
|
|
70
|
-
'transactionDate' in item &&
|
|
71
|
-
'transactionReceipt' in item
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Helper to get the product ID from either field name
|
|
77
|
-
*/
|
|
78
|
-
export function getProductId(item: {productId?: string; id?: string}): string {
|
|
79
|
-
return item.productId || item.id || '';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Helper to get the display price from either field name
|
|
84
|
-
*/
|
|
85
|
-
export function getDisplayPrice(item: {
|
|
86
|
-
localizedPrice?: string;
|
|
87
|
-
displayPrice?: string;
|
|
88
|
-
}): string {
|
|
89
|
-
return item.displayPrice || item.localizedPrice || '';
|
|
90
|
-
}
|