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.ts
ADDED
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// CORE TYPES
|
|
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
|
+
//
|
|
13
|
+
// ============================================================================
|
|
14
|
+
|
|
15
|
+
export type ChangeEventPayload = {
|
|
16
|
+
value: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ProductType = 'inapp' | 'subs'
|
|
20
|
+
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// COMMON TYPES (Base types shared across all platforms)
|
|
23
|
+
// ============================================================================
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Base product information shared across all platforms
|
|
27
|
+
*/
|
|
28
|
+
export type ProductCommon = {
|
|
29
|
+
/** Product identifier (SKU) */
|
|
30
|
+
id: string
|
|
31
|
+
/** Product title displayed to users */
|
|
32
|
+
title: string
|
|
33
|
+
/** Product description */
|
|
34
|
+
description: string
|
|
35
|
+
/** Product type: 'inapp' for one-time purchases (consumable/non-consumable), 'subs' for subscriptions */
|
|
36
|
+
type: ProductType
|
|
37
|
+
/** Display name for the product */
|
|
38
|
+
displayName?: string
|
|
39
|
+
/** Formatted price string for display (e.g., "$9.99") */
|
|
40
|
+
displayPrice: string
|
|
41
|
+
/** Currency code (e.g., "USD", "EUR") */
|
|
42
|
+
currency: string
|
|
43
|
+
/** Raw price value as number */
|
|
44
|
+
price?: number
|
|
45
|
+
/** Debug description for development */
|
|
46
|
+
debugDescription?: string
|
|
47
|
+
/** Platform identifier ('ios' or 'android') */
|
|
48
|
+
platform?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Base purchase information shared across all platforms
|
|
53
|
+
* Represents both consumables, non-consumables, and subscriptions
|
|
54
|
+
*/
|
|
55
|
+
export type PurchaseCommon = {
|
|
56
|
+
/** Transaction identifier - used by finishTransaction */
|
|
57
|
+
id: string
|
|
58
|
+
/** Product identifier - which product was purchased */
|
|
59
|
+
productId: string
|
|
60
|
+
/** Product identifiers for purchases that include multiple products */
|
|
61
|
+
ids?: string[]
|
|
62
|
+
/** @deprecated - use id instead */
|
|
63
|
+
transactionId?: string
|
|
64
|
+
/** Transaction timestamp in milliseconds */
|
|
65
|
+
transactionDate: number
|
|
66
|
+
/** Transaction receipt for validation */
|
|
67
|
+
transactionReceipt: string
|
|
68
|
+
/** Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android) */
|
|
69
|
+
purchaseToken?: string
|
|
70
|
+
/** Platform identifier ('ios' or 'android') */
|
|
71
|
+
platform?: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type ProductSubscriptionCommon = ProductCommon & {
|
|
75
|
+
type: 'subs'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// PLATFORM TYPES
|
|
80
|
+
// ============================================================================
|
|
81
|
+
|
|
82
|
+
export type IosPlatform = { platform: 'ios' }
|
|
83
|
+
export type AndroidPlatform = { platform: 'android' }
|
|
84
|
+
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// IOS TYPES
|
|
87
|
+
// ============================================================================
|
|
88
|
+
|
|
89
|
+
type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | ''
|
|
90
|
+
type PaymentMode = '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT'
|
|
91
|
+
|
|
92
|
+
type SubscriptionOffer = {
|
|
93
|
+
displayPrice: string
|
|
94
|
+
id: string
|
|
95
|
+
paymentMode: PaymentMode
|
|
96
|
+
period: {
|
|
97
|
+
unit: SubscriptionIosPeriod
|
|
98
|
+
value: number
|
|
99
|
+
}
|
|
100
|
+
periodCount: number
|
|
101
|
+
price: number
|
|
102
|
+
type: 'introductory' | 'promotional'
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
type SubscriptionInfo = {
|
|
106
|
+
introductoryOffer?: SubscriptionOffer
|
|
107
|
+
promotionalOffers?: SubscriptionOffer[]
|
|
108
|
+
subscriptionGroupId: string
|
|
109
|
+
subscriptionPeriod: {
|
|
110
|
+
unit: SubscriptionIosPeriod
|
|
111
|
+
value: number
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type Discount = {
|
|
116
|
+
identifier: string
|
|
117
|
+
type: string
|
|
118
|
+
numberOfPeriods: string
|
|
119
|
+
price: string
|
|
120
|
+
localizedPrice: string
|
|
121
|
+
paymentMode: PaymentMode
|
|
122
|
+
subscriptionPeriod: string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type ProductIOS = ProductCommon & {
|
|
126
|
+
displayNameIOS: string
|
|
127
|
+
isFamilyShareableIOS: boolean
|
|
128
|
+
jsonRepresentationIOS: string
|
|
129
|
+
platform: 'ios'
|
|
130
|
+
subscriptionInfoIOS?: SubscriptionInfo
|
|
131
|
+
// deprecated fields
|
|
132
|
+
displayName?: string
|
|
133
|
+
isFamilyShareable?: boolean
|
|
134
|
+
jsonRepresentation?: string
|
|
135
|
+
subscription?: SubscriptionInfo
|
|
136
|
+
introductoryPriceNumberOfPeriodsIOS?: string
|
|
137
|
+
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type ProductSubscriptionIOS = ProductIOS & {
|
|
141
|
+
discountsIOS?: Discount[]
|
|
142
|
+
introductoryPriceIOS?: string
|
|
143
|
+
introductoryPriceAsAmountIOS?: string
|
|
144
|
+
introductoryPricePaymentModeIOS?: PaymentMode
|
|
145
|
+
introductoryPriceNumberOfPeriodsIOS?: string
|
|
146
|
+
introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod
|
|
147
|
+
platform: 'ios'
|
|
148
|
+
subscriptionPeriodNumberIOS?: string
|
|
149
|
+
subscriptionPeriodUnitIOS?: SubscriptionIosPeriod
|
|
150
|
+
// deprecated
|
|
151
|
+
discounts?: Discount[]
|
|
152
|
+
introductoryPrice?: string
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type PurchaseIOS = PurchaseCommon & {
|
|
156
|
+
platform: 'ios'
|
|
157
|
+
quantityIOS?: number
|
|
158
|
+
originalTransactionDateIOS?: number
|
|
159
|
+
originalTransactionIdentifierIOS?: string
|
|
160
|
+
appAccountToken?: string
|
|
161
|
+
// iOS additional fields from StoreKit 2
|
|
162
|
+
expirationDateIOS?: number
|
|
163
|
+
webOrderLineItemIdIOS?: number
|
|
164
|
+
environmentIOS?: string
|
|
165
|
+
storefrontCountryCodeIOS?: string
|
|
166
|
+
appBundleIdIOS?: string
|
|
167
|
+
productTypeIOS?: string
|
|
168
|
+
subscriptionGroupIdIOS?: string
|
|
169
|
+
isUpgradedIOS?: boolean
|
|
170
|
+
ownershipTypeIOS?: string
|
|
171
|
+
reasonIOS?: string
|
|
172
|
+
reasonStringRepresentationIOS?: string
|
|
173
|
+
transactionReasonIOS?: 'PURCHASE' | 'RENEWAL' | string
|
|
174
|
+
revocationDateIOS?: number
|
|
175
|
+
revocationReasonIOS?: string
|
|
176
|
+
offerIOS?: {
|
|
177
|
+
id: string
|
|
178
|
+
type: string
|
|
179
|
+
paymentMode: string
|
|
180
|
+
}
|
|
181
|
+
// Price locale fields
|
|
182
|
+
currencyCodeIOS?: string
|
|
183
|
+
currencySymbolIOS?: string
|
|
184
|
+
countryCodeIOS?: string
|
|
185
|
+
/**
|
|
186
|
+
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
187
|
+
* iOS 15+ JWS representation is now available through the `purchaseToken` field.
|
|
188
|
+
*/
|
|
189
|
+
jwsRepresentationIOS?: string
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// ANDROID TYPES
|
|
194
|
+
// ============================================================================
|
|
195
|
+
|
|
196
|
+
type ProductAndroidOneTimePurchaseOfferDetail = {
|
|
197
|
+
priceCurrencyCode: string
|
|
198
|
+
formattedPrice: string
|
|
199
|
+
priceAmountMicros: string
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
type PricingPhaseAndroid = {
|
|
203
|
+
formattedPrice: string
|
|
204
|
+
priceCurrencyCode: string
|
|
205
|
+
billingPeriod: string // P1W, P1M, P1Y
|
|
206
|
+
billingCycleCount: number
|
|
207
|
+
priceAmountMicros: string
|
|
208
|
+
recurrenceMode: number
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
type PricingPhasesAndroid = {
|
|
212
|
+
pricingPhaseList: PricingPhaseAndroid[]
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
type ProductSubscriptionAndroidOfferDetail = {
|
|
216
|
+
basePlanId: string
|
|
217
|
+
offerId: string
|
|
218
|
+
offerToken: string
|
|
219
|
+
offerTags: string[]
|
|
220
|
+
pricingPhases: PricingPhasesAndroid
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
type ProductSubscriptionAndroidOfferDetails = {
|
|
224
|
+
basePlanId: string
|
|
225
|
+
offerId: string | null
|
|
226
|
+
offerToken: string
|
|
227
|
+
pricingPhases: PricingPhasesAndroid
|
|
228
|
+
offerTags: string[]
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export type ProductAndroid = ProductCommon & {
|
|
232
|
+
nameAndroid: string
|
|
233
|
+
oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail
|
|
234
|
+
platform: 'android'
|
|
235
|
+
subscriptionOfferDetailsAndroid?: ProductSubscriptionAndroidOfferDetail[]
|
|
236
|
+
// deprecated fields
|
|
237
|
+
name?: string
|
|
238
|
+
oneTimePurchaseOfferDetails?: ProductAndroidOneTimePurchaseOfferDetail
|
|
239
|
+
subscriptionOfferDetails?: ProductSubscriptionAndroidOfferDetail[]
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export type ProductSubscriptionAndroid = ProductAndroid & {
|
|
243
|
+
subscriptionOfferDetailsAndroid: ProductSubscriptionAndroidOfferDetails[]
|
|
244
|
+
// deprecated
|
|
245
|
+
subscriptionOfferDetails?: ProductSubscriptionAndroidOfferDetails[]
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export enum PurchaseAndroidState {
|
|
249
|
+
UNSPECIFIED_STATE = 0,
|
|
250
|
+
PURCHASED = 1,
|
|
251
|
+
PENDING = 2,
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export type PurchaseAndroid = PurchaseCommon & {
|
|
255
|
+
platform: 'android'
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
258
|
+
*/
|
|
259
|
+
purchaseTokenAndroid?: string
|
|
260
|
+
dataAndroid?: string
|
|
261
|
+
signatureAndroid?: string
|
|
262
|
+
autoRenewingAndroid?: boolean
|
|
263
|
+
purchaseStateAndroid?: PurchaseAndroidState
|
|
264
|
+
isAcknowledgedAndroid?: boolean
|
|
265
|
+
packageNameAndroid?: string
|
|
266
|
+
developerPayloadAndroid?: string
|
|
267
|
+
obfuscatedAccountIdAndroid?: string
|
|
268
|
+
obfuscatedProfileIdAndroid?: string
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ============================================================================
|
|
272
|
+
// TYPE ALIASES
|
|
273
|
+
// ============================================================================
|
|
274
|
+
|
|
275
|
+
// Legacy naming for backward compatibility
|
|
276
|
+
export type ProductPurchaseIOS = PurchaseIOS
|
|
277
|
+
export type ProductPurchaseAndroid = PurchaseAndroid
|
|
278
|
+
|
|
279
|
+
// Legacy naming for backward compatibility
|
|
280
|
+
export type SubscriptionProductIOS = ProductSubscriptionIOS
|
|
281
|
+
export type SubscriptionProductAndroid = ProductSubscriptionAndroid
|
|
282
|
+
|
|
283
|
+
// ============================================================================
|
|
284
|
+
// UNION TYPES
|
|
285
|
+
// ============================================================================
|
|
286
|
+
|
|
287
|
+
// Product Union Types
|
|
288
|
+
export type Product =
|
|
289
|
+
| (ProductAndroid & AndroidPlatform)
|
|
290
|
+
| (ProductIOS & IosPlatform)
|
|
291
|
+
|
|
292
|
+
export type SubscriptionProduct =
|
|
293
|
+
| (ProductSubscriptionAndroid & AndroidPlatform)
|
|
294
|
+
| (ProductSubscriptionIOS & IosPlatform)
|
|
295
|
+
|
|
296
|
+
// Purchase Union Types
|
|
297
|
+
/**
|
|
298
|
+
* Regular product purchase (consumable or non-consumable)
|
|
299
|
+
* Both types appear in getAvailablePurchases until finishTransaction is called
|
|
300
|
+
*/
|
|
301
|
+
export type ProductPurchase =
|
|
302
|
+
| (PurchaseAndroid & AndroidPlatform)
|
|
303
|
+
| (PurchaseIOS & IosPlatform)
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Active subscription purchase
|
|
307
|
+
* Appears in getAvailablePurchases while subscription is active
|
|
308
|
+
*/
|
|
309
|
+
export type SubscriptionPurchase =
|
|
310
|
+
| (PurchaseAndroid & AndroidPlatform & { autoRenewingAndroid: boolean })
|
|
311
|
+
| (PurchaseIOS & IosPlatform)
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Combined purchase type that includes all purchase types
|
|
315
|
+
* Used as return type for getAvailablePurchases
|
|
316
|
+
*/
|
|
317
|
+
export type Purchase =
|
|
318
|
+
| (PurchaseAndroid & AndroidPlatform)
|
|
319
|
+
| (PurchaseIOS & IosPlatform)
|
|
320
|
+
|
|
321
|
+
// ============================================================================
|
|
322
|
+
// REQUEST TYPES
|
|
323
|
+
// ============================================================================
|
|
324
|
+
|
|
325
|
+
// iOS-specific purchase request parameters
|
|
326
|
+
export interface RequestPurchaseIosProps {
|
|
327
|
+
readonly sku: string
|
|
328
|
+
readonly andDangerouslyFinishTransactionAutomatically?: boolean
|
|
329
|
+
readonly appAccountToken?: string
|
|
330
|
+
readonly quantity?: number
|
|
331
|
+
readonly withOffer?: PaymentDiscount
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Android-specific purchase request parameters
|
|
335
|
+
export interface RequestPurchaseAndroidProps {
|
|
336
|
+
readonly skus: string[]
|
|
337
|
+
readonly obfuscatedAccountIdAndroid?: string
|
|
338
|
+
readonly obfuscatedProfileIdAndroid?: string
|
|
339
|
+
readonly isOfferPersonalized?: boolean
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Android-specific subscription request parameters
|
|
343
|
+
export interface RequestSubscriptionAndroidProps
|
|
344
|
+
extends RequestPurchaseAndroidProps {
|
|
345
|
+
readonly purchaseTokenAndroid?: string
|
|
346
|
+
readonly replacementModeAndroid?: number
|
|
347
|
+
readonly subscriptionOffers: {
|
|
348
|
+
sku: string
|
|
349
|
+
offerToken: string
|
|
350
|
+
}[]
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Platform-specific request structures
|
|
354
|
+
export interface RequestPurchasePropsByPlatforms {
|
|
355
|
+
readonly ios?: RequestPurchaseIosProps
|
|
356
|
+
readonly android?: RequestPurchaseAndroidProps
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export interface RequestSubscriptionPropsByPlatforms {
|
|
360
|
+
readonly ios?: RequestPurchaseIosProps
|
|
361
|
+
readonly android?: RequestSubscriptionAndroidProps
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Modern request types (v2.7.0+)
|
|
365
|
+
export type RequestPurchaseProps = RequestPurchasePropsByPlatforms
|
|
366
|
+
export type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms
|
|
367
|
+
|
|
368
|
+
// ============================================================================
|
|
369
|
+
// ERROR TYPES
|
|
370
|
+
// ============================================================================
|
|
371
|
+
|
|
372
|
+
export enum ErrorCode {
|
|
373
|
+
E_UNKNOWN = 'E_UNKNOWN',
|
|
374
|
+
E_USER_CANCELLED = 'E_USER_CANCELLED',
|
|
375
|
+
E_USER_ERROR = 'E_USER_ERROR',
|
|
376
|
+
E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',
|
|
377
|
+
E_REMOTE_ERROR = 'E_REMOTE_ERROR',
|
|
378
|
+
E_NETWORK_ERROR = 'E_NETWORK_ERROR',
|
|
379
|
+
E_SERVICE_ERROR = 'E_SERVICE_ERROR',
|
|
380
|
+
E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',
|
|
381
|
+
E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',
|
|
382
|
+
E_NOT_PREPARED = 'E_NOT_PREPARED',
|
|
383
|
+
E_NOT_ENDED = 'E_NOT_ENDED',
|
|
384
|
+
E_ALREADY_OWNED = 'E_ALREADY_OWNED',
|
|
385
|
+
E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',
|
|
386
|
+
E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
387
|
+
E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',
|
|
388
|
+
E_INTERRUPTED = 'E_INTERRUPTED',
|
|
389
|
+
E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',
|
|
390
|
+
E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',
|
|
391
|
+
E_SYNC_ERROR = 'E_SYNC_ERROR',
|
|
392
|
+
E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',
|
|
393
|
+
E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',
|
|
394
|
+
E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',
|
|
395
|
+
E_PENDING = 'E_PENDING',
|
|
396
|
+
E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',
|
|
397
|
+
E_INIT_CONNECTION = 'E_INIT_CONNECTION',
|
|
398
|
+
E_SERVICE_DISCONNECTED = 'E_SERVICE_DISCONNECTED',
|
|
399
|
+
E_QUERY_PRODUCT = 'E_QUERY_PRODUCT',
|
|
400
|
+
E_SKU_NOT_FOUND = 'E_SKU_NOT_FOUND',
|
|
401
|
+
E_SKU_OFFER_MISMATCH = 'E_SKU_OFFER_MISMATCH',
|
|
402
|
+
E_ITEM_NOT_OWNED = 'E_ITEM_NOT_OWNED',
|
|
403
|
+
E_BILLING_UNAVAILABLE = 'E_BILLING_UNAVAILABLE',
|
|
404
|
+
E_FEATURE_NOT_SUPPORTED = 'E_FEATURE_NOT_SUPPORTED',
|
|
405
|
+
E_EMPTY_SKU_LIST = 'E_EMPTY_SKU_LIST',
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export type PurchaseResult = {
|
|
409
|
+
responseCode?: number
|
|
410
|
+
debugMessage?: string
|
|
411
|
+
code?: string
|
|
412
|
+
message?: string
|
|
413
|
+
/**
|
|
414
|
+
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
415
|
+
*/
|
|
416
|
+
purchaseTokenAndroid?: string
|
|
417
|
+
purchaseToken?: string
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Additional iOS types
|
|
421
|
+
export type PaymentDiscount = {
|
|
422
|
+
identifier: string
|
|
423
|
+
keyIdentifier: string
|
|
424
|
+
nonce: string
|
|
425
|
+
signature: string
|
|
426
|
+
timestamp: number
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export type AppTransactionIOS = {
|
|
430
|
+
appTransactionId?: string
|
|
431
|
+
originalPlatform?: string
|
|
432
|
+
bundleId: string
|
|
433
|
+
appVersion: string
|
|
434
|
+
originalAppVersion: string
|
|
435
|
+
originalPurchaseDate: number
|
|
436
|
+
deviceVerification: string
|
|
437
|
+
deviceVerificationNonce: string
|
|
438
|
+
environment: string
|
|
439
|
+
signedDate: number
|
|
440
|
+
appId?: number
|
|
441
|
+
appVersionId?: number
|
|
442
|
+
preorderDate?: number
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// ============================================================================
|
|
446
|
+
// METHOD OPTIONS TYPES
|
|
447
|
+
// ============================================================================
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Options for getAvailablePurchases methods
|
|
451
|
+
*/
|
|
452
|
+
export interface PurchaseOptions {
|
|
453
|
+
/**
|
|
454
|
+
* @deprecated Use alsoPublishToEventListenerIOS instead
|
|
455
|
+
* Whether to also publish purchases to event listener (iOS only)
|
|
456
|
+
*/
|
|
457
|
+
alsoPublishToEventListener?: boolean
|
|
458
|
+
/**
|
|
459
|
+
* @deprecated Use onlyIncludeActiveItemsIOS instead
|
|
460
|
+
* Whether to only include active items (iOS only)
|
|
461
|
+
*/
|
|
462
|
+
onlyIncludeActiveItems?: boolean
|
|
463
|
+
/** Whether to also publish purchases to event listener (iOS only) */
|
|
464
|
+
alsoPublishToEventListenerIOS?: boolean
|
|
465
|
+
/** Whether to only include active items (subscriptions that are still active) (iOS only) */
|
|
466
|
+
onlyIncludeActiveItemsIOS?: boolean
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Parameters for finishTransaction method
|
|
471
|
+
*/
|
|
472
|
+
export interface FinishTransactionParams {
|
|
473
|
+
/** The purchase to finish/consume */
|
|
474
|
+
purchase: Purchase
|
|
475
|
+
/**
|
|
476
|
+
* Whether this is a consumable product that should be consumed.
|
|
477
|
+
* - Set to true for consumable products (e.g., "20 credits", "100 coins")
|
|
478
|
+
* - Set to false (or omit) for non-consumable products (e.g., "remove ads", "premium features")
|
|
479
|
+
* - Do NOT set to true for subscriptions - they are managed automatically
|
|
480
|
+
* Note: On iOS, this flag doesn't affect behavior as StoreKit handles this automatically.
|
|
481
|
+
* On Android, consumables must be consumed to allow repurchase.
|
|
482
|
+
*/
|
|
483
|
+
isConsumable?: boolean
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ============================================================================
|
|
487
|
+
// IAP CONTEXT INTERFACE
|
|
488
|
+
// ============================================================================
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Main IAP context interface providing all in-app purchase functionality
|
|
492
|
+
*/
|
|
493
|
+
export interface IapContext {
|
|
494
|
+
/** Current list of available products */
|
|
495
|
+
products: Product[]
|
|
496
|
+
/** Current list of available subscription products */
|
|
497
|
+
subscriptions: SubscriptionProduct[]
|
|
498
|
+
/**
|
|
499
|
+
* List of available purchases (includes all types):
|
|
500
|
+
* - Consumables: Not yet consumed/finished
|
|
501
|
+
* - Non-consumables: Not yet finished
|
|
502
|
+
* - Subscriptions: Currently active
|
|
503
|
+
*/
|
|
504
|
+
availablePurchases: Purchase[]
|
|
505
|
+
/** Currently promoted product (iOS only) */
|
|
506
|
+
promotedProduct?: Product
|
|
507
|
+
/** Current purchase being processed */
|
|
508
|
+
currentPurchase?: Purchase
|
|
509
|
+
/** Purchase error if any */
|
|
510
|
+
purchaseError?: PurchaseError
|
|
511
|
+
|
|
512
|
+
// Connection methods
|
|
513
|
+
/** Initialize connection to the store */
|
|
514
|
+
initConnection(): Promise<boolean>
|
|
515
|
+
/** End connection to the store */
|
|
516
|
+
endConnection(): Promise<void>
|
|
517
|
+
/** Sync purchases (iOS only) */
|
|
518
|
+
sync(): Promise<void>
|
|
519
|
+
|
|
520
|
+
// Product methods
|
|
521
|
+
/**
|
|
522
|
+
* Fetch products from the store
|
|
523
|
+
* @param params.skus - Array of product SKUs to fetch
|
|
524
|
+
* @param params.type - Type of products: 'inapp' for regular products or 'subs' for subscriptions
|
|
525
|
+
*/
|
|
526
|
+
fetchProducts(params: {
|
|
527
|
+
skus: string[]
|
|
528
|
+
type?: ProductType // 'inapp' | 'subs', defaults to 'inapp'
|
|
529
|
+
}): Promise<Product[] | SubscriptionProduct[]>
|
|
530
|
+
|
|
531
|
+
// Purchase methods
|
|
532
|
+
/**
|
|
533
|
+
* Request a purchase for products or subscriptions
|
|
534
|
+
* @param params.request - Platform-specific purchase parameters
|
|
535
|
+
* @param params.type - Type of purchase: 'inapp' for products or 'subs' for subscriptions
|
|
536
|
+
*/
|
|
537
|
+
requestPurchase(params: {
|
|
538
|
+
request: RequestPurchaseProps | RequestSubscriptionProps
|
|
539
|
+
type?: 'inapp' | 'subs' // defaults to 'inapp'
|
|
540
|
+
}): Promise<Purchase | Purchase[] | void>
|
|
541
|
+
/**
|
|
542
|
+
* Finish a transaction and consume if applicable.
|
|
543
|
+
* IMPORTANT: Every purchase must be finished to complete the transaction.
|
|
544
|
+
* - For consumables: Set isConsumable=true to allow repurchase
|
|
545
|
+
* - For non-consumables & subscriptions: Set isConsumable=false or omit
|
|
546
|
+
*/
|
|
547
|
+
finishTransaction(
|
|
548
|
+
params: FinishTransactionParams
|
|
549
|
+
): Promise<PurchaseResult | boolean>
|
|
550
|
+
|
|
551
|
+
// Purchase history methods
|
|
552
|
+
/**
|
|
553
|
+
* Get all available purchases for the current user.
|
|
554
|
+
* Returns:
|
|
555
|
+
* - Consumables that haven't been consumed (finished with isConsumable=true)
|
|
556
|
+
* - Non-consumables that haven't been finished
|
|
557
|
+
* - Active subscriptions
|
|
558
|
+
*/
|
|
559
|
+
getAvailablePurchases(options?: PurchaseOptions): Promise<Purchase[]>
|
|
560
|
+
|
|
561
|
+
// Receipt validation
|
|
562
|
+
/** Validate a receipt (server-side validation recommended) */
|
|
563
|
+
validateReceipt(
|
|
564
|
+
options: ValidateReceiptProps
|
|
565
|
+
): Promise<ReceiptValidationResult>
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Purchase error type
|
|
570
|
+
*/
|
|
571
|
+
export interface PurchaseError {
|
|
572
|
+
/** Error code constant */
|
|
573
|
+
code: string
|
|
574
|
+
/** Human-readable error message */
|
|
575
|
+
message: string
|
|
576
|
+
/** Related product SKU */
|
|
577
|
+
productId?: string
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Validation options for receipt validation
|
|
582
|
+
*/
|
|
583
|
+
export interface ValidateReceiptProps {
|
|
584
|
+
/** Product SKU to validate */
|
|
585
|
+
sku: string
|
|
586
|
+
/** Android-specific validation options */
|
|
587
|
+
androidOptions?: {
|
|
588
|
+
packageName: string
|
|
589
|
+
productToken: string
|
|
590
|
+
accessToken: string
|
|
591
|
+
isSub?: boolean
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* iOS receipt validation result
|
|
597
|
+
*/
|
|
598
|
+
export interface ReceiptIOS {
|
|
599
|
+
/** Whether the receipt is valid */
|
|
600
|
+
isValid: boolean
|
|
601
|
+
/** Receipt data string */
|
|
602
|
+
receiptData: string
|
|
603
|
+
/** JWS representation */
|
|
604
|
+
jwsRepresentation: string
|
|
605
|
+
/** Latest transaction if available */
|
|
606
|
+
latestTransaction?: Purchase
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Android receipt validation result
|
|
611
|
+
*/
|
|
612
|
+
export interface ReceiptAndroid {
|
|
613
|
+
/** Whether the receipt is valid */
|
|
614
|
+
isValid: boolean
|
|
615
|
+
/** Receipt data string */
|
|
616
|
+
receiptData: string
|
|
617
|
+
/** JWS representation */
|
|
618
|
+
jwsRepresentation: string
|
|
619
|
+
/** Latest transaction if available */
|
|
620
|
+
latestTransaction?: Purchase
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Receipt validation result from receipt validation
|
|
625
|
+
*/
|
|
626
|
+
export type ReceiptValidationResult = ReceiptAndroid | ReceiptIOS
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* New iOS receipt validation result (matches user specification)
|
|
630
|
+
*/
|
|
631
|
+
export interface ReceiptValidationResultIOS {
|
|
632
|
+
isValid: boolean
|
|
633
|
+
receiptData: string
|
|
634
|
+
jwsRepresentation: string
|
|
635
|
+
latestTransaction?: Purchase
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* New Android receipt validation result (matches user specification)
|
|
640
|
+
*/
|
|
641
|
+
export interface ReceiptValidationResultAndroid {
|
|
642
|
+
autoRenewing: boolean
|
|
643
|
+
betaProduct: boolean
|
|
644
|
+
cancelDate: number | null
|
|
645
|
+
cancelReason: string
|
|
646
|
+
deferredDate: number | null
|
|
647
|
+
deferredSku: number | null
|
|
648
|
+
freeTrialEndDate: number
|
|
649
|
+
gracePeriodEndDate: number
|
|
650
|
+
parentProductId: string
|
|
651
|
+
productId: string
|
|
652
|
+
productType: string
|
|
653
|
+
purchaseDate: number
|
|
654
|
+
quantity: number
|
|
655
|
+
receiptId: string
|
|
656
|
+
renewalDate: number
|
|
657
|
+
term: string
|
|
658
|
+
termSku: string
|
|
659
|
+
testTransaction: boolean
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Represents an active subscription with platform-specific details
|
|
664
|
+
*/
|
|
665
|
+
export interface ActiveSubscription {
|
|
666
|
+
/** Product identifier (SKU) of the subscription */
|
|
667
|
+
productId: string
|
|
668
|
+
/** Whether the subscription is currently active */
|
|
669
|
+
isActive: boolean
|
|
670
|
+
/** iOS: Subscription expiration date */
|
|
671
|
+
expirationDateIOS?: Date
|
|
672
|
+
/** Android: Whether the subscription auto-renews */
|
|
673
|
+
autoRenewingAndroid?: boolean
|
|
674
|
+
/** iOS: Environment where the subscription was purchased (Production/Sandbox) */
|
|
675
|
+
environmentIOS?: string
|
|
676
|
+
/** Whether the subscription will expire soon (typically within 7 days) */
|
|
677
|
+
willExpireSoon?: boolean
|
|
678
|
+
/** iOS: Number of days until the subscription expires */
|
|
679
|
+
daysUntilExpirationIOS?: number
|
|
680
|
+
}
|