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.
Files changed (381) hide show
  1. package/NitroIap.podspec +33 -0
  2. package/README.md +163 -51
  3. package/android/CMakeLists.txt +32 -0
  4. package/android/build.gradle +107 -138
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -13
  7. package/android/src/main/AndroidManifest.xml +1 -4
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +843 -0
  10. package/android/src/main/java/com/margelo/nitro/iap/NitroIapPackage.java +33 -0
  11. package/android/src/main/java/com/margelo/nitro/iap/Types.kt +173 -0
  12. package/ios/Bridge.h +8 -0
  13. package/ios/ErrorUtils.swift +153 -0
  14. package/ios/HybridRnIap.swift +1326 -0
  15. package/ios/ProductStore.swift +33 -0
  16. package/ios/reactnativeiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  17. package/ios/reactnativeiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  18. package/lib/module/helpers/subscription.js +56 -0
  19. package/lib/module/helpers/subscription.js.map +1 -0
  20. package/lib/module/hooks/useIAP.js +175 -123
  21. package/lib/module/hooks/useIAP.js.map +1 -1
  22. package/lib/module/index.js +1015 -9
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/module/package.json +1 -0
  25. package/lib/module/specs/RnIap.nitro.js +4 -0
  26. package/lib/{commonjs/modules/common.js.map → module/specs/RnIap.nitro.js.map} +1 -1
  27. package/lib/module/types.js +187 -0
  28. package/lib/module/types.js.map +1 -0
  29. package/lib/module/utils/error.js +80 -0
  30. package/lib/module/utils/error.js.map +1 -0
  31. package/lib/module/utils/type-bridge.js +202 -0
  32. package/lib/module/utils/type-bridge.js.map +1 -0
  33. package/lib/typescript/package.json +1 -0
  34. package/lib/typescript/plugin/src/withIAP.d.ts +2 -7
  35. package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
  36. package/lib/typescript/scripts/check-nitro-versions.d.ts +3 -0
  37. package/lib/typescript/scripts/check-nitro-versions.d.ts.map +1 -0
  38. package/lib/typescript/src/helpers/subscription.d.ts +14 -0
  39. package/lib/typescript/src/helpers/subscription.d.ts.map +1 -0
  40. package/lib/typescript/src/hooks/useIAP.d.ts +42 -26
  41. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  42. package/lib/typescript/src/index.d.ts +356 -8
  43. package/lib/typescript/src/index.d.ts.map +1 -1
  44. package/lib/typescript/src/specs/RnIap.nitro.d.ts +404 -0
  45. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -0
  46. package/lib/typescript/src/types.d.ts +544 -0
  47. package/lib/typescript/src/types.d.ts.map +1 -0
  48. package/lib/typescript/src/utils/error.d.ts +30 -0
  49. package/lib/typescript/src/utils/error.d.ts.map +1 -0
  50. package/lib/typescript/src/utils/type-bridge.d.ts +40 -0
  51. package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -0
  52. package/nitro.json +17 -0
  53. package/nitrogen/generated/android/NitroIap+autolinking.cmake +80 -0
  54. package/nitrogen/generated/android/NitroIap+autolinking.gradle +27 -0
  55. package/nitrogen/generated/android/NitroIapOnLoad.cpp +50 -0
  56. package/nitrogen/generated/android/NitroIapOnLoad.hpp +25 -0
  57. package/nitrogen/generated/android/c++/JFunc_void_NitroProduct.hpp +78 -0
  58. package/nitrogen/generated/android/c++/JFunc_void_NitroPurchase.hpp +78 -0
  59. package/nitrogen/generated/android/c++/JFunc_void_NitroPurchaseResult.hpp +78 -0
  60. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +577 -0
  61. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +93 -0
  62. package/nitrogen/generated/android/c++/JNitroAndroidReceiptValidationOptions.hpp +66 -0
  63. package/nitrogen/generated/android/c++/JNitroAvailablePurchasesAndroidOptions.hpp +54 -0
  64. package/nitrogen/generated/android/c++/JNitroAvailablePurchasesIosOptions.hpp +65 -0
  65. package/nitrogen/generated/android/c++/JNitroAvailablePurchasesOptions.hpp +62 -0
  66. package/nitrogen/generated/android/c++/JNitroFinishTransactionAndroidParams.hpp +58 -0
  67. package/nitrogen/generated/android/c++/JNitroFinishTransactionIosParams.hpp +53 -0
  68. package/nitrogen/generated/android/c++/JNitroFinishTransactionParams.hpp +62 -0
  69. package/nitrogen/generated/android/c++/JNitroProduct.hpp +154 -0
  70. package/nitrogen/generated/android/c++/JNitroPurchase.hpp +122 -0
  71. package/nitrogen/generated/android/c++/JNitroPurchaseRequest.hpp +66 -0
  72. package/nitrogen/generated/android/c++/JNitroPurchaseResult.hpp +70 -0
  73. package/nitrogen/generated/android/c++/JNitroReceiptValidationParams.hpp +60 -0
  74. package/nitrogen/generated/android/c++/JNitroReceiptValidationResultAndroid.hpp +122 -0
  75. package/nitrogen/generated/android/c++/JNitroReceiptValidationResultIOS.hpp +68 -0
  76. package/nitrogen/generated/android/c++/JNitroRequestPurchaseAndroid.hpp +115 -0
  77. package/nitrogen/generated/android/c++/JNitroRequestPurchaseIos.hpp +84 -0
  78. package/nitrogen/generated/android/c++/JNitroSubscriptionOffer.hpp +57 -0
  79. package/nitrogen/generated/android/c++/JNitroSubscriptionRenewalInfo.hpp +74 -0
  80. package/nitrogen/generated/android/c++/JNitroSubscriptionStatus.hpp +64 -0
  81. package/nitrogen/generated/android/c++/JVariant_Boolean_NitroPurchaseResult.cpp +26 -0
  82. package/nitrogen/generated/android/c++/JVariant_Boolean_NitroPurchaseResult.hpp +71 -0
  83. package/nitrogen/generated/android/c++/JVariant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.cpp +26 -0
  84. package/nitrogen/generated/android/c++/JVariant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.hpp +75 -0
  85. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroProduct.kt +81 -0
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroPurchase.kt +81 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroPurchaseResult.kt +81 -0
  88. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +198 -0
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAndroidReceiptValidationOptions.kt +38 -0
  90. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesAndroidOptions.kt +29 -0
  91. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesIosOptions.kt +38 -0
  92. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesOptions.kt +32 -0
  93. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroFinishTransactionAndroidParams.kt +32 -0
  94. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroFinishTransactionIosParams.kt +29 -0
  95. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroFinishTransactionParams.kt +32 -0
  96. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroIapOnLoad.kt +35 -0
  97. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroProduct.kt +104 -0
  98. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +80 -0
  99. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseRequest.kt +32 -0
  100. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseResult.kt +41 -0
  101. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationParams.kt +32 -0
  102. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationResultAndroid.kt +80 -0
  103. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationResultIOS.kt +38 -0
  104. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRequestPurchaseAndroid.kt +47 -0
  105. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRequestPurchaseIos.kt +41 -0
  106. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroSubscriptionOffer.kt +32 -0
  107. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroSubscriptionRenewalInfo.kt +44 -0
  108. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroSubscriptionStatus.kt +35 -0
  109. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_Boolean_NitroPurchaseResult.kt +42 -0
  110. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.kt +42 -0
  111. package/nitrogen/generated/ios/NitroIap+autolinking.rb +60 -0
  112. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +152 -0
  113. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +1061 -0
  114. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +107 -0
  115. package/nitrogen/generated/ios/NitroIapAutolinking.mm +33 -0
  116. package/nitrogen/generated/ios/NitroIapAutolinking.swift +25 -0
  117. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.cpp +11 -0
  118. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +355 -0
  119. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  120. package/nitrogen/generated/ios/swift/Func_void_NitroProduct.swift +47 -0
  121. package/nitrogen/generated/ios/swift/Func_void_NitroPurchase.swift +47 -0
  122. package/nitrogen/generated/ios/swift/Func_void_NitroPurchaseResult.swift +47 -0
  123. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  124. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  125. package/nitrogen/generated/ios/swift/Func_void_std__optional_NitroProduct_.swift +54 -0
  126. package/nitrogen/generated/ios/swift/Func_void_std__optional_NitroPurchase_.swift +54 -0
  127. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +54 -0
  128. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__vector_NitroSubscriptionStatus__.swift +54 -0
  129. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  130. package/nitrogen/generated/ios/swift/Func_void_std__variant_NitroReceiptValidationResultIOS__NitroReceiptValidationResultAndroid_.swift +59 -0
  131. package/nitrogen/generated/ios/swift/Func_void_std__variant_bool__NitroPurchaseResult_.swift +59 -0
  132. package/nitrogen/generated/ios/swift/Func_void_std__vector_NitroProduct_.swift +47 -0
  133. package/nitrogen/generated/ios/swift/Func_void_std__vector_NitroPurchase_.swift +47 -0
  134. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +78 -0
  135. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +750 -0
  136. package/nitrogen/generated/ios/swift/NitroAndroidReceiptValidationOptions.swift +80 -0
  137. package/nitrogen/generated/ios/swift/NitroAvailablePurchasesAndroidOptions.swift +54 -0
  138. package/nitrogen/generated/ios/swift/NitroAvailablePurchasesIosOptions.swift +116 -0
  139. package/nitrogen/generated/ios/swift/NitroAvailablePurchasesOptions.swift +84 -0
  140. package/nitrogen/generated/ios/swift/NitroFinishTransactionAndroidParams.swift +58 -0
  141. package/nitrogen/generated/ios/swift/NitroFinishTransactionIosParams.swift +35 -0
  142. package/nitrogen/generated/ios/swift/NitroFinishTransactionParams.swift +84 -0
  143. package/nitrogen/generated/ios/swift/NitroProduct.swift +653 -0
  144. package/nitrogen/generated/ios/swift/NitroPurchase.swift +453 -0
  145. package/nitrogen/generated/ios/swift/NitroPurchaseRequest.swift +84 -0
  146. package/nitrogen/generated/ios/swift/NitroPurchaseResult.swift +117 -0
  147. package/nitrogen/generated/ios/swift/NitroReceiptValidationParams.swift +65 -0
  148. package/nitrogen/generated/ios/swift/NitroReceiptValidationResultAndroid.swift +258 -0
  149. package/nitrogen/generated/ios/swift/NitroReceiptValidationResultIOS.swift +87 -0
  150. package/nitrogen/generated/ios/swift/NitroRequestPurchaseAndroid.swift +225 -0
  151. package/nitrogen/generated/ios/swift/NitroRequestPurchaseIos.swift +161 -0
  152. package/nitrogen/generated/ios/swift/NitroSubscriptionOffer.swift +46 -0
  153. package/nitrogen/generated/ios/swift/NitroSubscriptionRenewalInfo.swift +152 -0
  154. package/nitrogen/generated/ios/swift/NitroSubscriptionStatus.swift +76 -0
  155. package/nitrogen/generated/ios/swift/Variant_Bool_NitroPurchaseResult.swift +18 -0
  156. package/nitrogen/generated/ios/swift/Variant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.swift +18 -0
  157. package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +50 -0
  158. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +125 -0
  159. package/nitrogen/generated/shared/c++/NitroAndroidReceiptValidationOptions.hpp +80 -0
  160. package/nitrogen/generated/shared/c++/NitroAvailablePurchasesAndroidOptions.hpp +68 -0
  161. package/nitrogen/generated/shared/c++/NitroAvailablePurchasesIosOptions.hpp +79 -0
  162. package/nitrogen/generated/shared/c++/NitroAvailablePurchasesOptions.hpp +76 -0
  163. package/nitrogen/generated/shared/c++/NitroFinishTransactionAndroidParams.hpp +72 -0
  164. package/nitrogen/generated/shared/c++/NitroFinishTransactionIosParams.hpp +67 -0
  165. package/nitrogen/generated/shared/c++/NitroFinishTransactionParams.hpp +76 -0
  166. package/nitrogen/generated/shared/c++/NitroProduct.hpp +168 -0
  167. package/nitrogen/generated/shared/c++/NitroPurchase.hpp +136 -0
  168. package/nitrogen/generated/shared/c++/NitroPurchaseRequest.hpp +76 -0
  169. package/nitrogen/generated/shared/c++/NitroPurchaseResult.hpp +84 -0
  170. package/nitrogen/generated/shared/c++/NitroReceiptValidationParams.hpp +74 -0
  171. package/nitrogen/generated/shared/c++/NitroReceiptValidationResultAndroid.hpp +136 -0
  172. package/nitrogen/generated/shared/c++/NitroReceiptValidationResultIOS.hpp +82 -0
  173. package/nitrogen/generated/shared/c++/NitroRequestPurchaseAndroid.hpp +95 -0
  174. package/nitrogen/generated/shared/c++/NitroRequestPurchaseIos.hpp +85 -0
  175. package/nitrogen/generated/shared/c++/NitroSubscriptionOffer.hpp +71 -0
  176. package/nitrogen/generated/shared/c++/NitroSubscriptionRenewalInfo.hpp +88 -0
  177. package/nitrogen/generated/shared/c++/NitroSubscriptionStatus.hpp +78 -0
  178. package/package.json +145 -104
  179. package/plugin/build/src/withIAP.d.ts +3 -0
  180. package/plugin/build/src/withIAP.js +81 -0
  181. package/plugin/build/tsconfig.tsbuildinfo +1 -0
  182. package/plugin/build/withIAP.d.ts +2 -7
  183. package/plugin/build/withIAP.js +62 -51
  184. package/plugin/src/withIAP.ts +119 -0
  185. package/plugin/tsconfig.json +18 -0
  186. package/plugin/tsconfig.tsbuildinfo +1 -0
  187. package/src/helpers/subscription.ts +65 -0
  188. package/src/hooks/useIAP.ts +361 -222
  189. package/src/index.ts +1194 -9
  190. package/src/specs/RnIap.nitro.ts +501 -0
  191. package/src/types.ts +680 -0
  192. package/src/utils/error.ts +97 -0
  193. package/src/utils/type-bridge.ts +209 -0
  194. package/LICENSE +0 -21
  195. package/RNIap.podspec +0 -36
  196. package/android/src/amazon/AndroidManifest.xml +0 -14
  197. package/android/src/amazon/java/com/dooboolab/rniap/EventSender.kt +0 -10
  198. package/android/src/amazon/java/com/dooboolab/rniap/PurchasingServiceProxy.kt +0 -29
  199. package/android/src/amazon/java/com/dooboolab/rniap/PurchasingServiceProxyAmazonImpl.kt +0 -31
  200. package/android/src/amazon/java/com/dooboolab/rniap/RNIapActivityListener.kt +0 -55
  201. package/android/src/amazon/java/com/dooboolab/rniap/RNIapAmazonListener.kt +0 -325
  202. package/android/src/amazon/java/com/dooboolab/rniap/RNIapAmazonModule.kt +0 -244
  203. package/android/src/amazon/java/com/dooboolab/rniap/RNIapPackage.kt +0 -17
  204. package/android/src/amazon/java/com/dooboolab/rniap/modifysubscription/RNIapAmazonModifySubscriptionListener.kt +0 -88
  205. package/android/src/amazon/java/com/dooboolab/rniap/utils/Extensions.kt +0 -22
  206. package/android/src/main/java/com/dooboolab/rniap/PromiseUtils.kt +0 -62
  207. package/android/src/main/java/com/dooboolab/rniap/PromiseUtlis.kt +0 -43
  208. package/android/src/play/java/com/dooboolab/rniap/PlayUtils.kt +0 -114
  209. package/android/src/play/java/com/dooboolab/rniap/RNIapActivityListener.kt +0 -15
  210. package/android/src/play/java/com/dooboolab/rniap/RNIapModule.kt +0 -911
  211. package/android/src/play/java/com/dooboolab/rniap/RNIapPackage.kt +0 -17
  212. package/android/src/testAmazon/java/com/dooboolab/rniap/RNIapAmazonModuleTest.kt +0 -170
  213. package/app.plugin.js +0 -1
  214. package/ios/IapSerializationUtils.swift +0 -290
  215. package/ios/IapTypes.swift +0 -56
  216. package/ios/IapUtils.swift +0 -40
  217. package/ios/LatestPromiseKeeper.swift +0 -52
  218. package/ios/RNIapIos-Bridging-Header.h +0 -2
  219. package/ios/RNIapIos.m +0 -69
  220. package/ios/RNIapIos.swift +0 -868
  221. package/ios/RNIapIos.xcodeproj/project.pbxproj +0 -289
  222. package/ios/RNIapIosSk2.m +0 -126
  223. package/ios/RNIapIosSk2.swift +0 -1413
  224. package/ios/ThreadSafe.swift +0 -18
  225. package/lib/commonjs/eventEmitter.js +0 -195
  226. package/lib/commonjs/eventEmitter.js.map +0 -1
  227. package/lib/commonjs/hooks/index.js +0 -17
  228. package/lib/commonjs/hooks/index.js.map +0 -1
  229. package/lib/commonjs/hooks/useIAP.js +0 -203
  230. package/lib/commonjs/hooks/useIAP.js.map +0 -1
  231. package/lib/commonjs/hooks/withIAPContext.js +0 -95
  232. package/lib/commonjs/hooks/withIAPContext.js.map +0 -1
  233. package/lib/commonjs/iap.js +0 -836
  234. package/lib/commonjs/iap.js.map +0 -1
  235. package/lib/commonjs/index.js +0 -105
  236. package/lib/commonjs/index.js.map +0 -1
  237. package/lib/commonjs/internal/enhancedFetch.js +0 -26
  238. package/lib/commonjs/internal/enhancedFetch.js.map +0 -1
  239. package/lib/commonjs/internal/fillProductsWithAdditionalData.js +0 -50
  240. package/lib/commonjs/internal/fillProductsWithAdditionalData.js.map +0 -1
  241. package/lib/commonjs/internal/index.js +0 -39
  242. package/lib/commonjs/internal/index.js.map +0 -1
  243. package/lib/commonjs/internal/platform.js +0 -119
  244. package/lib/commonjs/internal/platform.js.map +0 -1
  245. package/lib/commonjs/modules/amazon.js +0 -50
  246. package/lib/commonjs/modules/amazon.js.map +0 -1
  247. package/lib/commonjs/modules/android.js +0 -92
  248. package/lib/commonjs/modules/android.js.map +0 -1
  249. package/lib/commonjs/modules/common.js +0 -2
  250. package/lib/commonjs/modules/index.js +0 -50
  251. package/lib/commonjs/modules/index.js.map +0 -1
  252. package/lib/commonjs/modules/ios.js +0 -160
  253. package/lib/commonjs/modules/ios.js.map +0 -1
  254. package/lib/commonjs/modules/iosSk2.js +0 -113
  255. package/lib/commonjs/modules/iosSk2.js.map +0 -1
  256. package/lib/commonjs/purchaseError.js +0 -170
  257. package/lib/commonjs/purchaseError.js.map +0 -1
  258. package/lib/commonjs/types/amazon.js +0 -2
  259. package/lib/commonjs/types/amazon.js.map +0 -1
  260. package/lib/commonjs/types/android.js +0 -67
  261. package/lib/commonjs/types/android.js.map +0 -1
  262. package/lib/commonjs/types/apple.js +0 -24
  263. package/lib/commonjs/types/apple.js.map +0 -1
  264. package/lib/commonjs/types/appleSk2.js +0 -137
  265. package/lib/commonjs/types/appleSk2.js.map +0 -1
  266. package/lib/commonjs/types/index.js +0 -67
  267. package/lib/commonjs/types/index.js.map +0 -1
  268. package/lib/commonjs/utils/errorMapping.js +0 -83
  269. package/lib/commonjs/utils/errorMapping.js.map +0 -1
  270. package/lib/commonjs/utils/typeGuards.js +0 -74
  271. package/lib/commonjs/utils/typeGuards.js.map +0 -1
  272. package/lib/module/eventEmitter.js +0 -185
  273. package/lib/module/eventEmitter.js.map +0 -1
  274. package/lib/module/hooks/index.js +0 -2
  275. package/lib/module/hooks/index.js.map +0 -1
  276. package/lib/module/hooks/withIAPContext.js +0 -86
  277. package/lib/module/hooks/withIAPContext.js.map +0 -1
  278. package/lib/module/iap.js +0 -805
  279. package/lib/module/iap.js.map +0 -1
  280. package/lib/module/internal/enhancedFetch.js +0 -19
  281. package/lib/module/internal/enhancedFetch.js.map +0 -1
  282. package/lib/module/internal/fillProductsWithAdditionalData.js +0 -43
  283. package/lib/module/internal/fillProductsWithAdditionalData.js.map +0 -1
  284. package/lib/module/internal/index.js +0 -4
  285. package/lib/module/internal/index.js.map +0 -1
  286. package/lib/module/internal/platform.js +0 -102
  287. package/lib/module/internal/platform.js.map +0 -1
  288. package/lib/module/modules/amazon.js +0 -42
  289. package/lib/module/modules/amazon.js.map +0 -1
  290. package/lib/module/modules/android.js +0 -81
  291. package/lib/module/modules/android.js.map +0 -1
  292. package/lib/module/modules/common.js +0 -2
  293. package/lib/module/modules/common.js.map +0 -1
  294. package/lib/module/modules/index.js +0 -5
  295. package/lib/module/modules/index.js.map +0 -1
  296. package/lib/module/modules/ios.js +0 -145
  297. package/lib/module/modules/ios.js.map +0 -1
  298. package/lib/module/modules/iosSk2.js +0 -96
  299. package/lib/module/modules/iosSk2.js.map +0 -1
  300. package/lib/module/purchaseError.js +0 -164
  301. package/lib/module/purchaseError.js.map +0 -1
  302. package/lib/module/types/amazon.js +0 -2
  303. package/lib/module/types/amazon.js.map +0 -1
  304. package/lib/module/types/android.js +0 -63
  305. package/lib/module/types/android.js.map +0 -1
  306. package/lib/module/types/apple.js +0 -17
  307. package/lib/module/types/apple.js.map +0 -1
  308. package/lib/module/types/appleSk2.js +0 -129
  309. package/lib/module/types/appleSk2.js.map +0 -1
  310. package/lib/module/types/index.js +0 -75
  311. package/lib/module/types/index.js.map +0 -1
  312. package/lib/module/utils/errorMapping.js +0 -75
  313. package/lib/module/utils/errorMapping.js.map +0 -1
  314. package/lib/module/utils/typeGuards.js +0 -61
  315. package/lib/module/utils/typeGuards.js.map +0 -1
  316. package/lib/typescript/src/eventEmitter.d.ts +0 -151
  317. package/lib/typescript/src/eventEmitter.d.ts.map +0 -1
  318. package/lib/typescript/src/hooks/index.d.ts +0 -2
  319. package/lib/typescript/src/hooks/index.d.ts.map +0 -1
  320. package/lib/typescript/src/hooks/withIAPContext.d.ts +0 -27
  321. package/lib/typescript/src/hooks/withIAPContext.d.ts.map +0 -1
  322. package/lib/typescript/src/iap.d.ts +0 -503
  323. package/lib/typescript/src/iap.d.ts.map +0 -1
  324. package/lib/typescript/src/internal/enhancedFetch.d.ts +0 -6
  325. package/lib/typescript/src/internal/enhancedFetch.d.ts.map +0 -1
  326. package/lib/typescript/src/internal/fillProductsWithAdditionalData.d.ts +0 -7
  327. package/lib/typescript/src/internal/fillProductsWithAdditionalData.d.ts.map +0 -1
  328. package/lib/typescript/src/internal/index.d.ts +0 -4
  329. package/lib/typescript/src/internal/index.d.ts.map +0 -1
  330. package/lib/typescript/src/internal/platform.d.ts +0 -27
  331. package/lib/typescript/src/internal/platform.d.ts.map +0 -1
  332. package/lib/typescript/src/modules/amazon.d.ts +0 -55
  333. package/lib/typescript/src/modules/amazon.d.ts.map +0 -1
  334. package/lib/typescript/src/modules/android.d.ts +0 -74
  335. package/lib/typescript/src/modules/android.d.ts.map +0 -1
  336. package/lib/typescript/src/modules/common.d.ts +0 -14
  337. package/lib/typescript/src/modules/common.d.ts.map +0 -1
  338. package/lib/typescript/src/modules/index.d.ts +0 -5
  339. package/lib/typescript/src/modules/index.d.ts.map +0 -1
  340. package/lib/typescript/src/modules/ios.d.ts +0 -117
  341. package/lib/typescript/src/modules/ios.d.ts.map +0 -1
  342. package/lib/typescript/src/modules/iosSk2.d.ts +0 -140
  343. package/lib/typescript/src/modules/iosSk2.d.ts.map +0 -1
  344. package/lib/typescript/src/purchaseError.d.ts +0 -133
  345. package/lib/typescript/src/purchaseError.d.ts.map +0 -1
  346. package/lib/typescript/src/types/amazon.d.ts +0 -33
  347. package/lib/typescript/src/types/amazon.d.ts.map +0 -1
  348. package/lib/typescript/src/types/android.d.ts +0 -66
  349. package/lib/typescript/src/types/android.d.ts.map +0 -1
  350. package/lib/typescript/src/types/apple.d.ts +0 -27
  351. package/lib/typescript/src/types/apple.d.ts.map +0 -1
  352. package/lib/typescript/src/types/appleSk2.d.ts +0 -129
  353. package/lib/typescript/src/types/appleSk2.d.ts.map +0 -1
  354. package/lib/typescript/src/types/index.d.ts +0 -302
  355. package/lib/typescript/src/types/index.d.ts.map +0 -1
  356. package/lib/typescript/src/utils/errorMapping.d.ts +0 -29
  357. package/lib/typescript/src/utils/errorMapping.d.ts.map +0 -1
  358. package/lib/typescript/src/utils/typeGuards.d.ts +0 -53
  359. package/lib/typescript/src/utils/typeGuards.d.ts.map +0 -1
  360. package/src/eventEmitter.ts +0 -212
  361. package/src/hooks/index.ts +0 -1
  362. package/src/hooks/withIAPContext.tsx +0 -179
  363. package/src/iap.ts +0 -1046
  364. package/src/internal/enhancedFetch.ts +0 -25
  365. package/src/internal/fillProductsWithAdditionalData.ts +0 -47
  366. package/src/internal/index.ts +0 -3
  367. package/src/internal/platform.ts +0 -135
  368. package/src/modules/amazon.ts +0 -94
  369. package/src/modules/android.ts +0 -179
  370. package/src/modules/common.ts +0 -16
  371. package/src/modules/index.ts +0 -4
  372. package/src/modules/ios.ts +0 -229
  373. package/src/modules/iosSk2.ts +0 -194
  374. package/src/purchaseError.ts +0 -196
  375. package/src/types/amazon.ts +0 -40
  376. package/src/types/android.ts +0 -89
  377. package/src/types/apple.ts +0 -44
  378. package/src/types/appleSk2.ts +0 -275
  379. package/src/types/index.ts +0 -379
  380. package/src/utils/errorMapping.ts +0 -88
  381. package/src/utils/typeGuards.ts +0 -90
