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/modules/ios.ts
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import {Linking, NativeModules} from 'react-native';
|
|
2
|
-
import type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';
|
|
3
|
-
|
|
4
|
-
import {getIosModule, isIosStorekit2} from '../internal';
|
|
5
|
-
const {RNIapIos} = NativeModules;
|
|
6
|
-
import type {
|
|
7
|
-
ProductIOS,
|
|
8
|
-
ProductPurchase,
|
|
9
|
-
Purchase,
|
|
10
|
-
Sku,
|
|
11
|
-
SubscriptionIOS,
|
|
12
|
-
} from '../types';
|
|
13
|
-
import type {PaymentDiscount} from '../types/apple';
|
|
14
|
-
|
|
15
|
-
import type {NativeModuleProps} from './common';
|
|
16
|
-
|
|
17
|
-
type getItems = (skus: Sku[]) => Promise<ProductIOS[] | SubscriptionIOS[]>;
|
|
18
|
-
|
|
19
|
-
type getAvailableItems = (
|
|
20
|
-
automaticallyFinishRestoredTransactions: boolean,
|
|
21
|
-
) => Promise<Purchase[]>;
|
|
22
|
-
|
|
23
|
-
export type BuyProduct = (
|
|
24
|
-
sku: Sku,
|
|
25
|
-
andDangerouslyFinishTransactionAutomaticallyIOS: boolean,
|
|
26
|
-
applicationUsername: string | undefined,
|
|
27
|
-
quantity: number,
|
|
28
|
-
withOffer: Record<keyof PaymentDiscount, string> | undefined,
|
|
29
|
-
) => Promise<Purchase>;
|
|
30
|
-
|
|
31
|
-
type clearTransaction = () => Promise<void>;
|
|
32
|
-
type clearProducts = () => Promise<void>;
|
|
33
|
-
type promotedProduct = () => Promise<ProductIOS | null>;
|
|
34
|
-
type buyPromotedProduct = () => Promise<void>;
|
|
35
|
-
type requestReceipt = (refresh: boolean) => Promise<string | undefined | null>;
|
|
36
|
-
|
|
37
|
-
type finishTransaction = (transactionIdentifier: string) => Promise<boolean>;
|
|
38
|
-
|
|
39
|
-
type getPendingTransactions = () => Promise<ProductPurchase[]>;
|
|
40
|
-
type presentCodeRedemptionSheet = () => Promise<null>;
|
|
41
|
-
|
|
42
|
-
export interface IosModuleProps extends NativeModuleProps {
|
|
43
|
-
getItems: getItems;
|
|
44
|
-
getAvailableItems: getAvailableItems;
|
|
45
|
-
buyProduct: BuyProduct;
|
|
46
|
-
clearTransaction: clearTransaction;
|
|
47
|
-
clearProducts: clearProducts;
|
|
48
|
-
promotedProduct: promotedProduct;
|
|
49
|
-
buyPromotedProduct: buyPromotedProduct;
|
|
50
|
-
requestReceipt: requestReceipt;
|
|
51
|
-
finishTransaction: finishTransaction;
|
|
52
|
-
getPendingTransactions: getPendingTransactions;
|
|
53
|
-
presentCodeRedemptionSheet: presentCodeRedemptionSheet;
|
|
54
|
-
disable: () => Promise<null>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get the current receipt base64 encoded in IOS.
|
|
59
|
-
* @returns {Promise<ProductPurchase[]>}
|
|
60
|
-
*/
|
|
61
|
-
export const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>
|
|
62
|
-
getIosModule().getPendingTransactions();
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Get the current receipt base64 encoded in IOS.
|
|
66
|
-
*
|
|
67
|
-
* The sequence should be as follows:
|
|
68
|
-
* Call getReceiptIOS({forceRefresh: false}). That will return the cached receipt that is available on TestFlight and Production.
|
|
69
|
-
* In the case of Sandbox the receipt might not be cached, causing it to return nil.
|
|
70
|
-
* In that case you might want to let the user that they will to be prompted for credentials.
|
|
71
|
-
* If they accept, call it again with `getReceiptIOS({forceRefresh:true}) If it fails or the user declines, assume they haven't purchased any items.
|
|
72
|
-
* Reference: https://developer.apple.com/forums/thread/662350
|
|
73
|
-
*
|
|
74
|
-
* From: https://apphud.com/blog/app-store-receipt-validation#what-is-app-store-receipt
|
|
75
|
-
> Q: Does a receipt always exist in the app?
|
|
76
|
-
> A: If a user downloaded the app from the App Store – yes. However, in sandbox if your app was installed via Xcode or Testflight, then there won't be a receipt until you make a purchase or restore.
|
|
77
|
-
*
|
|
78
|
-
## Usage
|
|
79
|
-
```tsx
|
|
80
|
-
import {getReceiptIOS} from 'react-native-iap';
|
|
81
|
-
try{
|
|
82
|
-
let receipt = await getReceiptIOS({forceRefresh: false});
|
|
83
|
-
if(!receipt){
|
|
84
|
-
// Let user know that they might get prompted for credentials
|
|
85
|
-
const shouldShowPrompt = // Display UI with details, Did user agree?. this only for Sandbox testing
|
|
86
|
-
if(shouldShowPrompt){
|
|
87
|
-
receipt = await getReceiptIOS({forceRefresh: true});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}catch(error:Error){
|
|
91
|
-
// error while getting the receipt, it might indicate an invalid receipt of a connection error while trying to get it
|
|
92
|
-
}
|
|
93
|
-
// If !receipt assume user doesn't own the items
|
|
94
|
-
```
|
|
95
|
-
* @param {forceRefresh?:boolean} Requests the receipt from Bundle.main.appStoreReceiptURL.
|
|
96
|
-
Based on the note above, looks like forceRefresh only makes sense when testing an app not downloaded from the Appstore.
|
|
97
|
-
And only afer a direct user action.
|
|
98
|
-
* @returns {Promise<string | undefined | null>} The receipt data
|
|
99
|
-
*/
|
|
100
|
-
export const getReceiptIOS = async ({
|
|
101
|
-
forceRefresh,
|
|
102
|
-
}: {
|
|
103
|
-
forceRefresh?: boolean;
|
|
104
|
-
}): Promise<string | undefined | null> => {
|
|
105
|
-
if (!isIosStorekit2()) {
|
|
106
|
-
return RNIapIos.requestReceipt(forceRefresh ?? false);
|
|
107
|
-
} else {
|
|
108
|
-
return Promise.reject('Only available on Sk1');
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Launches a modal to register the redeem offer code in IOS.
|
|
113
|
-
* @returns {Promise<null>}
|
|
114
|
-
*/
|
|
115
|
-
export const presentCodeRedemptionSheetIOS = async (): Promise<null> =>
|
|
116
|
-
getIosModule().presentCodeRedemptionSheet();
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Should Add Store Payment (iOS only)
|
|
120
|
-
* Indicates the the App Store purchase should continue from the app instead of the App Store.
|
|
121
|
-
* @returns {Promise<Product | null>} promoted product
|
|
122
|
-
*/
|
|
123
|
-
export const getPromotedProductIOS = (): Promise<ProductIOS | null> => {
|
|
124
|
-
if (!isIosStorekit2()) {
|
|
125
|
-
return RNIapIos.promotedProduct();
|
|
126
|
-
} else {
|
|
127
|
-
return Promise.reject('Only available on Sk1');
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Buy the currently selected promoted product (iOS only)
|
|
133
|
-
* Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.
|
|
134
|
-
* @returns {Promise<void>}
|
|
135
|
-
*/
|
|
136
|
-
export const buyPromotedProductIOS = (): Promise<void> =>
|
|
137
|
-
getIosModule().buyPromotedProduct();
|
|
138
|
-
|
|
139
|
-
const fetchJsonOrThrow = async (
|
|
140
|
-
url: string,
|
|
141
|
-
receiptBody: Record<string, unknown>,
|
|
142
|
-
): Promise<ReceiptValidationResponse | false> => {
|
|
143
|
-
const response = await fetch(url, {
|
|
144
|
-
method: 'POST',
|
|
145
|
-
headers: {
|
|
146
|
-
Accept: 'application/json',
|
|
147
|
-
'Content-Type': 'application/json',
|
|
148
|
-
},
|
|
149
|
-
body: JSON.stringify(receiptBody),
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
if (!response.ok) {
|
|
153
|
-
throw Object.assign(new Error(response.statusText), {
|
|
154
|
-
statusCode: response.status,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return response.json();
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const TEST_RECEIPT = 21007;
|
|
162
|
-
const requestAgnosticReceiptValidationIos = async (
|
|
163
|
-
receiptBody: Record<string, unknown>,
|
|
164
|
-
): Promise<ReceiptValidationResponse | false> => {
|
|
165
|
-
const response = await fetchJsonOrThrow(
|
|
166
|
-
'https://buy.itunes.apple.com/verifyReceipt',
|
|
167
|
-
receiptBody,
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
// Best practice is to check for test receipt and check sandbox instead
|
|
171
|
-
// https://developer.apple.com/documentation/appstorereceipts/verifyreceipt
|
|
172
|
-
if (response && response.status === TEST_RECEIPT) {
|
|
173
|
-
const testResponse = await fetchJsonOrThrow(
|
|
174
|
-
'https://sandbox.itunes.apple.com/verifyReceipt',
|
|
175
|
-
receiptBody,
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
return testResponse;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return response;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Validate receipt for iOS.
|
|
186
|
-
* @param {object} receiptBody the receipt body to send to apple server.
|
|
187
|
-
* @param {boolean} isTest whether this is in test environment which is sandbox.
|
|
188
|
-
* @returns {Promise<Apple.ReceiptValidationResponse | false>}
|
|
189
|
-
*/
|
|
190
|
-
export const validateReceiptIos = async ({
|
|
191
|
-
receiptBody,
|
|
192
|
-
isTest,
|
|
193
|
-
}: {
|
|
194
|
-
receiptBody: Record<string, unknown>;
|
|
195
|
-
isTest?: boolean;
|
|
196
|
-
}): Promise<ReceiptValidationResponse | false> => {
|
|
197
|
-
if (isTest == null) {
|
|
198
|
-
return await requestAgnosticReceiptValidationIos(receiptBody);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const url = isTest
|
|
202
|
-
? 'https://sandbox.itunes.apple.com/verifyReceipt'
|
|
203
|
-
: 'https://buy.itunes.apple.com/verifyReceipt';
|
|
204
|
-
|
|
205
|
-
const response = await fetchJsonOrThrow(url, receiptBody);
|
|
206
|
-
|
|
207
|
-
return response;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Clear Transaction (iOS only)
|
|
212
|
-
* Finish remaining transactions. Related to issue #257 and #801
|
|
213
|
-
* link : https://github.com/hyochan/react-native-iap/issues/257
|
|
214
|
-
* https://github.com/hyochan/react-native-iap/issues/801
|
|
215
|
-
* @returns {Promise<void>}
|
|
216
|
-
*/
|
|
217
|
-
export const clearTransactionIOS = (): Promise<void> =>
|
|
218
|
-
getIosModule().clearTransaction();
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Clear valid Products (iOS only)
|
|
222
|
-
* Remove all products which are validated by Apple server.
|
|
223
|
-
* @returns {void}
|
|
224
|
-
*/
|
|
225
|
-
export const clearProductsIOS = (): Promise<void> =>
|
|
226
|
-
getIosModule().clearProducts();
|
|
227
|
-
|
|
228
|
-
export const deepLinkToSubscriptionsIos = (): Promise<void> =>
|
|
229
|
-
Linking.openURL('https://apps.apple.com/account/subscriptions');
|
package/src/modules/iosSk2.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import {NativeModules} from 'react-native';
|
|
2
|
-
|
|
3
|
-
import type {Product, ProductPurchase, Sku} from '../types';
|
|
4
|
-
import type {
|
|
5
|
-
PaymentDiscountSk2,
|
|
6
|
-
ProductSk2,
|
|
7
|
-
ProductStatus,
|
|
8
|
-
RefundRequestStatus,
|
|
9
|
-
TransactionSk2,
|
|
10
|
-
} from '../types/appleSk2';
|
|
11
|
-
|
|
12
|
-
import type {NativeModuleProps} from './common';
|
|
13
|
-
const {RNIapIosSk2} = NativeModules;
|
|
14
|
-
|
|
15
|
-
type getItems = (skus: Sku[]) => Promise<ProductSk2[]>;
|
|
16
|
-
|
|
17
|
-
type getAvailableItems = (
|
|
18
|
-
alsoPublishToEventListener?: boolean,
|
|
19
|
-
onlyIncludeActiveItems?: boolean,
|
|
20
|
-
) => Promise<TransactionSk2[]>;
|
|
21
|
-
|
|
22
|
-
export type BuyProduct = (
|
|
23
|
-
sku: Sku,
|
|
24
|
-
andDangerouslyFinishTransactionAutomaticallyIOS: boolean,
|
|
25
|
-
applicationUsername: string | undefined,
|
|
26
|
-
quantity: number,
|
|
27
|
-
withOffer: Record<keyof PaymentDiscountSk2, string> | undefined,
|
|
28
|
-
) => Promise<TransactionSk2>;
|
|
29
|
-
|
|
30
|
-
type clearTransaction = () => Promise<void>;
|
|
31
|
-
type clearProducts = () => Promise<void>;
|
|
32
|
-
type promotedProduct = () => Promise<Product | null>;
|
|
33
|
-
type buyPromotedProduct = () => Promise<void>;
|
|
34
|
-
|
|
35
|
-
type finishTransaction = (transactionIdentifier: string) => Promise<boolean>;
|
|
36
|
-
|
|
37
|
-
type getPendingTransactions = () => Promise<ProductPurchase[]>;
|
|
38
|
-
type presentCodeRedemptionSheet = () => Promise<null>;
|
|
39
|
-
type showManageSubscriptions = () => Promise<null>;
|
|
40
|
-
type getStorefront = () => Promise<string>;
|
|
41
|
-
|
|
42
|
-
type getAppTransaction = () => Promise<{
|
|
43
|
-
appTransactionID: string;
|
|
44
|
-
originalAppVersion: string;
|
|
45
|
-
originalPurchaseDate: number;
|
|
46
|
-
deviceVerification: string;
|
|
47
|
-
deviceVerificationNonce: string;
|
|
48
|
-
appVersion: string;
|
|
49
|
-
signedDate: number;
|
|
50
|
-
environment: string;
|
|
51
|
-
}>;
|
|
52
|
-
|
|
53
|
-
export interface IosModulePropsSk2 extends NativeModuleProps {
|
|
54
|
-
isAvailable(): number;
|
|
55
|
-
latestTransaction(sku: string): Promise<TransactionSk2>;
|
|
56
|
-
currentEntitlement(sku: string): Promise<TransactionSk2>;
|
|
57
|
-
subscriptionStatus(sku: string): Promise<ProductStatus[]>;
|
|
58
|
-
isEligibleForIntroOffer(groupID: string): Promise<Boolean>;
|
|
59
|
-
sync(): Promise<null>;
|
|
60
|
-
getItems: getItems;
|
|
61
|
-
getAvailableItems: getAvailableItems;
|
|
62
|
-
buyProduct: BuyProduct;
|
|
63
|
-
clearTransaction: clearTransaction;
|
|
64
|
-
clearProducts: clearProducts;
|
|
65
|
-
promotedProduct: promotedProduct;
|
|
66
|
-
buyPromotedProduct: buyPromotedProduct;
|
|
67
|
-
finishTransaction: finishTransaction;
|
|
68
|
-
getPendingTransactions: getPendingTransactions;
|
|
69
|
-
presentCodeRedemptionSheet: presentCodeRedemptionSheet;
|
|
70
|
-
showManageSubscriptions: showManageSubscriptions;
|
|
71
|
-
disable: () => Promise<null>;
|
|
72
|
-
beginRefundRequest: (sku: string) => Promise<RefundRequestStatus>;
|
|
73
|
-
getStorefront: getStorefront;
|
|
74
|
-
getAppTransaction: getAppTransaction;
|
|
75
|
-
getReceiptData: () => Promise<string>;
|
|
76
|
-
isTransactionVerified: (sku: string) => Promise<boolean>;
|
|
77
|
-
getTransactionJws: (sku: string) => Promise<string>;
|
|
78
|
-
validateReceiptIos: (sku: string) => Promise<{
|
|
79
|
-
isValid: boolean;
|
|
80
|
-
receiptData: string;
|
|
81
|
-
jwsRepresentation: string;
|
|
82
|
-
latestTransaction?: TransactionSk2;
|
|
83
|
-
}>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Sync state with Appstore (iOS only)
|
|
88
|
-
* https://developer.apple.com/documentation/storekit/appstore/3791906-sync
|
|
89
|
-
*/
|
|
90
|
-
export const sync = (): Promise<null> => RNIapIosSk2.sync();
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
export const isEligibleForIntroOffer = (groupID: string): Promise<Boolean> =>
|
|
96
|
-
RNIapIosSk2.isEligibleForIntroOffer(groupID);
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
export const subscriptionStatus = (sku: string): Promise<ProductStatus[]> =>
|
|
103
|
-
RNIapIosSk2.subscriptionStatus(sku);
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
export const currentEntitlement = (sku: string): Promise<TransactionSk2> =>
|
|
109
|
-
RNIapIosSk2.currentEntitlement(sku);
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
*
|
|
113
|
-
*/
|
|
114
|
-
export const latestTransaction = (sku: string): Promise<TransactionSk2> =>
|
|
115
|
-
RNIapIosSk2.latestTransaction(sku);
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
*
|
|
119
|
-
*/
|
|
120
|
-
export const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>
|
|
121
|
-
RNIapIosSk2.beginRefundRequest(sku);
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
*/
|
|
126
|
-
export const showManageSubscriptions = (): Promise<null> =>
|
|
127
|
-
RNIapIosSk2.showManageSubscriptions();
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
*
|
|
131
|
-
*/
|
|
132
|
-
export const finishTransaction = (
|
|
133
|
-
transactionIdentifier: string,
|
|
134
|
-
): Promise<Boolean> => RNIapIosSk2.finishTransaction(transactionIdentifier);
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Get the receipt data from the iOS device.
|
|
138
|
-
* This returns the base64 encoded receipt data which can be sent to your server
|
|
139
|
-
* for verification with Apple's server.
|
|
140
|
-
*
|
|
141
|
-
* NOTE: For proper security, always verify receipts on your server using
|
|
142
|
-
* Apple's verifyReceipt endpoint, not directly from the app.
|
|
143
|
-
*
|
|
144
|
-
* @returns {Promise<string>} Base64 encoded receipt data
|
|
145
|
-
*/
|
|
146
|
-
export const getReceiptIos = (): Promise<string> =>
|
|
147
|
-
RNIapIosSk2.getReceiptData();
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Check if a transaction is verified through StoreKit 2.
|
|
151
|
-
* StoreKit 2 performs local verification of transaction JWS signatures.
|
|
152
|
-
*
|
|
153
|
-
* @param {string} sku The product's SKU (on iOS)
|
|
154
|
-
* @returns {Promise<boolean>} True if the transaction is verified
|
|
155
|
-
*/
|
|
156
|
-
export const isTransactionVerified = (sku: string): Promise<boolean> =>
|
|
157
|
-
RNIapIosSk2.isTransactionVerified(sku);
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Get the JWS representation of a purchase for server-side verification.
|
|
161
|
-
* The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.
|
|
162
|
-
*
|
|
163
|
-
* @param {string} sku The product's SKU (on iOS)
|
|
164
|
-
* @returns {Promise<string>} JWS representation of the transaction
|
|
165
|
-
*/
|
|
166
|
-
export const getTransactionJws = (sku: string): Promise<string> =>
|
|
167
|
-
RNIapIosSk2.getTransactionJws(sku);
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Validate receipt for iOS using StoreKit 2's built-in verification.
|
|
171
|
-
* Returns receipt data and verification information to help with server-side validation.
|
|
172
|
-
*
|
|
173
|
-
* NOTE: For proper security, Apple recommends verifying receipts on your server using
|
|
174
|
-
* the verifyReceipt endpoint rather than relying solely on client-side verification.
|
|
175
|
-
*
|
|
176
|
-
* @param {string} sku The product's SKU (on iOS)
|
|
177
|
-
* @returns {Promise<{
|
|
178
|
-
* isValid: boolean;
|
|
179
|
-
* receiptData: string;
|
|
180
|
-
* jwsRepresentation: string;
|
|
181
|
-
* latestTransaction?: TransactionSk2;
|
|
182
|
-
* }>}
|
|
183
|
-
*/
|
|
184
|
-
export const validateReceiptIos = async (
|
|
185
|
-
sku: string,
|
|
186
|
-
): Promise<{
|
|
187
|
-
isValid: boolean;
|
|
188
|
-
receiptData: string;
|
|
189
|
-
jwsRepresentation: string;
|
|
190
|
-
latestTransaction?: TransactionSk2;
|
|
191
|
-
}> => {
|
|
192
|
-
const result = await RNIapIosSk2.validateReceiptIos(sku);
|
|
193
|
-
return result;
|
|
194
|
-
};
|
package/src/purchaseError.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
export enum ErrorCode {
|
|
2
|
-
E_UNKNOWN = 'E_UNKNOWN',
|
|
3
|
-
E_USER_CANCELLED = 'E_USER_CANCELLED',
|
|
4
|
-
E_USER_ERROR = 'E_USER_ERROR',
|
|
5
|
-
E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',
|
|
6
|
-
E_REMOTE_ERROR = 'E_REMOTE_ERROR',
|
|
7
|
-
E_NETWORK_ERROR = 'E_NETWORK_ERROR',
|
|
8
|
-
E_SERVICE_ERROR = 'E_SERVICE_ERROR',
|
|
9
|
-
E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',
|
|
10
|
-
E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',
|
|
11
|
-
E_NOT_PREPARED = 'E_NOT_PREPARED',
|
|
12
|
-
E_NOT_ENDED = 'E_NOT_ENDED',
|
|
13
|
-
E_ALREADY_OWNED = 'E_ALREADY_OWNED',
|
|
14
|
-
E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',
|
|
15
|
-
E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
16
|
-
E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',
|
|
17
|
-
E_INTERRUPTED = 'E_INTERRUPTED',
|
|
18
|
-
E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',
|
|
19
|
-
E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',
|
|
20
|
-
E_SYNC_ERROR = 'E_SYNC_ERROR',
|
|
21
|
-
E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',
|
|
22
|
-
E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',
|
|
23
|
-
E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',
|
|
24
|
-
E_PENDING = 'E_PENDING',
|
|
25
|
-
E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Platform-specific error code mappings
|
|
30
|
-
* Maps ErrorCode enum values to platform-specific integer codes
|
|
31
|
-
*/
|
|
32
|
-
export const ErrorCodeMapping = {
|
|
33
|
-
ios: {
|
|
34
|
-
[ErrorCode.E_UNKNOWN]: 0,
|
|
35
|
-
[ErrorCode.E_SERVICE_ERROR]: 1,
|
|
36
|
-
[ErrorCode.E_USER_CANCELLED]: 2,
|
|
37
|
-
[ErrorCode.E_USER_ERROR]: 3,
|
|
38
|
-
[ErrorCode.E_ITEM_UNAVAILABLE]: 4,
|
|
39
|
-
[ErrorCode.E_REMOTE_ERROR]: 5,
|
|
40
|
-
[ErrorCode.E_NETWORK_ERROR]: 6,
|
|
41
|
-
[ErrorCode.E_RECEIPT_FAILED]: 7,
|
|
42
|
-
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,
|
|
43
|
-
[ErrorCode.E_DEVELOPER_ERROR]: 9,
|
|
44
|
-
[ErrorCode.E_PURCHASE_ERROR]: 10,
|
|
45
|
-
[ErrorCode.E_SYNC_ERROR]: 11,
|
|
46
|
-
[ErrorCode.E_DEFERRED_PAYMENT]: 12,
|
|
47
|
-
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,
|
|
48
|
-
[ErrorCode.E_NOT_PREPARED]: 14,
|
|
49
|
-
[ErrorCode.E_NOT_ENDED]: 15,
|
|
50
|
-
[ErrorCode.E_ALREADY_OWNED]: 16,
|
|
51
|
-
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,
|
|
52
|
-
[ErrorCode.E_INTERRUPTED]: 18,
|
|
53
|
-
[ErrorCode.E_IAP_NOT_AVAILABLE]: 19,
|
|
54
|
-
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,
|
|
55
|
-
[ErrorCode.E_ALREADY_PREPARED]: 21,
|
|
56
|
-
[ErrorCode.E_PENDING]: 22,
|
|
57
|
-
[ErrorCode.E_CONNECTION_CLOSED]: 23,
|
|
58
|
-
},
|
|
59
|
-
android: {
|
|
60
|
-
[ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',
|
|
61
|
-
[ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',
|
|
62
|
-
[ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',
|
|
63
|
-
[ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',
|
|
64
|
-
[ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',
|
|
65
|
-
[ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',
|
|
66
|
-
[ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',
|
|
67
|
-
[ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',
|
|
68
|
-
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',
|
|
69
|
-
[ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',
|
|
70
|
-
[ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',
|
|
71
|
-
[ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',
|
|
72
|
-
[ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',
|
|
73
|
-
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:
|
|
74
|
-
'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
75
|
-
[ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',
|
|
76
|
-
[ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',
|
|
77
|
-
[ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',
|
|
78
|
-
[ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',
|
|
79
|
-
[ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',
|
|
80
|
-
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:
|
|
81
|
-
'E_TRANSACTION_VALIDATION_FAILED',
|
|
82
|
-
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',
|
|
83
|
-
[ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',
|
|
84
|
-
[ErrorCode.E_PENDING]: 'E_PENDING',
|
|
85
|
-
[ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',
|
|
86
|
-
},
|
|
87
|
-
} as const;
|
|
88
|
-
|
|
89
|
-
export class PurchaseError implements Error {
|
|
90
|
-
constructor(
|
|
91
|
-
public name: string,
|
|
92
|
-
public message: string,
|
|
93
|
-
public responseCode?: number,
|
|
94
|
-
public debugMessage?: string,
|
|
95
|
-
public code?: ErrorCode,
|
|
96
|
-
public productId?: string,
|
|
97
|
-
public platform?: 'ios' | 'android',
|
|
98
|
-
) {
|
|
99
|
-
this.name = '[react-native-iap]: PurchaseError';
|
|
100
|
-
this.message = message;
|
|
101
|
-
this.responseCode = responseCode;
|
|
102
|
-
this.debugMessage = debugMessage;
|
|
103
|
-
this.code = code;
|
|
104
|
-
this.productId = productId;
|
|
105
|
-
this.platform = platform;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Creates a PurchaseError from platform-specific error data
|
|
110
|
-
* @param errorData Raw error data from native modules
|
|
111
|
-
* @param platform Platform where the error occurred
|
|
112
|
-
* @returns Properly typed PurchaseError instance
|
|
113
|
-
*/
|
|
114
|
-
static fromPlatformError(
|
|
115
|
-
errorData: any,
|
|
116
|
-
platform: 'ios' | 'android',
|
|
117
|
-
): PurchaseError {
|
|
118
|
-
const errorCode = errorData.code
|
|
119
|
-
? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)
|
|
120
|
-
: ErrorCode.E_UNKNOWN;
|
|
121
|
-
|
|
122
|
-
return new PurchaseError(
|
|
123
|
-
'[react-native-iap]: PurchaseError',
|
|
124
|
-
errorData.message || 'Unknown error occurred',
|
|
125
|
-
errorData.responseCode,
|
|
126
|
-
errorData.debugMessage,
|
|
127
|
-
errorCode,
|
|
128
|
-
errorData.productId,
|
|
129
|
-
platform,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Gets the platform-specific error code for this error
|
|
135
|
-
* @returns Platform-specific error code
|
|
136
|
-
*/
|
|
137
|
-
getPlatformCode(): string | number | undefined {
|
|
138
|
-
if (!this.code || !this.platform) return undefined;
|
|
139
|
-
return ErrorCodeUtils.toPlatformCode(this.code, this.platform);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Utility functions for error code mapping and validation
|
|
145
|
-
*/
|
|
146
|
-
export const ErrorCodeUtils = {
|
|
147
|
-
/**
|
|
148
|
-
* Maps a platform-specific error code back to the standardized ErrorCode enum
|
|
149
|
-
* @param platformCode Platform-specific error code (string for Android, number for iOS)
|
|
150
|
-
* @param platform Target platform
|
|
151
|
-
* @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found
|
|
152
|
-
*/
|
|
153
|
-
fromPlatformCode: (
|
|
154
|
-
platformCode: string | number,
|
|
155
|
-
platform: 'ios' | 'android',
|
|
156
|
-
): ErrorCode => {
|
|
157
|
-
const mapping = ErrorCodeMapping[platform];
|
|
158
|
-
|
|
159
|
-
for (const [errorCode, mappedCode] of Object.entries(mapping)) {
|
|
160
|
-
if (mappedCode === platformCode) {
|
|
161
|
-
return errorCode as ErrorCode;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return ErrorCode.E_UNKNOWN;
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Maps an ErrorCode enum to platform-specific code
|
|
170
|
-
* @param errorCode ErrorCode enum value
|
|
171
|
-
* @param platform Target platform
|
|
172
|
-
* @returns Platform-specific error code
|
|
173
|
-
*/
|
|
174
|
-
toPlatformCode: (
|
|
175
|
-
errorCode: ErrorCode,
|
|
176
|
-
platform: 'ios' | 'android',
|
|
177
|
-
): string | number => {
|
|
178
|
-
return (
|
|
179
|
-
ErrorCodeMapping[platform][errorCode] ??
|
|
180
|
-
(platform === 'ios' ? 0 : 'E_UNKNOWN')
|
|
181
|
-
);
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Checks if an error code is valid for the specified platform
|
|
186
|
-
* @param errorCode ErrorCode enum value
|
|
187
|
-
* @param platform Target platform
|
|
188
|
-
* @returns True if the error code is supported on the platform
|
|
189
|
-
*/
|
|
190
|
-
isValidForPlatform: (
|
|
191
|
-
errorCode: ErrorCode,
|
|
192
|
-
platform: 'ios' | 'android',
|
|
193
|
-
): boolean => {
|
|
194
|
-
return errorCode in ErrorCodeMapping[platform];
|
|
195
|
-
},
|
|
196
|
-
};
|
package/src/types/amazon.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export interface UserDataAmazon {
|
|
2
|
-
userIdAmazon?: string;
|
|
3
|
-
userMarketplaceAmazon?: string;
|
|
4
|
-
userJsonAmazon?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface ProductPurchaseAmazon extends UserDataAmazon {
|
|
8
|
-
isCanceledAmazon?: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* From: https://developer.amazon.com/es/docs/in-app-purchasing/iap-rvs-examples.html
|
|
12
|
-
*/
|
|
13
|
-
export type ReceiptType = {
|
|
14
|
-
autoRenewing: boolean;
|
|
15
|
-
betaProduct: boolean;
|
|
16
|
-
cancelDate: number | null;
|
|
17
|
-
cancelReason: string;
|
|
18
|
-
deferredDate: number | null;
|
|
19
|
-
deferredSku: number | null;
|
|
20
|
-
freeTrialEndDate: number;
|
|
21
|
-
gracePeriodEndDate: number;
|
|
22
|
-
parentProductId: string;
|
|
23
|
-
productId: string;
|
|
24
|
-
productType: string;
|
|
25
|
-
purchaseDate: number;
|
|
26
|
-
quantity: number;
|
|
27
|
-
receiptId: string;
|
|
28
|
-
renewalDate: number;
|
|
29
|
-
term: string;
|
|
30
|
-
termSku: string;
|
|
31
|
-
testTransaction: boolean;
|
|
32
|
-
} & Record<string, unknown>;
|
|
33
|
-
|
|
34
|
-
export type AmazonLicensingStatus =
|
|
35
|
-
| 'LICENSED'
|
|
36
|
-
| 'NOT_LICENSED'
|
|
37
|
-
| 'EXPIRED'
|
|
38
|
-
| 'ERROR_VERIFICATION'
|
|
39
|
-
| 'ERROR_INVALID_LICENSING_KEYS'
|
|
40
|
-
| 'UNKNOWN_ERROR';
|