react-native-iap 13.0.4 → 14.0.0-rc.2
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 +144 -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
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package com.dooboolab.rniap
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage
|
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.uimanager.ViewManager
|
|
7
|
-
import java.util.ArrayList
|
|
8
|
-
|
|
9
|
-
class RNIapPackage : ReactPackage {
|
|
10
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> = emptyList()
|
|
11
|
-
|
|
12
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
13
|
-
val modules: MutableList<NativeModule> = ArrayList()
|
|
14
|
-
modules.add(RNIapModule(reactContext))
|
|
15
|
-
return modules
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
package com.dooboolab.rniap
|
|
2
|
-
|
|
3
|
-
import com.amazon.device.iap.model.PurchaseResponse
|
|
4
|
-
import com.amazon.device.iap.model.Receipt
|
|
5
|
-
import com.amazon.device.iap.model.RequestId
|
|
6
|
-
import com.amazon.device.iap.model.UserData
|
|
7
|
-
import com.facebook.react.bridge.Arguments
|
|
8
|
-
import com.facebook.react.bridge.Promise
|
|
9
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
|
-
import com.facebook.react.bridge.WritableMap
|
|
11
|
-
import io.mockk.MockKAnnotations
|
|
12
|
-
import io.mockk.Runs
|
|
13
|
-
import io.mockk.every
|
|
14
|
-
import io.mockk.impl.annotations.MockK
|
|
15
|
-
import io.mockk.impl.annotations.RelaxedMockK
|
|
16
|
-
import io.mockk.just
|
|
17
|
-
import io.mockk.mockk
|
|
18
|
-
import io.mockk.mockkStatic
|
|
19
|
-
import io.mockk.slot
|
|
20
|
-
import io.mockk.spyk
|
|
21
|
-
import io.mockk.verify
|
|
22
|
-
import org.junit.Assert.assertEquals
|
|
23
|
-
import org.junit.Assert.assertNotNull
|
|
24
|
-
import org.junit.Before
|
|
25
|
-
import org.junit.Test
|
|
26
|
-
import java.util.*
|
|
27
|
-
|
|
28
|
-
class RNIapAmazonModuleTest {
|
|
29
|
-
@MockK
|
|
30
|
-
lateinit var context: ReactApplicationContext
|
|
31
|
-
|
|
32
|
-
@RelaxedMockK
|
|
33
|
-
lateinit var purchasingServiceProxy: PurchasingServiceProxy
|
|
34
|
-
|
|
35
|
-
@MockK
|
|
36
|
-
lateinit var eventSender: EventSender
|
|
37
|
-
|
|
38
|
-
private lateinit var listener: RNIapAmazonListener
|
|
39
|
-
|
|
40
|
-
private lateinit var module: RNIapAmazonModule
|
|
41
|
-
|
|
42
|
-
@Before
|
|
43
|
-
fun setUp() {
|
|
44
|
-
MockKAnnotations.init(this, relaxUnitFun = true)
|
|
45
|
-
listener = spyk(RNIapAmazonListener(eventSender, purchasingServiceProxy))
|
|
46
|
-
module = RNIapAmazonModule(context, purchasingServiceProxy, eventSender)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Test
|
|
50
|
-
fun `initConnection should resolve to true if RNIapActivityListener is configured`() {
|
|
51
|
-
every { context.applicationContext } returns mockk()
|
|
52
|
-
|
|
53
|
-
val promise = mockk<Promise>(relaxed = true)
|
|
54
|
-
|
|
55
|
-
verify(exactly = 0) { promise.reject(any(), any<String>()) }
|
|
56
|
-
|
|
57
|
-
RNIapActivityListener.registerActivity(mockk())
|
|
58
|
-
|
|
59
|
-
module.initConnection(promise)
|
|
60
|
-
// should set eventSender and purchase service
|
|
61
|
-
assertNotNull(RNIapActivityListener.amazonListener?.purchasingService)
|
|
62
|
-
assertNotNull(RNIapActivityListener.amazonListener?.eventSender)
|
|
63
|
-
|
|
64
|
-
verify { promise.resolve(true) }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@Test
|
|
68
|
-
fun `initConnection should reject if RNIapActivityListener is not configured`() {
|
|
69
|
-
every { context.applicationContext } returns mockk()
|
|
70
|
-
|
|
71
|
-
val promise = mockk<Promise>(relaxed = true)
|
|
72
|
-
module.initConnection(promise)
|
|
73
|
-
verify(exactly = 0) { promise.reject(any(), any<String>()) }
|
|
74
|
-
verify { promise.reject(PromiseUtils.E_DEVELOPER_ERROR, any(), any<Throwable>()) }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@Test
|
|
78
|
-
fun `Purchase Item`() {
|
|
79
|
-
val purchaseResponse =
|
|
80
|
-
mockk<PurchaseResponse> {
|
|
81
|
-
every { requestId } returns RequestId.fromString("0")
|
|
82
|
-
|
|
83
|
-
every { requestStatus } returns PurchaseResponse.RequestStatus.SUCCESSFUL
|
|
84
|
-
val mReceipt =
|
|
85
|
-
mockk<Receipt>(relaxed = true) {
|
|
86
|
-
every { sku } returns "mySku"
|
|
87
|
-
every { purchaseDate } returns Date()
|
|
88
|
-
every { receiptId } returns "rId"
|
|
89
|
-
}
|
|
90
|
-
every { receipt } returns mReceipt
|
|
91
|
-
val mUserData =
|
|
92
|
-
mockk<UserData>(relaxed = true) {
|
|
93
|
-
every { userId } returns "uid1"
|
|
94
|
-
}
|
|
95
|
-
every { userData } returns mUserData
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
every { eventSender.sendEvent(any(), any()) } just Runs
|
|
99
|
-
|
|
100
|
-
every { purchasingServiceProxy.purchase(any()) } answers {
|
|
101
|
-
listener.onPurchaseResponse(
|
|
102
|
-
purchaseResponse,
|
|
103
|
-
)
|
|
104
|
-
RequestId.fromString("0")
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
val itemsMap =
|
|
108
|
-
mockk<WritableMap>(relaxed = true) {
|
|
109
|
-
every { getString("productId") } returns "mySku"
|
|
110
|
-
}
|
|
111
|
-
mockkStatic(Arguments::class)
|
|
112
|
-
|
|
113
|
-
every { Arguments.createMap() } returns itemsMap
|
|
114
|
-
|
|
115
|
-
val promise = mockk<Promise>(relaxed = true)
|
|
116
|
-
|
|
117
|
-
module.buyItemByType("mySku", "", promise)
|
|
118
|
-
verify(exactly = 0) { promise.reject(any(), any<String>()) }
|
|
119
|
-
val response = slot<WritableMap>()
|
|
120
|
-
verify { promise.resolve(capture(response)) }
|
|
121
|
-
assertEquals("mySku", response.captured.getString("productId"))
|
|
122
|
-
verify { eventSender.sendEvent("purchase-updated", any()) }
|
|
123
|
-
verify(exactly = 0) { purchasingServiceProxy.getPurchaseUpdates(false) }
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// @Test
|
|
127
|
-
// fun `initConnection Play Services not available on device should reject`() {
|
|
128
|
-
// }
|
|
129
|
-
//
|
|
130
|
-
// @Test
|
|
131
|
-
// fun `initConnection start new connection fails`() {
|
|
132
|
-
// }
|
|
133
|
-
//
|
|
134
|
-
// @Test
|
|
135
|
-
// fun `endConnection resolves`() {
|
|
136
|
-
// }
|
|
137
|
-
//
|
|
138
|
-
// @Test
|
|
139
|
-
// fun `flushFailedPurchasesCachedAsPending resolves to false if no pending purchases`() {
|
|
140
|
-
// }
|
|
141
|
-
//
|
|
142
|
-
// @Test
|
|
143
|
-
// fun `flushFailedPurchasesCachedAsPending resolves to true if pending purchases`() {
|
|
144
|
-
// }
|
|
145
|
-
//
|
|
146
|
-
// @Test
|
|
147
|
-
// fun getItemsByType() {
|
|
148
|
-
// }
|
|
149
|
-
//
|
|
150
|
-
// @Test
|
|
151
|
-
// fun getAvailableItemsByType() {
|
|
152
|
-
// }
|
|
153
|
-
//
|
|
154
|
-
// @Test
|
|
155
|
-
// fun getPurchaseHistoryByType() {
|
|
156
|
-
// }
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
// @Test
|
|
160
|
-
// fun acknowledgePurchase() {
|
|
161
|
-
// }
|
|
162
|
-
//
|
|
163
|
-
// @Test
|
|
164
|
-
// fun consumeProduct() {
|
|
165
|
-
// }
|
|
166
|
-
//
|
|
167
|
-
// @Test
|
|
168
|
-
// fun onPurchasesUpdated() {
|
|
169
|
-
// }
|
|
170
|
-
}
|
package/app.plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./plugin/build/withIAP');
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// IapSerializationUtils.swift
|
|
3
|
-
// RNIap
|
|
4
|
-
//
|
|
5
|
-
// Created by Andres Aguilar on 8/18/22.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
import StoreKit
|
|
10
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
11
|
-
func serialize(_ p: Product) -> [String: Any?] {
|
|
12
|
-
return [
|
|
13
|
-
"debugDescription": serializeDebug( p.debugDescription),
|
|
14
|
-
"description": p.description,
|
|
15
|
-
"displayName": p.displayName,
|
|
16
|
-
"displayPrice": p.displayPrice,
|
|
17
|
-
"id": p.id,
|
|
18
|
-
"isFamilyShareable": p.isFamilyShareable,
|
|
19
|
-
"jsonRepresentation": serializeDebug(p.jsonRepresentation),
|
|
20
|
-
"price": p.price,
|
|
21
|
-
"subscription": serialize(p.subscription),
|
|
22
|
-
"type": serialize(p.type),
|
|
23
|
-
"currency": p.priceFormatStyle.currencyCode
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
func serializeDebug (_ d: Data) -> String? {
|
|
28
|
-
#if DEBUG
|
|
29
|
-
return String( decoding: d, as: UTF8.self)
|
|
30
|
-
#else
|
|
31
|
-
return nil
|
|
32
|
-
#endif
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
func serialize (_ d: Data) -> String? {
|
|
36
|
-
return String( decoding: d, as: UTF8.self)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
func serializeDebug (_ s: String) -> String? {
|
|
40
|
-
#if DEBUG
|
|
41
|
-
return s
|
|
42
|
-
#else
|
|
43
|
-
return nil
|
|
44
|
-
#endif
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
func serialize(_ e: Error?) -> [String: Any?]? {
|
|
48
|
-
guard let e = e else {return nil}
|
|
49
|
-
return ["localizedDescription": e.localizedDescription]
|
|
50
|
-
}
|
|
51
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
52
|
-
func serialize(_ si: Product.SubscriptionInfo?) -> [String: Any?]? {
|
|
53
|
-
guard let si = si else {return nil}
|
|
54
|
-
return [
|
|
55
|
-
"introductoryOffer": serialize(si.introductoryOffer),
|
|
56
|
-
"promotionalOffers": si.promotionalOffers.map {(offer: Product.SubscriptionOffer) in serialize(offer)},
|
|
57
|
-
"subscriptionGroupID": si.subscriptionGroupID,
|
|
58
|
-
"subscriptionPeriod": serialize(si.subscriptionPeriod)
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
62
|
-
func serialize(_ sp: Product.SubscriptionPeriod?) -> [String: Any?]? {
|
|
63
|
-
guard let sp = sp else {return nil}
|
|
64
|
-
return ["value": sp.value,
|
|
65
|
-
"unit": serialize(sp.unit)]
|
|
66
|
-
}
|
|
67
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
68
|
-
func serialize(_ sp: Product.SubscriptionPeriod.Unit?) -> String? {
|
|
69
|
-
guard let sp = sp else {return nil}
|
|
70
|
-
switch sp {
|
|
71
|
-
case .day: return "day"
|
|
72
|
-
case .week: return "week"
|
|
73
|
-
case .month: return "month"
|
|
74
|
-
case .year: return "year"
|
|
75
|
-
|
|
76
|
-
default:
|
|
77
|
-
return nil
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
82
|
-
func serialize(_ s: Product.SubscriptionInfo.Status?) -> [String: Any?]? {
|
|
83
|
-
guard let s = s else {return nil}
|
|
84
|
-
return ["state": serialize( s.state),
|
|
85
|
-
"renewalInfo": serialize(s.renewalInfo)
|
|
86
|
-
// "transaction": serialize(s.transaction),
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
91
|
-
func serialize(_ vri: VerificationResult<Product.SubscriptionInfo.RenewalInfo>?) -> [String: Any?]? {
|
|
92
|
-
guard let vri = vri else {return nil}
|
|
93
|
-
do {
|
|
94
|
-
let ri = try vri.payloadValue
|
|
95
|
-
let jsonStringRepresentation = String(data: ri.jsonRepresentation, encoding: .utf8) ?? ""
|
|
96
|
-
return [
|
|
97
|
-
"jsonRepresentation": jsonStringRepresentation,
|
|
98
|
-
"willAutoRenew": ri.willAutoRenew,
|
|
99
|
-
"autoRenewPreference": ri.autoRenewPreference
|
|
100
|
-
]
|
|
101
|
-
} catch {
|
|
102
|
-
print("Error in parsing VerificationResult<Product.SubscriptionInfo.RenewalInfo>")
|
|
103
|
-
return nil
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
108
|
-
func serialize(_ rs: Product.SubscriptionInfo.RenewalState?) -> String? {
|
|
109
|
-
guard let rs = rs else {return nil}
|
|
110
|
-
switch rs {
|
|
111
|
-
case .expired: return "expired"
|
|
112
|
-
case .inBillingRetryPeriod: return "inBillingRetryPeriod"
|
|
113
|
-
case .inGracePeriod: return "inGracePeriod"
|
|
114
|
-
case .revoked: return "revoked"
|
|
115
|
-
case .subscribed: return "subscribed"
|
|
116
|
-
|
|
117
|
-
default:
|
|
118
|
-
return nil
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
123
|
-
func serialize(_ ri: Product.SubscriptionInfo.RenewalInfo?) -> [String: Any?]? {
|
|
124
|
-
guard let ri = ri else {return nil}
|
|
125
|
-
return ["signedDate": ri.signedDate.millisecondsSince1970
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
130
|
-
func serialize(_ so: Product.SubscriptionOffer?) -> [String: Any?]? {
|
|
131
|
-
guard let so = so else {return nil}
|
|
132
|
-
return [
|
|
133
|
-
"displayPrice": so.displayPrice,
|
|
134
|
-
"id": so.id,
|
|
135
|
-
"paymentMode": serialize(so.paymentMode),
|
|
136
|
-
"period": serialize(so.period),
|
|
137
|
-
"periodCount": so.periodCount,
|
|
138
|
-
"price": so.price,
|
|
139
|
-
"type": serialize(so.type)
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
143
|
-
func serialize(_ pm: Product.SubscriptionOffer.PaymentMode?) -> String? {
|
|
144
|
-
guard let pm = pm else {return nil}
|
|
145
|
-
switch pm {
|
|
146
|
-
case .freeTrial: return "freeTrial"
|
|
147
|
-
case .payAsYouGo: return "payAsYouGo"
|
|
148
|
-
case .payUpFront: return "payUpFront"
|
|
149
|
-
|
|
150
|
-
default:
|
|
151
|
-
return nil
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
155
|
-
func serialize(_ ot: Product.SubscriptionOffer.OfferType?) -> String? {
|
|
156
|
-
guard let ot = ot else {return nil}
|
|
157
|
-
switch ot {
|
|
158
|
-
case .introductory: return "introductory"
|
|
159
|
-
case .promotional: return "promotional"
|
|
160
|
-
|
|
161
|
-
default:
|
|
162
|
-
return nil
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
166
|
-
func serialize(_ t: Transaction) -> [String: Any?] {
|
|
167
|
-
var environment: String?
|
|
168
|
-
|
|
169
|
-
if #available(iOS 16.0, tvOS 16.0, *) {
|
|
170
|
-
environment = t.environment.rawValue
|
|
171
|
-
} else {
|
|
172
|
-
#if !os(visionOS)
|
|
173
|
-
let env = t.environmentStringRepresentation
|
|
174
|
-
if ["Production", "Sandbox", "Xcode"].contains(env) {
|
|
175
|
-
environment = env
|
|
176
|
-
}
|
|
177
|
-
#endif
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
var result: [String: Any?] = [
|
|
181
|
-
"appAccountToken": t.appAccountToken?.uuidString,
|
|
182
|
-
"appBundleID": t.appBundleID,
|
|
183
|
-
"debugDescription": serializeDebug(t.debugDescription),
|
|
184
|
-
"deviceVerification": t.deviceVerification,
|
|
185
|
-
"deviceVerificationNonce": t.deviceVerificationNonce.uuidString,
|
|
186
|
-
"expirationDate": t.expirationDate?.millisecondsSince1970,
|
|
187
|
-
"environment": environment,
|
|
188
|
-
"id": t.id,
|
|
189
|
-
"isUpgraded": t.isUpgraded,
|
|
190
|
-
"jsonRepresentation": serialize(t.jsonRepresentation),
|
|
191
|
-
"offerID": t.offerID,
|
|
192
|
-
"offerType": serialize(t.offerType),
|
|
193
|
-
"originalID": t.originalID,
|
|
194
|
-
"originalPurchaseDate": t.originalPurchaseDate.millisecondsSince1970,
|
|
195
|
-
"ownershipType": serialize(t.ownershipType),
|
|
196
|
-
"productID": t.productID,
|
|
197
|
-
"productType": serialize(t.productType),
|
|
198
|
-
"purchaseDate": t.purchaseDate.millisecondsSince1970,
|
|
199
|
-
"purchasedQuantity": t.purchasedQuantity,
|
|
200
|
-
"revocationDate": t.revocationDate?.millisecondsSince1970,
|
|
201
|
-
"revocationReason": t.revocationReason,
|
|
202
|
-
"signedDate": t.signedDate.millisecondsSince1970,
|
|
203
|
-
"subscriptionGroupID": t.subscriptionGroupID,
|
|
204
|
-
"webOrderLineItemID": t.webOrderLineItemID
|
|
205
|
-
]
|
|
206
|
-
|
|
207
|
-
// appTransactionID is a property of AppTransaction, not Transaction
|
|
208
|
-
// It's available in iOS 15.4+ but only for AppTransaction type
|
|
209
|
-
|
|
210
|
-
// Additional fields from expo-iap
|
|
211
|
-
if #available(iOS 16.0, tvOS 16.0, *) {
|
|
212
|
-
result["environmentIos"] = t.environment.rawValue
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if #available(iOS 17.0, tvOS 17.0, *) {
|
|
216
|
-
result["storefrontCountryCodeIos"] = t.storefront.countryCode
|
|
217
|
-
result["reasonIos"] = t.reason.rawValue
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if #available(iOS 17.2, tvOS 17.2, *) {
|
|
221
|
-
if let offer = t.offer {
|
|
222
|
-
result["offerIos"] = [
|
|
223
|
-
"id": offer.id,
|
|
224
|
-
"type": offer.type.rawValue,
|
|
225
|
-
"paymentMode": offer.paymentMode?.rawValue ?? ""
|
|
226
|
-
]
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Extract price and currency from JSON representation
|
|
231
|
-
if #available(iOS 15.4, tvOS 15.4, *) {
|
|
232
|
-
do {
|
|
233
|
-
if let jsonObj = try JSONSerialization.jsonObject(with: t.jsonRepresentation) as? [String: Any] {
|
|
234
|
-
if let price = jsonObj["price"] as? NSNumber {
|
|
235
|
-
result["priceIos"] = price.doubleValue
|
|
236
|
-
}
|
|
237
|
-
if let currency = jsonObj["currency"] as? String {
|
|
238
|
-
result["currencyIos"] = currency
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
} catch {
|
|
242
|
-
// Ignore JSON parsing errors
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return result
|
|
247
|
-
}
|
|
248
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
249
|
-
func serialize(_ t: Transaction, _ v: VerificationResult<Transaction>) -> [String: Any?] {
|
|
250
|
-
var transaction = serialize(t)
|
|
251
|
-
transaction.updateValue(v.jwsRepresentation, forKey: "verificationResult")
|
|
252
|
-
transaction.updateValue(v.jwsRepresentation, forKey: "jwsRepresentationIos")
|
|
253
|
-
return transaction
|
|
254
|
-
}
|
|
255
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
256
|
-
func serialize(_ ot: Transaction.OfferType?) -> String? {
|
|
257
|
-
guard let ot = ot else {return nil}
|
|
258
|
-
switch ot {
|
|
259
|
-
case .promotional: return "promotional"
|
|
260
|
-
case .introductory: return "introductory"
|
|
261
|
-
case .code: return "code"
|
|
262
|
-
|
|
263
|
-
default:
|
|
264
|
-
return nil
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
268
|
-
func serialize(_ ot: Transaction.OwnershipType?) -> String? {
|
|
269
|
-
guard let ot = ot else {return nil}
|
|
270
|
-
switch ot {
|
|
271
|
-
case .purchased: return "purchased"
|
|
272
|
-
case .familyShared: return "familyShared"
|
|
273
|
-
|
|
274
|
-
default:
|
|
275
|
-
return nil
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
279
|
-
func serialize(_ pt: Product.ProductType?) -> String? {
|
|
280
|
-
guard let pt = pt else {return nil}
|
|
281
|
-
switch pt {
|
|
282
|
-
case .autoRenewable: return "autoRenewable"
|
|
283
|
-
case .consumable: return "consumable"
|
|
284
|
-
case .nonConsumable: return "nonConsumable"
|
|
285
|
-
case .nonRenewable: return "nonRenewable"
|
|
286
|
-
|
|
287
|
-
default:
|
|
288
|
-
return nil
|
|
289
|
-
}
|
|
290
|
-
}
|
package/ios/IapTypes.swift
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// IapTypes.swift
|
|
3
|
-
// RNIap
|
|
4
|
-
//
|
|
5
|
-
// Created by Andres Aguilar on 8/18/22.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
import StoreKit
|
|
10
|
-
|
|
11
|
-
typealias RNIapIosPromise = (RCTPromiseResolveBlock, RCTPromiseRejectBlock)
|
|
12
|
-
|
|
13
|
-
public enum StoreError: Error {
|
|
14
|
-
case failedVerification
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
enum IapErrors: String, CaseIterable {
|
|
18
|
-
case E_UNKNOWN = "E_UNKNOWN"
|
|
19
|
-
case E_SERVICE_ERROR = "E_SERVICE_ERROR"
|
|
20
|
-
case E_USER_CANCELLED = "E_USER_CANCELLED"
|
|
21
|
-
case E_USER_ERROR = "E_USER_ERROR"
|
|
22
|
-
case E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE"
|
|
23
|
-
case E_REMOTE_ERROR = "E_REMOTE_ERROR"
|
|
24
|
-
case E_NETWORK_ERROR = "E_NETWORK_ERROR"
|
|
25
|
-
case E_RECEIPT_FAILED = "E_RECEIPT_FAILED"
|
|
26
|
-
case E_RECEIPT_FINISHED_FAILED = "E_RECEIPT_FINISHED_FAILED"
|
|
27
|
-
case E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR"
|
|
28
|
-
case E_PURCHASE_ERROR = "E_PURCHASE_ERROR"
|
|
29
|
-
case E_SYNC_ERROR = "E_SYNC_ERROR"
|
|
30
|
-
case E_DEFERRED_PAYMENT = "E_DEFERRED_PAYMENT"
|
|
31
|
-
case E_TRANSACTION_VALIDATION_FAILED = "E_TRANSACTION_VALIDATION_FAILED"
|
|
32
|
-
func asInt() -> Int {
|
|
33
|
-
return IapErrors.allCases.firstIndex(of: self)!
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Based on https://stackoverflow.com/a/40135192/570612
|
|
38
|
-
extension Date {
|
|
39
|
-
var millisecondsSince1970: Int64 {
|
|
40
|
-
return Int64((self.timeIntervalSince1970 * 1000.0).rounded())
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var millisecondsSince1970String: String {
|
|
44
|
-
return String(self.millisecondsSince1970)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
init(milliseconds: Int64) {
|
|
48
|
-
self = Date(timeIntervalSince1970: TimeInterval(milliseconds) / 1000)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
extension SKProductsRequest {
|
|
53
|
-
var key: String {
|
|
54
|
-
return String(self.hashValue)
|
|
55
|
-
}
|
|
56
|
-
}
|
package/ios/IapUtils.swift
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// IapUtils.swift
|
|
3
|
-
// RNIap
|
|
4
|
-
//
|
|
5
|
-
// Created by Andres Aguilar on 8/15/22.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
import StoreKit
|
|
10
|
-
import React
|
|
11
|
-
|
|
12
|
-
public func debugMessage(_ object: Any...) {
|
|
13
|
-
#if DEBUG
|
|
14
|
-
for item in object {
|
|
15
|
-
print("[react-native-iap] \(item)")
|
|
16
|
-
}
|
|
17
|
-
#endif
|
|
18
|
-
}
|
|
19
|
-
@available(iOS 15.0, tvOS 15.0, *)
|
|
20
|
-
func checkVerified<T>(_ result: VerificationResult<T>) throws -> T {
|
|
21
|
-
// Check whether the JWS passes StoreKit verification.
|
|
22
|
-
switch result {
|
|
23
|
-
case .unverified:
|
|
24
|
-
// StoreKit parses the JWS, but it fails verification.
|
|
25
|
-
throw StoreError.failedVerification
|
|
26
|
-
|
|
27
|
-
case .verified(let safe):
|
|
28
|
-
// The result is verified. Return the unwrapped value.
|
|
29
|
-
return safe
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@available(iOS 15.0, *)
|
|
34
|
-
func currentWindow() async -> UIWindow? {
|
|
35
|
-
await withCheckedContinuation { continuation in
|
|
36
|
-
DispatchQueue.main.async {
|
|
37
|
-
continuation.resume(returning: RCTKeyWindow())
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import StoreKit
|
|
2
|
-
|
|
3
|
-
// Only keeps latest promise, assumes older promises are not needed
|
|
4
|
-
// Avoids racing conditions by storing latestPromise in a thread safe var
|
|
5
|
-
// Cancels previous promises when new ones are added
|
|
6
|
-
// Should not be used when all promises are relevant (e.g. Purchases)
|
|
7
|
-
class LatestPromiseKeeper {
|
|
8
|
-
private var latestPromise: ThreadSafe<(RCTPromiseResolveBlock, RCTPromiseRejectBlock)?> = ThreadSafe(nil)
|
|
9
|
-
private var latestRequest: ThreadSafe<SKProductsRequest?> = ThreadSafe(nil)
|
|
10
|
-
|
|
11
|
-
func setLatestPromise(request: SKProductsRequest, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
12
|
-
// Cancel the ongoing request and reject the existing promise before setting a new one
|
|
13
|
-
cancelOngoingRequest()
|
|
14
|
-
|
|
15
|
-
latestRequest.atomically { $0 = request }
|
|
16
|
-
latestPromise.atomically { $0 = (resolve, reject) }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
func cancelOngoingRequest() {
|
|
20
|
-
latestPromise.atomically { promiseResolvers in
|
|
21
|
-
if let (_, reject) = promiseResolvers {
|
|
22
|
-
// Reject the promise with an error indicating that it was cancelled due to a new request
|
|
23
|
-
reject("E_CANCELED", "Previous request was cancelled due to a new request", nil)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
latestRequest.atomically { ongoingRequest in
|
|
28
|
-
ongoingRequest?.cancel()
|
|
29
|
-
ongoingRequest = nil
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
clearLatestPromiseAndRequest()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
func resolveIfRequestMatches(matchingRequest: SKProductsRequest, items: [[String: Any?]], operation: (RCTPromiseResolveBlock, [[String: Any?]]) -> Void) {
|
|
36
|
-
latestPromise.atomically { promiseResolvers in
|
|
37
|
-
guard let (resolve, _) = promiseResolvers else { return }
|
|
38
|
-
|
|
39
|
-
latestRequest.atomically { ongoingRequest in
|
|
40
|
-
guard ongoingRequest === matchingRequest else { return }
|
|
41
|
-
|
|
42
|
-
operation(resolve, items)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
clearLatestPromiseAndRequest()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private func clearLatestPromiseAndRequest() {
|
|
49
|
-
latestPromise.atomically { $0 = nil }
|
|
50
|
-
latestRequest.atomically { $0 = nil }
|
|
51
|
-
}
|
|
52
|
-
}
|