@@ -1,151 +0,0 @@
1
- import { EmitterSubscription } from 'react-native';
2
- import { TransactionEvent } from './types/appleSk2';
3
- import type { PurchaseError } from './purchaseError';
4
- import type { Purchase } from './types';
5
- /**
6
- * Add IAP purchase event
7
- * Register a callback that gets called when the store has any updates to purchases that have not yet been finished, consumed or acknowledged. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates. Register you listener as soon as possible and react to updates at all times.
8
-
9
- ## Signature
10
-
11
- ```ts
12
- purchaseUpdatedListener((purchase: Purchase) => {});
13
- ```
14
-
15
- ## Usage
16
-
17
- ```tsx
18
- import React, {useEffect} from 'react';
19
- import {View} from 'react-native';
20
- import {purchaseUpdatedListener} from 'react-native-iap';
21
-
22
- const App = () => {
23
- useEffect(() => {
24
- const subscription = purchaseUpdatedListener((purchase: Purchase) => {
25
- console.log(purchase);
26
- });
27
-
28
- return () => {
29
- subscription.remove();
30
- };
31
- }, []);
32
-
33
- return <View />;
34
- };
35
- ```
36
- */
37
- export declare const purchaseUpdatedListener: (listener: (event: Purchase) => void, errorCallback?: ((error: unknown) => void) | undefined) => EmitterSubscription;
38
- /**
39
- * Add IAP purchase error event
40
- * Register a callback that gets called when there has been an error with a purchase. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates.
41
-
42
- ## Signature
43
-
44
- ```ts
45
- purchaseErrorListener((error: PurchaseError) => {});
46
- ```
47
-
48
- ## Usage
49
-
50
- ```tsx
51
- import React, {useEffect} from 'react';
52
- import {View} from 'react-native';
53
- import {purchaseErrorListener} from 'react-native-iap';
54
-
55
- const App = () => {
56
- useEffect(() => {
57
- const subscription = purchaseErrorListener((error: PurchaseError) => {
58
- console.log(error);
59
- });
60
-
61
- return () => {
62
- subscription.remove();
63
- };
64
- }, []);
65
-
66
- return <View />;
67
- };
68
- ```
69
-
70
- */
71
- export declare const purchaseErrorListener: (listener: (error: PurchaseError) => void) => EmitterSubscription;
72
- /**
73
- * Add IAP promoted subscription event
74
- * Add IAP promoted subscription event.
75
-
76
- ## Signature
77
-
78
- ```ts
79
- promotedProductListener((productId?: string) => {});
80
- ```
81
-
82
- ## Usage
83
-
84
- ```tsx
85
- import React, {useEffect} from 'react';
86
- import {View} from 'react-native';
87
- import {promotedProductListener} from 'react-native-iap';
88
-
89
- const App = () => {
90
- useEffect(() => {
91
- const subscription = promotedProductListener((productId) => {
92
- console.log(productId);
93
- });
94
-
95
- return () => {
96
- subscription.remove();
97
- };
98
- }, []);
99
-
100
- return <View />;
101
- };
102
- ```
103
-
104
- *
105
- * @platform iOS
106
- */
107
- export declare const promotedProductListener: (listener: () => void) => EmitterSubscription | null;
108
- /**
109
- * Updated transactions for iOS Sk2
110
- * Register a callback that gets called when the store has any updates to transactions related to purchases that have not yet been finished, consumed or acknowledged.
111
- * Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates. Register you listener as soon as possible and react to updates at all times.
112
-
113
- **Warning**
114
- This is only available for iOS 15 and higher and Storekit 2 is activated
115
-
116
- ## Signature
117
-
118
- ```ts
119
- purchaseUpdatedListener((transactionOrError: TransactionOrError) => {});
120
- ```
121
-
122
- ## Usage
123
-
124
- ```tsx
125
- import React, {useEffect} from 'react';
126
- import {View} from 'react-native';
127
- import {purchaseUpdatedListener} from 'react-native-iap';
128
-
129
- const App = () => {
130
- useEffect(() => {
131
- const subscription = purchaseUpdatedListener((transactionOrError: TransactionOrError) => {
132
- if(transactionOrError.transaction){
133
- console.log("There's an update to a transaction", transactionOrError.transaction);
134
- }else{
135
- console.log("There's been an error with a received transaction")
136
- }
137
- });
138
-
139
- return () => {
140
- subscription.remove();
141
- };
142
- }, []);
143
-
144
- return <View />;
145
- };
146
- ```
147
- *
148
- * @platform iOS (Sk2)
149
- */
150
- export declare const transactionListener: (listener: (event: TransactionEvent) => void) => EmitterSubscription | null;
151
- //# sourceMappingURL=eventEmitter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventEmitter.d.ts","sourceRoot":"","sources":["../../../src/eventEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAqB,MAAM,cAAc,CAAC;AAErE,OAAO,EAAC,gBAAgB,EAA8B,MAAM,kBAAkB,CAAC;AAS/E,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,uBAAuB,qBAChB,QAAQ,KAAK,IAAI,2BACX,OAAO,KAAK,IAAI,qCA0BzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,qBAAqB,qBACd,aAAa,KAAK,IAAI,KACvC,mBAGF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,uBAAuB,aAAc,MAAM,IAAI,+BAO3D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,mBAAmB,qBACZ,gBAAgB,KAAK,IAAI,+BAQ5C,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './useIAP';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- import type { PurchaseError } from '../purchaseError';
3
- import type { Product, Purchase, Subscription } from '../types';
4
- import type { TransactionSk2 } from '../types/appleSk2';
5
- type IAPContextType = {
6
- connected: boolean;
7
- products: Product[];
8
- promotedProductsIOS: Product[];
9
- subscriptions: Subscription[];
10
- purchaseHistory: Purchase[];
11
- availablePurchases: Purchase[];
12
- currentPurchase?: Purchase;
13
- currentTransaction?: TransactionSk2;
14
- currentPurchaseError?: PurchaseError;
15
- initConnectionError?: Error;
16
- setConnected: (connected: boolean) => void;
17
- setProducts: (products: Product[]) => void;
18
- setSubscriptions: (subscriptions: Subscription[]) => void;
19
- setPurchaseHistory: (purchaseHistory: Purchase[]) => void;
20
- setAvailablePurchases: (availablePurchases: Purchase[]) => void;
21
- setCurrentPurchase: (currentPurchase: Purchase | undefined) => void;
22
- setCurrentPurchaseError: (currentPurchaseError: PurchaseError | undefined) => void;
23
- };
24
- export declare function useIAPContext(): IAPContextType;
25
- export declare function withIAPContext<T>(Component: React.ComponentType<T>): (props: T) => React.JSX.Element;
26
- export {};
27
- //# sourceMappingURL=withIAPContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withIAPContext.d.ts","sourceRoot":"","sources":["../../../../src/hooks/withIAPContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAStE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EACV,OAAO,EAEP,QAAQ,EACR,YAAY,EAEb,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAmB,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAExE,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,mBAAmB,EAAE,OAAO,EAAE,CAAC;IAC/B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,eAAe,EAAE,QAAQ,EAAE,CAAC;IAC5B,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,kBAAkB,CAAC,EAAE,cAAc,CAAC;IACpC,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC,mBAAmB,CAAC,EAAE,KAAK,CAAC;IAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IAC3C,gBAAgB,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAC1D,kBAAkB,EAAE,CAAC,eAAe,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAC1D,qBAAqB,EAAE,CAAC,kBAAkB,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAChE,kBAAkB,EAAE,CAAC,eAAe,EAAE,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC;IACpE,uBAAuB,EAAE,CACvB,oBAAoB,EAAE,aAAa,GAAG,SAAS,KAC5C,IAAI,CAAC;CACX,CAAC;AAKF,wBAAgB,aAAa,IAAI,cAAc,CAQ9C;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,WACzB,CAAC,uBA2H1C"}
@@ -1,503 +0,0 @@
1
- import * as IapAmazon from './modules/amazon';
2
- import * as IapAndroid from './modules/android';
3
- import * as IapIos from './modules/ios';
4
- import * as IapIosSk2 from './modules/iosSk2';
5
- import { isIosStorekit2 } from './internal';
6
- import { Product, ProductPurchase, Purchase, PurchaseResult, RequestPurchase, RequestSubscription, Subscription, SubscriptionPurchase } from './types';
7
- export { IapAndroid, IapAmazon, IapIos, IapIosSk2, isIosStorekit2 };
8
- /**
9
- * STOREKIT1_MODE: Will not enable Storekit 2 even if the device supports it. Thigs will work as before,
10
- * minimum changes required in the migration guide (default)
11
- * HYBRID_MODE: Will enable Storekit 2 for iOS devices > 15.0 but will fallback to Sk1 on older devices
12
- * There are some edge cases that you need to handle in this case (described in migration guide). This mode
13
- * is for developers that are migrating to Storekit 2 but want to keep supporting older versions.
14
- * STOREKIT2_MODE: Will *only* enable Storekit 2. This disables Storekit 1. This is for apps that
15
- * have already targeted a min version of 15 for their app.
16
- */
17
- export type STOREKIT_OPTIONS = 'STOREKIT1_MODE' | 'STOREKIT_HYBRID_MODE' | 'STOREKIT2_MODE';
18
- export declare const setup: ({ storekitMode, }?: {
19
- storekitMode?: STOREKIT_OPTIONS | undefined;
20
- }) => void;
21
- /**
22
- * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
23
- * ## Usage
24
-
25
- ```tsx
26
- import React, {useEffect} from 'react';
27
- import {View} from 'react-native';
28
- import {initConnection} from 'react-native-iap';
29
-
30
- const App = () => {
31
- useEffect(() => {
32
- void initConnection();
33
- }, []);
34
-
35
- return <View />;
36
- };
37
- ```
38
- */
39
- export declare const initConnection: () => Promise<boolean>;
40
- /**
41
- * Disconnects from native SDK
42
- * Usage
43
- * ```tsx
44
- import React, {useEffect} from 'react';
45
- import {View} from 'react-native';
46
- import {endConnection} from 'react-native-iap';
47
-
48
- const App = () => {
49
- useEffect(() => {
50
- return () => {
51
- void endConnection();
52
- };
53
- }, []);
54
-
55
- return <View />;
56
- };
57
- ```
58
- * @returns {Promise<void>}
59
- */
60
- export declare const endConnection: () => Promise<boolean>;
61
- /**
62
- * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.
63
- * @returns {Promise<boolean>}
64
- */
65
- export declare const flushFailedPurchasesCachedAsPendingAndroid: () => Promise<boolean>;
66
- /**
67
- * Get a list of products (consumable and non-consumable items, but not subscriptions)
68
- ## Usage
69
-
70
- ```ts
71
- import React, {useState} from 'react';
72
- import {Platform} from 'react-native';
73
- import {getProducts, Product} from 'react-native-iap';
74
-
75
- const skus = Platform.select({
76
- ios: ['com.example.consumableIos'],
77
- android: ['com.example.consumableAndroid'],
78
- });
79
-
80
- const App = () => {
81
- const [products, setProducts] = useState<Product[]>([]);
82
-
83
- const handleProducts = async () => {
84
- const items = await getProducts({skus});
85
-
86
- setProducts(items);
87
- };
88
-
89
- useEffect(() => {
90
- void handleProducts();
91
- }, []);
92
-
93
- return (
94
- <>
95
- {products.map((product) => (
96
- <Text key={product.productId}>{product.productId}</Text>
97
- ))}
98
- </>
99
- );
100
- };
101
- ```
102
-
103
- Just a few things to keep in mind:
104
-
105
- - You can get your products in `componentDidMount`, `useEffect` or another appropriate area of your app.
106
- - Since a user may start your app with a bad or no internet connection, preparing/getting the items more than once may be a good idea.
107
- - If the user has no IAPs available when the app starts first, you may want to check again when the user enters your IAP store.
108
-
109
- */
110
- export declare const getProducts: ({ skus, }: {
111
- skus: string[];
112
- }) => Promise<Array<Product>>;
113
- /**
114
- * Get a list of subscriptions
115
- * ## Usage
116
-
117
- ```tsx
118
- import React, {useCallback} from 'react';
119
- import {View} from 'react-native';
120
- import {getSubscriptions} from 'react-native-iap';
121
-
122
- const App = () => {
123
- const subscriptions = useCallback(
124
- async () =>
125
- await getSubscriptions({skus:['com.example.product1', 'com.example.product2']}),
126
- [],
127
- );
128
-
129
- return <View />;
130
- };
131
- ```
132
-
133
- */
134
- export declare const getSubscriptions: ({ skus, }: {
135
- skus: string[];
136
- }) => Promise<Subscription[]>;
137
- /**
138
- * Gets an inventory of purchases made by the user regardless of consumption status
139
- * ## Usage
140
-
141
- ```tsx
142
- import React, {useCallback} from 'react';
143
- import {View} from 'react-native';
144
- import {getPurchaseHistory} from 'react-native-iap';
145
-
146
- const App = () => {
147
- const history = useCallback(
148
- async () =>
149
- await getPurchaseHistory([
150
- 'com.example.product1',
151
- 'com.example.product2',
152
- ]),
153
- [],
154
- );
155
-
156
- return <View />;
157
- };
158
- ```
159
- @param {alsoPublishToEventListener}:boolean. (IOS Sk2 only) When `true`, every element will also be pushed to the purchaseUpdated listener.
160
- Note that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`
161
- @param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically
162
- finished. This means that if you call this method again you won't get the same result on the same device. On the other hand, if `false` you'd
163
- have to manually finish the returned transaction once you have delivered the content to your user.
164
- @param {onlyIncludeActiveItems}:boolean. (IOS Sk2 only). Defaults to false, meaning that it will return one transaction per item purchased.
165
- @See https://developer.apple.com/documentation/storekit/transaction/3851204-currententitlements for details
166
- */
167
- export declare const getPurchaseHistory: ({ alsoPublishToEventListener, automaticallyFinishRestoredTransactions, onlyIncludeActiveItems, }?: {
168
- alsoPublishToEventListener?: boolean | undefined;
169
- automaticallyFinishRestoredTransactions?: boolean | undefined;
170
- onlyIncludeActiveItems?: boolean | undefined;
171
- }) => Promise<Purchase[]>;
172
- /**
173
- * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)
174
- * ## Usage
175
-
176
- ```tsx
177
- import React, {useCallback} from 'react';
178
- import {View} from 'react-native';
179
- import {getAvailablePurchases} from 'react-native-iap';
180
-
181
- const App = () => {
182
- const availablePurchases = useCallback(
183
- async () => await getAvailablePurchases(),
184
- [],
185
- );
186
-
187
- return <View />;
188
- };
189
- ```
190
-
191
- ## Restoring purchases
192
-
193
- You can use `getAvailablePurchases()` to do what's commonly understood as "restoring" purchases.
194
-
195
- :::note
196
- For debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.
197
- :::
198
-
199
- :::warning
200
- Beware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.
201
- :::
202
-
203
- ```tsx
204
- import React from 'react';
205
- import {Button} from 'react-native';
206
- import {getAvailablePurchases,finishTransaction} from 'react-native-iap';
207
-
208
- const App = () => {
209
- handleRestore = async () => {
210
- try {
211
- const purchases = await getAvailablePurchases();
212
- const newState = {premium: false, ads: true};
213
- let titles = [];
214
-
215
- await Promise.all(purchases.map(async purchase => {
216
- switch (purchase.productId) {
217
- case 'com.example.premium':
218
- newState.premium = true;
219
- titles.push('Premium Version');
220
- break;
221
-
222
- case 'com.example.no_ads':
223
- newState.ads = false;
224
- titles.push('No Ads');
225
- break;
226
-
227
- case 'com.example.coins100':
228
- await finishTransaction({purchase});
229
- CoinStore.addCoins(100);
230
- }
231
- }));
232
-
233
- Alert.alert(
234
- 'Restore Successful',
235
- `You successfully restored the following purchases: ${titles.join(', ')}`,
236
- );
237
- } catch (error) {
238
- console.warn(error);
239
- Alert.alert(error.message);
240
- }
241
- };
242
-
243
- return (
244
- <Button title="Restore purchases" onPress={handleRestore} />
245
- )
246
- };
247
- ```
248
- @param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.
249
- Note that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`
250
- @param {onlyIncludeActiveItems}:boolean. (IOS Sk2 only). Defaults to true, meaning that it will return the transaction if suscription has not expired.
251
- @See https://developer.apple.com/documentation/storekit/transaction/3851204-currententitlements for details
252
- *
253
- */
254
- export declare const getAvailablePurchases: ({ alsoPublishToEventListener, automaticallyFinishRestoredTransactions, onlyIncludeActiveItems, }?: {
255
- alsoPublishToEventListener?: boolean | undefined;
256
- automaticallyFinishRestoredTransactions?: boolean | undefined;
257
- onlyIncludeActiveItems?: boolean | undefined;
258
- }) => Promise<Purchase[]>;
259
- /**
260
- * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
261
- * Request a purchase for a product (consumables or non-consumables).
262
-
263
- The response will be received through the `PurchaseUpdatedListener`.
264
-
265
- :::note
266
- `andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend
267
- always keeping at false, and verifying the transaction receipts on the server-side.
268
- :::
269
-
270
- ## Signature
271
-
272
- ```ts
273
- requestPurchase(
274
- The product's sku/ID
275
- sku,
276
-
277
-
278
- * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.
279
- * @default false
280
-
281
- andDangerouslyFinishTransactionAutomaticallyIOS = false,
282
-
283
- /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
284
- obfuscatedAccountIdAndroid,
285
-
286
- Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
287
- obfuscatedProfileIdAndroid,
288
-
289
- The purchaser's user ID
290
- applicationUsername,
291
- ): Promise<ProductPurchase>;
292
- ```
293
-
294
- ## Usage
295
-
296
- ```tsx
297
- import React, { useState, useEffect } from 'react';
298
- import {Button} from 'react-native';
299
- import {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';
300
-
301
- const App = () => {
302
- const [products, setProducts] = useState<Product[]>([]);
303
-
304
- useEffect(() => {
305
- const fetchProducts = async () => {
306
- const productList = await getProducts({skus:['com.example.product']});
307
- setProducts(productList);
308
- }
309
-
310
- fetchProducts();
311
- }, []);
312
-
313
- const handlePurchase = async (sku: Sku) => {
314
- await requestPurchase({sku});
315
- };
316
-
317
- return (
318
- <>
319
- {products.map((product) => (
320
- <Button
321
- key={product.productId}
322
- title="Buy product"
323
- onPress={() => handlePurchase(product.productId)}
324
- />
325
- ))}
326
- </>
327
- );
328
- };
329
- ```
330
-
331
- */
332
- export declare const requestPurchase: (request: RequestPurchase) => Promise<ProductPurchase | ProductPurchase[] | void>;
333
- /**
334
- * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
335
- * Request a purchase for a subscription.
336
-
337
- The response will be received through the `PurchaseUpdatedListener`.
338
-
339
- :::note
340
- `andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend
341
- always keeping at false, and verifying the transaction receipts on the server-side.
342
- :::
343
-
344
- ## Signature
345
-
346
- ```ts
347
- requestSubscription(
348
- The product's sku/ID
349
- sku,
350
-
351
-
352
- * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.
353
- * @default false
354
-
355
- andDangerouslyFinishTransactionAutomaticallyIOS = false,
356
-
357
- purchaseToken that the user is upgrading or downgrading from (Android).
358
- purchaseTokenAndroid,
359
-
360
- UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
361
- prorationModeAndroid = -1,
362
-
363
- /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
364
- obfuscatedAccountIdAndroid,
365
-
366
- Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
367
- obfuscatedProfileIdAndroid,
368
-
369
- The purchaser's user ID
370
- applicationUsername,
371
- ): Promise<SubscriptionPurchase>
372
- ```
373
-
374
- ## Usage
375
-
376
- ```tsx
377
- import React, {useCallback} from 'react';
378
- import {Button} from 'react-native';
379
- import {
380
- requestSubscription,
381
- Product,
382
- Sku,
383
- getSubscriptions,
384
- } from 'react-native-iap';
385
-
386
- const App = () => {
387
- const subscriptions = useCallback(
388
- async () => getSubscriptions(['com.example.subscription']),
389
- [],
390
- );
391
-
392
- const handlePurchase = async (sku: Sku) => {
393
- await requestSubscription({sku});
394
- };
395
-
396
- return (
397
- <>
398
- {subscriptions.map((subscription) => (
399
- <Button
400
- key={subscription.productId}
401
- title="Buy subscription"
402
- onPress={() => handlePurchase(subscription.productId)}
403
- />
404
- ))}
405
- </>
406
- );
407
- };
408
- ```
409
- */
410
- export declare const requestSubscription: (request: RequestSubscription) => Promise<SubscriptionPurchase | SubscriptionPurchase[] | null | void>;
411
- /**
412
- * Finish Transaction (both platforms)
413
- * Abstracts Finish Transaction
414
- * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.
415
- * Call this after you have persisted the purchased state to your server or local data in your app.
416
- * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**
417
- * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.
418
- *
419
- ```tsx
420
- import React from 'react';
421
- import {Button} from 'react-native';
422
- import {finishTransaction} from 'react-native-iap';
423
-
424
- const App = () => {
425
- const handlePurchase = async () => {
426
- // ... handle the purchase request
427
-
428
- const result = finishTransaction({purchase});
429
- };
430
-
431
- return <Button title="Buy product" onPress={handlePurchase} />;
432
- };
433
- ```
434
- @returns {Promise<PurchaseResult | boolean>} Android: PurchaseResult, iOS: true
435
- */
436
- export declare const finishTransaction: ({ purchase, isConsumable, developerPayloadAndroid, }: {
437
- purchase: Purchase;
438
- isConsumable?: boolean | undefined;
439
- developerPayloadAndroid?: string | undefined;
440
- }) => Promise<PurchaseResult | boolean>;
441
- /**
442
- * Deeplinks to native interface that allows users to manage their subscriptions
443
- *
444
- */
445
- export declare const deepLinkToSubscriptions: ({ sku, isAmazonDevice, }: {
446
- sku?: string | undefined;
447
- isAmazonDevice?: boolean | undefined;
448
- }) => Promise<void>;
449
- /**
450
- * Get App Store and Google Play device region.
451
- *
452
- * App Store: string - ISO 3166-1 Alpha-3 country code representation https://developer.apple.com/documentation/storekit/storefront.
453
- *
454
- * Google Play: string - ISO-3166-1 alpha2 country code representation https://developer.android.com/reference/com/android/billingclient/api/BillingConfig#getCountryCode()
455
- *
456
- * ```tsx
457
- * import React from 'react';
458
- * import {getStorefront} from 'react-native-iap';
459
- *
460
- * const App = () => {
461
- * React.useEffect(() => {
462
- * getStorefront().then((countryCode) => {
463
- * // ... handle region
464
- * });
465
- * }, []);
466
- * };
467
- * ```
468
- */
469
- export declare const getStorefront: () => Promise<string>;
470
- /**
471
- * Get the app transaction information (iOS only, StoreKit 2).
472
- * This contains the appTransactionID and other app purchase information.
473
- *
474
- * @platform iOS (16.0+)
475
- * @returns {Promise<AppTransaction>} A promise that resolves to the app transaction information
476
- *
477
- * @example
478
- * ```tsx
479
- * import React from 'react';
480
- * import {getAppTransaction} from 'react-native-iap';
481
- *
482
- * const App = () => {
483
- * React.useEffect(() => {
484
- * getAppTransaction().then((appTransaction) => {
485
- * console.log('App Transaction ID:', appTransaction.appTransactionID);
486
- * }).catch(error => {
487
- * console.error('Error getting app transaction:', error);
488
- * });
489
- * }, []);
490
- * };
491
- * ```
492
- */
493
- export declare const getAppTransaction: () => Promise<{
494
- appTransactionID: string;
495
- originalAppVersion: string;
496
- originalPurchaseDate: number;
497
- deviceVerification: string;
498
- deviceVerificationNonce: string;
499
- appVersion: string;
500
- signedDate: number;
501
- environment: string;
502
- }>;
503
- //# sourceMappingURL=iap.d.ts.map