@stripe/stripe-react-native 0.44.0 → 0.46.0

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 (334) hide show
  1. package/.clang-format +90 -0
  2. package/.editorconfig +3 -0
  3. package/CHANGELOG.md +13 -1
  4. package/README.md +0 -3
  5. package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
  6. package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
  7. package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
  8. package/android/.gradle/8.11.1/executionHistory/executionHistory.bin +0 -0
  9. package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
  10. package/android/.gradle/8.11.1/fileHashes/fileHashes.bin +0 -0
  11. package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  13. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  14. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  15. package/android/.gradle/config.properties +2 -0
  16. package/android/.gradle/file-system.probe +0 -0
  17. package/android/.idea/caches/deviceStreaming.xml +619 -0
  18. package/android/.idea/compiler.xml +6 -0
  19. package/android/.idea/gradle.xml +19 -0
  20. package/android/.idea/migrations.xml +10 -0
  21. package/android/.idea/misc.xml +10 -0
  22. package/android/.idea/runConfigurations.xml +17 -0
  23. package/android/.idea/vcs.xml +6 -0
  24. package/android/build.gradle +90 -18
  25. package/android/gradle.properties +1 -1
  26. package/android/local.properties +8 -0
  27. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +15 -6
  28. package/android/src/main/java/com/reactnativestripesdk/CardChangeEvent.kt +56 -0
  29. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +4 -4
  30. package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +55 -45
  31. package/android/src/main/java/com/reactnativestripesdk/{CardFocusEvent.kt → CardFocusChangeEvent.kt} +2 -2
  32. package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +17 -16
  33. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +5 -5
  34. package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +39 -33
  35. package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +35 -36
  36. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +224 -0
  37. package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +238 -0
  38. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +11 -26
  39. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +14 -6
  40. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +3 -17
  41. package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +20 -6
  42. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +63 -44
  43. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -1
  44. package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +17 -0
  45. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +266 -0
  46. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +25 -33
  47. package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +113 -0
  48. package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -3
  49. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +180 -65
  50. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +34 -4
  51. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +3 -17
  52. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +33 -27
  53. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +49 -24
  54. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +19 -24
  55. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +11 -29
  56. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +36 -12
  57. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +5 -3
  58. package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -0
  59. package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +2 -2
  60. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +21 -0
  61. package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +52 -0
  62. package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerDelegate.java +49 -0
  63. package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddToWalletButtonManagerInterface.java +25 -0
  64. package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerDelegate.java +64 -0
  65. package/android/src/oldarch/java/com/facebook/react/viewmanagers/AddressSheetViewManagerInterface.java +30 -0
  66. package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerDelegate.java +41 -0
  67. package/android/src/oldarch/java/com/facebook/react/viewmanagers/ApplePayButtonManagerInterface.java +20 -0
  68. package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerDelegate.java +36 -0
  69. package/android/src/oldarch/java/com/facebook/react/viewmanagers/AuBECSDebitFormManagerInterface.java +20 -0
  70. package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerDelegate.java +73 -0
  71. package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFieldManagerInterface.java +31 -0
  72. package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerDelegate.java +67 -0
  73. package/android/src/oldarch/java/com/facebook/react/viewmanagers/CardFormManagerInterface.java +29 -0
  74. package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +49 -0
  75. package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +21 -0
  76. package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerDelegate.java +38 -0
  77. package/android/src/oldarch/java/com/facebook/react/viewmanagers/GooglePayButtonManagerInterface.java +19 -0
  78. package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerDelegate.java +32 -0
  79. package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeContainerManagerInterface.java +17 -0
  80. package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +310 -0
  81. package/ios/AddressSheet/AddressSheetUtils.swift +21 -19
  82. package/ios/AddressSheet/AddressSheetView.swift +23 -17
  83. package/ios/ApplePayButtonManager.m +0 -1
  84. package/ios/ApplePayButtonManager.swift +1 -3
  85. package/ios/ApplePayButtonView.swift +25 -20
  86. package/ios/ApplePayViewController.swift +22 -22
  87. package/ios/AuBECSDebitFormView.swift +14 -8
  88. package/ios/CardFieldManager.swift +1 -4
  89. package/ios/CardFieldView.swift +28 -25
  90. package/ios/CardFormManager.swift +1 -4
  91. package/ios/CardFormView.swift +25 -16
  92. package/ios/CustomerSheet/CustomerSheetUtils.swift +12 -16
  93. package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +8 -8
  94. package/ios/EmbeddedPaymentElementManager.m +6 -0
  95. package/ios/EmbeddedPaymentElementView.swift +49 -0
  96. package/ios/NewArch/AddToWalletButtonComponentView.h +10 -0
  97. package/ios/NewArch/AddToWalletButtonComponentView.mm +93 -0
  98. package/ios/NewArch/AddressSheetViewComponentView.h +10 -0
  99. package/ios/NewArch/AddressSheetViewComponentView.mm +109 -0
  100. package/ios/NewArch/ApplePayButtonComponentView.h +10 -0
  101. package/ios/NewArch/ApplePayButtonComponentView.mm +124 -0
  102. package/ios/NewArch/AuBECSDebitFormComponentView.h +10 -0
  103. package/ios/NewArch/AuBECSDebitFormComponentView.mm +95 -0
  104. package/ios/NewArch/CardFieldComponentView.h +10 -0
  105. package/ios/NewArch/CardFieldComponentView.mm +125 -0
  106. package/ios/NewArch/CardFormComponentView.h +10 -0
  107. package/ios/NewArch/CardFormComponentView.mm +108 -0
  108. package/ios/NewArch/EmbeddedPaymentElementViewComponentView.h +10 -0
  109. package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +81 -0
  110. package/ios/NewArch/StripeContainerComponentView.h +10 -0
  111. package/ios/NewArch/StripeContainerComponentView.mm +74 -0
  112. package/ios/NewArch/StripeNewArchConversions.h +20 -0
  113. package/ios/NewArch/StripeNewArchConversions.mm +47 -0
  114. package/ios/OldArch/StripeSdkEventEmitterCompat.h +27 -0
  115. package/ios/OldArch/StripeSdkEventEmitterCompat.m +105 -0
  116. package/ios/PaymentOptionDisplayData+ReactNative.swift +55 -0
  117. package/ios/PaymentSheetAppearance.swift +194 -1
  118. package/ios/PushProvisioning/AddToWalletButtonView.swift +19 -13
  119. package/ios/StripeContainerView.swift +5 -3
  120. package/ios/StripeSdk.h +21 -0
  121. package/ios/StripeSdk.mm +415 -0
  122. package/ios/StripeSdkEmitter.swift +19 -0
  123. package/ios/{StripeSdk+CustomerSheet.swift → StripeSdkImpl+CustomerSheet.swift} +24 -25
  124. package/ios/StripeSdkImpl+Embedded.swift +327 -0
  125. package/ios/{StripeSdk+PaymentSheet.swift → StripeSdkImpl+PaymentSheet.swift} +18 -29
  126. package/ios/{StripeSdk.swift → StripeSdkImpl.swift} +50 -72
  127. package/ios/StripeSwiftInterop.h +25 -0
  128. package/ios/stripe_react_native.h +2 -0
  129. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  130. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  131. package/lib/commonjs/components/AddressSheet.js +1 -1
  132. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  133. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  134. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  135. package/lib/commonjs/components/CardField.js +1 -1
  136. package/lib/commonjs/components/CardField.js.map +1 -1
  137. package/lib/commonjs/components/CardForm.js +1 -1
  138. package/lib/commonjs/components/CardForm.js.map +1 -1
  139. package/lib/commonjs/components/CustomerSheet.js +1 -1
  140. package/lib/commonjs/components/CustomerSheet.js.map +1 -1
  141. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  142. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  143. package/lib/commonjs/components/StripeContainer.js +1 -1
  144. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  145. package/lib/commonjs/components/StripeProvider.js +1 -1
  146. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  147. package/lib/commonjs/events.js +2 -0
  148. package/lib/commonjs/events.js.map +1 -0
  149. package/lib/commonjs/functions.js +1 -1
  150. package/lib/commonjs/functions.js.map +1 -1
  151. package/lib/commonjs/index.js +1 -1
  152. package/lib/commonjs/index.js.map +1 -1
  153. package/lib/commonjs/specs/NativeAddToWalletButton.js +2 -0
  154. package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -0
  155. package/lib/commonjs/specs/NativeAddressSheet.js +2 -0
  156. package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -0
  157. package/lib/commonjs/specs/NativeApplePayButton.js +2 -0
  158. package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -0
  159. package/lib/commonjs/specs/NativeAuBECSDebitForm.js +2 -0
  160. package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -0
  161. package/lib/commonjs/specs/NativeCardField.js +2 -0
  162. package/lib/commonjs/specs/NativeCardField.js.map +1 -0
  163. package/lib/commonjs/specs/NativeCardForm.js +2 -0
  164. package/lib/commonjs/specs/NativeCardForm.js.map +1 -0
  165. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +2 -0
  166. package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -0
  167. package/lib/commonjs/specs/NativeGooglePayButton.js +2 -0
  168. package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -0
  169. package/lib/commonjs/specs/NativeStripeContainer.js +2 -0
  170. package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -0
  171. package/lib/commonjs/specs/NativeStripeSdkModule.js +2 -0
  172. package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -0
  173. package/lib/commonjs/specs/utils.js +2 -0
  174. package/lib/commonjs/specs/utils.js.map +1 -0
  175. package/lib/commonjs/types/EmbeddedPaymentElement.js +2 -0
  176. package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -0
  177. package/lib/commonjs/types/PaymentSheet.js +1 -1
  178. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  179. package/lib/module/components/AddToWalletButton.js +1 -1
  180. package/lib/module/components/AddToWalletButton.js.map +1 -1
  181. package/lib/module/components/AddressSheet.js +1 -1
  182. package/lib/module/components/AddressSheet.js.map +1 -1
  183. package/lib/module/components/AuBECSDebitForm.js +1 -1
  184. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  185. package/lib/module/components/CardField.js +1 -1
  186. package/lib/module/components/CardField.js.map +1 -1
  187. package/lib/module/components/CardForm.js +1 -1
  188. package/lib/module/components/CardForm.js.map +1 -1
  189. package/lib/module/components/CustomerSheet.js +1 -1
  190. package/lib/module/components/CustomerSheet.js.map +1 -1
  191. package/lib/module/components/PlatformPayButton.js +1 -1
  192. package/lib/module/components/PlatformPayButton.js.map +1 -1
  193. package/lib/module/components/StripeContainer.js +1 -1
  194. package/lib/module/components/StripeContainer.js.map +1 -1
  195. package/lib/module/components/StripeProvider.js +1 -1
  196. package/lib/module/components/StripeProvider.js.map +1 -1
  197. package/lib/module/events.js +2 -0
  198. package/lib/module/events.js.map +1 -0
  199. package/lib/module/functions.js +1 -1
  200. package/lib/module/functions.js.map +1 -1
  201. package/lib/module/index.js +1 -1
  202. package/lib/module/index.js.map +1 -1
  203. package/lib/module/specs/NativeAddToWalletButton.js +2 -0
  204. package/lib/module/specs/NativeAddToWalletButton.js.map +1 -0
  205. package/lib/module/specs/NativeAddressSheet.js +2 -0
  206. package/lib/module/specs/NativeAddressSheet.js.map +1 -0
  207. package/lib/module/specs/NativeApplePayButton.js +2 -0
  208. package/lib/module/specs/NativeApplePayButton.js.map +1 -0
  209. package/lib/module/specs/NativeAuBECSDebitForm.js +2 -0
  210. package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -0
  211. package/lib/module/specs/NativeCardField.js +2 -0
  212. package/lib/module/specs/NativeCardField.js.map +1 -0
  213. package/lib/module/specs/NativeCardForm.js +2 -0
  214. package/lib/module/specs/NativeCardForm.js.map +1 -0
  215. package/lib/module/specs/NativeEmbeddedPaymentElement.js +2 -0
  216. package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -0
  217. package/lib/module/specs/NativeGooglePayButton.js +2 -0
  218. package/lib/module/specs/NativeGooglePayButton.js.map +1 -0
  219. package/lib/module/specs/NativeStripeContainer.js +2 -0
  220. package/lib/module/specs/NativeStripeContainer.js.map +1 -0
  221. package/lib/module/specs/NativeStripeSdkModule.js +2 -0
  222. package/lib/module/specs/NativeStripeSdkModule.js.map +1 -0
  223. package/lib/module/specs/utils.js +2 -0
  224. package/lib/module/specs/utils.js.map +1 -0
  225. package/lib/module/types/EmbeddedPaymentElement.js +2 -0
  226. package/lib/module/types/EmbeddedPaymentElement.js.map +1 -0
  227. package/lib/module/types/PaymentSheet.js +1 -1
  228. package/lib/module/types/PaymentSheet.js.map +1 -1
  229. package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -1
  230. package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -1
  231. package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -1
  232. package/lib/typescript/src/components/CardField.d.ts +1 -1
  233. package/lib/typescript/src/components/CardField.d.ts.map +1 -1
  234. package/lib/typescript/src/components/CardForm.d.ts +1 -1
  235. package/lib/typescript/src/components/CardForm.d.ts.map +1 -1
  236. package/lib/typescript/src/components/CustomerSheet.d.ts +1 -1
  237. package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -1
  238. package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -1
  239. package/lib/typescript/src/events.d.ts +13 -0
  240. package/lib/typescript/src/events.d.ts.map +1 -0
  241. package/lib/typescript/src/functions.d.ts.map +1 -1
  242. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +4 -4
  243. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -1
  244. package/lib/typescript/src/hooks/useStripe.d.ts +2 -2
  245. package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -1
  246. package/lib/typescript/src/index.d.ts +2 -0
  247. package/lib/typescript/src/index.d.ts.map +1 -1
  248. package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts +27 -0
  249. package/lib/typescript/src/specs/NativeAddToWalletButton.d.ts.map +1 -0
  250. package/lib/typescript/src/specs/NativeAddressSheet.d.ts +34 -0
  251. package/lib/typescript/src/specs/NativeAddressSheet.d.ts.map +1 -0
  252. package/lib/typescript/src/specs/NativeApplePayButton.d.ts +28 -0
  253. package/lib/typescript/src/specs/NativeApplePayButton.d.ts.map +1 -0
  254. package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts +19 -0
  255. package/lib/typescript/src/specs/NativeAuBECSDebitForm.d.ts.map +1 -0
  256. package/lib/typescript/src/specs/NativeCardField.d.ts +33 -0
  257. package/lib/typescript/src/specs/NativeCardField.d.ts.map +1 -0
  258. package/lib/typescript/src/specs/NativeCardForm.d.ts +31 -0
  259. package/lib/typescript/src/specs/NativeCardForm.d.ts.map +1 -0
  260. package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +17 -0
  261. package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -0
  262. package/lib/typescript/src/specs/NativeGooglePayButton.d.ts +11 -0
  263. package/lib/typescript/src/specs/NativeGooglePayButton.d.ts.map +1 -0
  264. package/lib/typescript/src/specs/NativeStripeContainer.d.ts +8 -0
  265. package/lib/typescript/src/specs/NativeStripeContainer.d.ts.map +1 -0
  266. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +93 -0
  267. package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -0
  268. package/lib/typescript/src/specs/utils.d.ts +20 -0
  269. package/lib/typescript/src/specs/utils.d.ts.map +1 -0
  270. package/lib/typescript/src/types/CustomerSheet.d.ts +1 -5
  271. package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -1
  272. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +161 -0
  273. package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -0
  274. package/lib/typescript/src/types/PaymentSheet.d.ts +97 -4
  275. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
  276. package/lib/typescript/src/types/components/CardFieldInput.d.ts +3 -2
  277. package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -1
  278. package/lib/typescript/src/types/components/CardFormView.d.ts +3 -1
  279. package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -1
  280. package/package.json +22 -2
  281. package/src/components/AddToWalletButton.tsx +2 -5
  282. package/src/components/AddressSheet.tsx +5 -16
  283. package/src/components/AuBECSDebitForm.tsx +3 -12
  284. package/src/components/CardField.tsx +20 -30
  285. package/src/components/CardForm.tsx +14 -29
  286. package/src/components/CustomerSheet.tsx +23 -25
  287. package/src/components/PlatformPayButton.tsx +6 -6
  288. package/src/components/StripeContainer.tsx +5 -12
  289. package/src/components/StripeProvider.tsx +1 -1
  290. package/src/events.ts +49 -0
  291. package/src/functions.ts +13 -24
  292. package/src/hooks/useFinancialConnectionsSheet.tsx +2 -2
  293. package/src/hooks/useStripe.tsx +2 -2
  294. package/src/index.tsx +3 -0
  295. package/src/specs/NativeAddToWalletButton.ts +40 -0
  296. package/src/specs/NativeAddressSheet.ts +50 -0
  297. package/src/specs/NativeApplePayButton.ts +40 -0
  298. package/src/specs/NativeAuBECSDebitForm.ts +24 -0
  299. package/src/specs/NativeCardField.ts +51 -0
  300. package/src/specs/NativeCardForm.ts +43 -0
  301. package/src/specs/NativeEmbeddedPaymentElement.ts +28 -0
  302. package/src/specs/NativeGooglePayButton.ts +20 -0
  303. package/src/specs/NativeStripeContainer.ts +12 -0
  304. package/src/specs/NativeStripeSdkModule.ts +219 -0
  305. package/src/specs/utils.ts +22 -0
  306. package/src/types/CustomerSheet.ts +1 -5
  307. package/src/types/EmbeddedPaymentElement.tsx +467 -0
  308. package/src/types/PaymentSheet.ts +114 -4
  309. package/src/types/components/CardFieldInput.ts +1 -2
  310. package/src/types/components/CardFormView.ts +1 -1
  311. package/stripe-react-native.podspec +27 -2
  312. package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +0 -54
  313. package/ios/StripeSdk.m +0 -244
  314. package/lib/commonjs/NativeStripeSdk.js +0 -2
  315. package/lib/commonjs/NativeStripeSdk.js.map +0 -1
  316. package/lib/commonjs/components/ApplePayButtonNative.js +0 -2
  317. package/lib/commonjs/components/ApplePayButtonNative.js.map +0 -1
  318. package/lib/commonjs/components/GooglePayButtonNative.js +0 -2
  319. package/lib/commonjs/components/GooglePayButtonNative.js.map +0 -1
  320. package/lib/module/NativeStripeSdk.js +0 -2
  321. package/lib/module/NativeStripeSdk.js.map +0 -1
  322. package/lib/module/components/ApplePayButtonNative.js +0 -2
  323. package/lib/module/components/ApplePayButtonNative.js.map +0 -1
  324. package/lib/module/components/GooglePayButtonNative.js +0 -2
  325. package/lib/module/components/GooglePayButtonNative.js.map +0 -1
  326. package/lib/typescript/src/NativeStripeSdk.d.ts +0 -58
  327. package/lib/typescript/src/NativeStripeSdk.d.ts.map +0 -1
  328. package/lib/typescript/src/components/ApplePayButtonNative.d.ts +0 -4
  329. package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +0 -1
  330. package/lib/typescript/src/components/GooglePayButtonNative.d.ts +0 -4
  331. package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +0 -1
  332. package/src/NativeStripeSdk.tsx +0 -159
  333. package/src/components/ApplePayButtonNative.tsx +0 -5
  334. package/src/components/GooglePayButtonNative.tsx +0 -7
@@ -1,22 +1,25 @@
1
1
  package com.reactnativestripesdk
2
2
 
3
+ import android.annotation.SuppressLint
3
4
  import android.app.Activity
5
+ import android.app.Application
4
6
  import android.content.Intent
7
+ import android.os.Bundle
5
8
  import android.util.Log
9
+ import android.view.ViewGroup
6
10
  import androidx.fragment.app.FragmentActivity
7
11
  import com.facebook.react.bridge.BaseActivityEventListener
8
12
  import com.facebook.react.bridge.Promise
9
13
  import com.facebook.react.bridge.ReactApplicationContext
10
- import com.facebook.react.bridge.ReactContext
11
- import com.facebook.react.bridge.ReactContextBaseJavaModule
12
14
  import com.facebook.react.bridge.ReactMethod
13
15
  import com.facebook.react.bridge.ReadableArray
14
16
  import com.facebook.react.bridge.ReadableMap
17
+ import com.facebook.react.bridge.UiThreadUtil
15
18
  import com.facebook.react.bridge.WritableMap
16
19
  import com.facebook.react.bridge.WritableNativeMap
17
20
  import com.facebook.react.module.annotations.ReactModule
18
- import com.facebook.react.modules.core.DeviceEventManagerModule
19
21
  import com.reactnativestripesdk.addresssheet.AddressLauncherFragment
22
+ import com.reactnativestripesdk.customersheet.CustomerSheetFragment
20
23
  import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
21
24
  import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
22
25
  import com.reactnativestripesdk.utils.CreateTokenErrorType
@@ -61,6 +64,7 @@ import com.stripe.android.model.SetupIntent
61
64
  import com.stripe.android.model.Token
62
65
  import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
63
66
  import com.stripe.android.paymentsheet.PaymentSheet
67
+ import kotlinx.coroutines.CompletableDeferred
64
68
  import kotlinx.coroutines.CoroutineScope
65
69
  import kotlinx.coroutines.Dispatchers
66
70
  import kotlinx.coroutines.launch
@@ -69,9 +73,7 @@ import org.json.JSONObject
69
73
  @ReactModule(name = StripeSdkModule.NAME)
70
74
  class StripeSdkModule(
71
75
  reactContext: ReactApplicationContext,
72
- ) : ReactContextBaseJavaModule(reactContext) {
73
- override fun getName(): String = NAME
74
-
76
+ ) : NativeStripeSdkModuleSpec(reactContext) {
75
77
  var cardFieldView: CardFieldView? = null
76
78
  var cardFormView: CardFormView? = null
77
79
 
@@ -89,7 +91,9 @@ class StripeSdkModule(
89
91
 
90
92
  private var customerSheetFragment: CustomerSheetFragment? = null
91
93
 
92
- internal var eventListenerCount = 0
94
+ internal var embeddedIntentCreationCallback = CompletableDeferred<ReadableMap>()
95
+
96
+ internal var composeCompatView: StripeAbstractComposeView.CompatView? = null
93
97
 
94
98
  // If you create a new Fragment, you must put the tag here, otherwise result callbacks for that
95
99
  // Fragment will not work on RN < 0.65
@@ -176,17 +180,18 @@ class StripeSdkModule(
176
180
  )
177
181
  }
178
182
 
179
- override fun getConstants(): MutableMap<String, Any> =
180
- hashMapOf(
183
+ @SuppressLint("RestrictedApi")
184
+ override fun getTypedExportedConstants() =
185
+ mapOf(
181
186
  "API_VERSIONS" to
182
- hashMapOf(
187
+ mapOf(
183
188
  "CORE" to ApiVersion.API_VERSION_CODE,
184
189
  "ISSUING" to PushProvisioningProxy.getApiVersion(),
185
190
  ),
186
191
  )
187
192
 
188
193
  @ReactMethod
189
- fun initialise(
194
+ override fun initialise(
190
195
  params: ReadableMap,
191
196
  promise: Promise,
192
197
  ) {
@@ -213,21 +218,23 @@ class StripeSdkModule(
213
218
  stripe = Stripe(reactApplicationContext, publishableKey, stripeAccountId)
214
219
 
215
220
  PaymentConfiguration.init(reactApplicationContext, publishableKey, stripeAccountId)
221
+
222
+ preventActivityRecreation()
223
+ setupComposeCompatView()
224
+
216
225
  promise.resolve(null)
217
226
  }
218
227
 
219
228
  @ReactMethod
220
- fun initPaymentSheet(
229
+ override fun initPaymentSheet(
221
230
  params: ReadableMap,
222
231
  promise: Promise,
223
232
  ) {
224
233
  getCurrentActivityOrResolveWithError(promise)?.let { activity ->
225
234
  paymentSheetFragment?.removeFragment(reactApplicationContext)
235
+ val bundle = toBundleObject(params)
226
236
  paymentSheetFragment =
227
- PaymentSheetFragment(reactApplicationContext, promise).also {
228
- val bundle = toBundleObject(params)
229
- it.arguments = bundle
230
- }
237
+ PaymentSheetFragment.create(reactApplicationContext, bundle, promise)
231
238
  try {
232
239
  activity.supportFragmentManager
233
240
  .beginTransaction()
@@ -240,7 +247,7 @@ class StripeSdkModule(
240
247
  }
241
248
 
242
249
  @ReactMethod
243
- fun presentPaymentSheet(
250
+ override fun presentPaymentSheet(
244
251
  options: ReadableMap,
245
252
  promise: Promise,
246
253
  ) {
@@ -261,7 +268,7 @@ class StripeSdkModule(
261
268
  }
262
269
 
263
270
  @ReactMethod
264
- fun confirmPaymentSheetPayment(promise: Promise) {
271
+ override fun confirmPaymentSheetPayment(promise: Promise) {
265
272
  if (paymentSheetFragment == null) {
266
273
  promise.resolve(PaymentSheetFragment.createMissingInitError())
267
274
  return
@@ -271,16 +278,18 @@ class StripeSdkModule(
271
278
  }
272
279
 
273
280
  @ReactMethod
274
- fun resetPaymentSheetCustomer(promise: Promise) {
281
+ override fun resetPaymentSheetCustomer(promise: Promise) {
275
282
  PaymentSheet.resetCustomer(context = reactApplicationContext)
276
283
  promise.resolve(null)
277
284
  }
278
285
 
279
286
  @ReactMethod
280
- fun intentCreationCallback(
287
+ override fun intentCreationCallback(
281
288
  params: ReadableMap,
282
289
  promise: Promise,
283
290
  ) {
291
+ embeddedIntentCreationCallback.complete(params)
292
+
284
293
  if (paymentSheetFragment == null) {
285
294
  promise.resolve(PaymentSheetFragment.createMissingInitError())
286
295
  return
@@ -290,7 +299,7 @@ class StripeSdkModule(
290
299
  }
291
300
 
292
301
  @ReactMethod
293
- fun createPaymentMethod(
302
+ override fun createPaymentMethod(
294
303
  data: ReadableMap,
295
304
  options: ReadableMap,
296
305
  promise: Promise,
@@ -330,7 +339,7 @@ class StripeSdkModule(
330
339
  }
331
340
 
332
341
  @ReactMethod
333
- fun createToken(
342
+ override fun createToken(
334
343
  params: ReadableMap,
335
344
  promise: Promise,
336
345
  ) {
@@ -467,7 +476,7 @@ class StripeSdkModule(
467
476
  }
468
477
 
469
478
  @ReactMethod
470
- fun createTokenForCVCUpdate(
479
+ override fun createTokenForCVCUpdate(
471
480
  cvc: String,
472
481
  promise: Promise,
473
482
  ) {
@@ -490,8 +499,9 @@ class StripeSdkModule(
490
499
  }
491
500
 
492
501
  @ReactMethod
493
- fun handleNextAction(
502
+ override fun handleNextAction(
494
503
  paymentIntentClientSecret: String,
504
+ returnUrl: String?,
495
505
  promise: Promise,
496
506
  ) {
497
507
  paymentLauncherFragment =
@@ -506,8 +516,9 @@ class StripeSdkModule(
506
516
  }
507
517
 
508
518
  @ReactMethod
509
- fun handleNextActionForSetup(
519
+ override fun handleNextActionForSetup(
510
520
  setupIntentClientSecret: String,
521
+ returnUrl: String?,
511
522
  promise: Promise,
512
523
  ) {
513
524
  paymentLauncherFragment =
@@ -541,10 +552,10 @@ class StripeSdkModule(
541
552
  // }
542
553
 
543
554
  @ReactMethod
544
- fun confirmPayment(
555
+ override fun confirmPayment(
545
556
  paymentIntentClientSecret: String,
546
557
  params: ReadableMap?,
547
- options: ReadableMap,
558
+ options: ReadableMap?,
548
559
  promise: Promise,
549
560
  ) {
550
561
  val paymentMethodData = getMapOrNull(params, "paymentMethodData")
@@ -604,7 +615,7 @@ class StripeSdkModule(
604
615
  }
605
616
 
606
617
  @ReactMethod
607
- fun retrievePaymentIntent(
618
+ override fun retrievePaymentIntent(
608
619
  clientSecret: String,
609
620
  promise: Promise,
610
621
  ) {
@@ -615,7 +626,7 @@ class StripeSdkModule(
615
626
  }
616
627
 
617
628
  @ReactMethod
618
- fun retrieveSetupIntent(
629
+ override fun retrieveSetupIntent(
619
630
  clientSecret: String,
620
631
  promise: Promise,
621
632
  ) {
@@ -626,7 +637,7 @@ class StripeSdkModule(
626
637
  }
627
638
 
628
639
  @ReactMethod
629
- fun confirmSetupIntent(
640
+ override fun confirmSetupIntent(
630
641
  setupIntentClientSecret: String,
631
642
  params: ReadableMap,
632
643
  options: ReadableMap,
@@ -677,13 +688,13 @@ class StripeSdkModule(
677
688
  }
678
689
 
679
690
  @ReactMethod
680
- fun isPlatformPaySupported(
691
+ override fun isPlatformPaySupported(
681
692
  params: ReadableMap?,
682
693
  promise: Promise,
683
694
  ) {
684
695
  val googlePayParams = params?.getMap("googlePay")
685
696
  val fragment =
686
- GooglePayPaymentMethodLauncherFragment(
697
+ GooglePayPaymentMethodLauncherFragment.create(
687
698
  reactApplicationContext,
688
699
  getBooleanOrFalse(googlePayParams, "testEnv"),
689
700
  getBooleanOrFalse(googlePayParams, "existingPaymentMethodRequired"),
@@ -703,7 +714,7 @@ class StripeSdkModule(
703
714
  }
704
715
 
705
716
  @ReactMethod
706
- fun confirmPlatformPay(
717
+ override fun confirmPlatformPay(
707
718
  clientSecret: String,
708
719
  params: ReadableMap,
709
720
  isPaymentIntent: Boolean,
@@ -799,7 +810,7 @@ class StripeSdkModule(
799
810
  }
800
811
 
801
812
  @ReactMethod
802
- fun createPlatformPayPaymentMethod(
813
+ override fun createPlatformPayPaymentMethod(
803
814
  params: ReadableMap,
804
815
  usesDeprecatedTokenFlow: Boolean,
805
816
  promise: Promise,
@@ -828,7 +839,7 @@ class StripeSdkModule(
828
839
  }
829
840
 
830
841
  @ReactMethod
831
- fun canAddCardToWallet(
842
+ override fun canAddCardToWallet(
832
843
  params: ReadableMap,
833
844
  promise: Promise,
834
845
  ) {
@@ -862,7 +873,7 @@ class StripeSdkModule(
862
873
  }
863
874
 
864
875
  @ReactMethod
865
- fun isCardInWallet(
876
+ override fun isCardInWallet(
866
877
  params: ReadableMap,
867
878
  promise: Promise,
868
879
  ) {
@@ -886,7 +897,7 @@ class StripeSdkModule(
886
897
  }
887
898
 
888
899
  @ReactMethod
889
- fun collectBankAccount(
900
+ override fun collectBankAccount(
890
901
  isPaymentIntent: Boolean,
891
902
  clientSecret: String,
892
903
  params: ReadableMap,
@@ -924,7 +935,7 @@ class StripeSdkModule(
924
935
  )
925
936
 
926
937
  collectBankAccountLauncherFragment =
927
- CollectBankAccountLauncherFragment(
938
+ CollectBankAccountLauncherFragment.create(
928
939
  reactApplicationContext,
929
940
  publishableKey,
930
941
  stripeAccountId,
@@ -946,7 +957,7 @@ class StripeSdkModule(
946
957
  }
947
958
 
948
959
  @ReactMethod
949
- fun verifyMicrodeposits(
960
+ override fun verifyMicrodeposits(
950
961
  isPaymentIntent: Boolean,
951
962
  clientSecret: String,
952
963
  params: ReadableMap,
@@ -1031,7 +1042,7 @@ class StripeSdkModule(
1031
1042
  }
1032
1043
 
1033
1044
  @ReactMethod
1034
- fun collectBankAccountToken(
1045
+ override fun collectBankAccountToken(
1035
1046
  clientSecret: String,
1036
1047
  params: ReadableMap,
1037
1048
  promise: Promise,
@@ -1053,7 +1064,7 @@ class StripeSdkModule(
1053
1064
  }
1054
1065
 
1055
1066
  @ReactMethod
1056
- fun collectFinancialConnectionsAccounts(
1067
+ override fun collectFinancialConnectionsAccounts(
1057
1068
  clientSecret: String,
1058
1069
  params: ReadableMap,
1059
1070
  promise: Promise,
@@ -1075,7 +1086,7 @@ class StripeSdkModule(
1075
1086
  }
1076
1087
 
1077
1088
  @ReactMethod
1078
- fun initCustomerSheet(
1089
+ override fun initCustomerSheet(
1079
1090
  params: ReadableMap,
1080
1091
  customerAdapterOverrides: ReadableMap,
1081
1092
  promise: Promise,
@@ -1107,7 +1118,7 @@ class StripeSdkModule(
1107
1118
  }
1108
1119
 
1109
1120
  @ReactMethod
1110
- fun presentCustomerSheet(
1121
+ override fun presentCustomerSheet(
1111
1122
  params: ReadableMap,
1112
1123
  promise: Promise,
1113
1124
  ) {
@@ -1121,14 +1132,14 @@ class StripeSdkModule(
1121
1132
  }
1122
1133
 
1123
1134
  @ReactMethod
1124
- fun retrieveCustomerSheetPaymentOptionSelection(promise: Promise) {
1135
+ override fun retrieveCustomerSheetPaymentOptionSelection(promise: Promise) {
1125
1136
  customerSheetFragment?.retrievePaymentOptionSelection(promise) ?: run {
1126
1137
  promise.resolve(CustomerSheetFragment.createMissingInitError())
1127
1138
  }
1128
1139
  }
1129
1140
 
1130
1141
  @ReactMethod
1131
- fun customerAdapterFetchPaymentMethodsCallback(
1142
+ override fun customerAdapterFetchPaymentMethodsCallback(
1132
1143
  paymentMethodJsonObjects: ReadableArray,
1133
1144
  promise: Promise,
1134
1145
  ) {
@@ -1152,7 +1163,7 @@ class StripeSdkModule(
1152
1163
  }
1153
1164
 
1154
1165
  @ReactMethod
1155
- fun customerAdapterAttachPaymentMethodCallback(
1166
+ override fun customerAdapterAttachPaymentMethodCallback(
1156
1167
  paymentMethodJson: ReadableMap,
1157
1168
  promise: Promise,
1158
1169
  ) {
@@ -1174,7 +1185,7 @@ class StripeSdkModule(
1174
1185
  }
1175
1186
 
1176
1187
  @ReactMethod
1177
- fun customerAdapterDetachPaymentMethodCallback(
1188
+ override fun customerAdapterDetachPaymentMethodCallback(
1178
1189
  paymentMethodJson: ReadableMap,
1179
1190
  promise: Promise,
1180
1191
  ) {
@@ -1196,7 +1207,7 @@ class StripeSdkModule(
1196
1207
  }
1197
1208
 
1198
1209
  @ReactMethod
1199
- fun customerAdapterSetSelectedPaymentOptionCallback(promise: Promise) {
1210
+ override fun customerAdapterSetSelectedPaymentOptionCallback(promise: Promise) {
1200
1211
  customerSheetFragment?.let {
1201
1212
  it.customerAdapter?.setSelectedPaymentOptionCallback?.complete(Unit)
1202
1213
  } ?: run {
@@ -1206,7 +1217,7 @@ class StripeSdkModule(
1206
1217
  }
1207
1218
 
1208
1219
  @ReactMethod
1209
- fun customerAdapterFetchSelectedPaymentOptionCallback(
1220
+ override fun customerAdapterFetchSelectedPaymentOptionCallback(
1210
1221
  paymentOption: String?,
1211
1222
  promise: Promise,
1212
1223
  ) {
@@ -1219,7 +1230,7 @@ class StripeSdkModule(
1219
1230
  }
1220
1231
 
1221
1232
  @ReactMethod
1222
- fun customerAdapterSetupIntentClientSecretForCustomerAttachCallback(
1233
+ override fun customerAdapterSetupIntentClientSecretForCustomerAttachCallback(
1223
1234
  clientSecret: String,
1224
1235
  promise: Promise,
1225
1236
  ) {
@@ -1232,26 +1243,70 @@ class StripeSdkModule(
1232
1243
  }
1233
1244
 
1234
1245
  @ReactMethod
1235
- fun addListener(eventName: String) {
1236
- eventListenerCount++
1246
+ override fun createEmbeddedPaymentElement(
1247
+ intentConfig: ReadableMap,
1248
+ configuration: ReadableMap,
1249
+ promise: Promise,
1250
+ ) {
1251
+ // TODO:
1237
1252
  }
1238
1253
 
1239
1254
  @ReactMethod
1240
- fun removeListeners(count: Int) {
1241
- eventListenerCount -= count
1242
- if (eventListenerCount < 0) {
1243
- eventListenerCount = 0
1244
- }
1255
+ override fun confirmEmbeddedPaymentElement(
1256
+ viewTag: Double,
1257
+ promise: Promise,
1258
+ ) {
1259
+ // noop, iOS only
1260
+ }
1261
+
1262
+ @ReactMethod
1263
+ override fun updateEmbeddedPaymentElement(
1264
+ intentConfig: ReadableMap,
1265
+ promise: Promise,
1266
+ ) {
1267
+ // TODO:
1245
1268
  }
1246
1269
 
1247
- internal fun sendEvent(
1248
- reactContext: ReactContext,
1249
- eventName: String,
1250
- params: WritableMap,
1270
+ @ReactMethod
1271
+ override fun clearEmbeddedPaymentOption(
1272
+ viewTag: Double,
1273
+ promise: Promise,
1251
1274
  ) {
1252
- reactContext
1253
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
1254
- .emit(eventName, params)
1275
+ // noop, iOS only
1276
+ }
1277
+
1278
+ override fun handleURLCallback(
1279
+ url: String,
1280
+ promise: Promise,
1281
+ ) {
1282
+ // noop, iOS only.
1283
+ }
1284
+
1285
+ override fun openApplePaySetup(promise: Promise) {
1286
+ // noop, iOS only.
1287
+ }
1288
+
1289
+ override fun configureOrderTracking(
1290
+ orderTypeIdentifier: String,
1291
+ orderIdentifier: String,
1292
+ webServiceUrl: String,
1293
+ authenticationToken: String,
1294
+ promise: Promise,
1295
+ ) {
1296
+ // noop, iOS only.
1297
+ }
1298
+
1299
+ override fun dismissPlatformPay(promise: Promise?) {
1300
+ // noop, iOS only.
1301
+ }
1302
+
1303
+ override fun updatePlatformPaySheet(
1304
+ summaryItems: ReadableArray?,
1305
+ shippingMethods: ReadableArray?,
1306
+ errors: ReadableArray?,
1307
+ promise: Promise?,
1308
+ ) {
1309
+ // noop, iOS only.
1255
1310
  }
1256
1311
 
1257
1312
  /**
@@ -1266,7 +1321,67 @@ class StripeSdkModule(
1266
1321
  return null
1267
1322
  }
1268
1323
 
1324
+ private var isRecreatingActivities = false
1325
+ private val activityLifecycleCallbacks =
1326
+ object : Application.ActivityLifecycleCallbacks {
1327
+ override fun onActivityCreated(
1328
+ activity: Activity,
1329
+ bundle: Bundle?,
1330
+ ) {
1331
+ if (bundle != null) {
1332
+ isRecreatingActivities = true
1333
+ }
1334
+ if (isRecreatingActivities && activity.javaClass.name.startsWith("com.stripe.android")) {
1335
+ activity.finish()
1336
+ }
1337
+ }
1338
+
1339
+ override fun onActivityStarted(activity: Activity) {
1340
+ }
1341
+
1342
+ override fun onActivityResumed(activity: Activity) {
1343
+ isRecreatingActivities = false
1344
+ }
1345
+
1346
+ override fun onActivityPaused(activity: Activity) {
1347
+ }
1348
+
1349
+ override fun onActivityStopped(activity: Activity) {
1350
+ }
1351
+
1352
+ override fun onActivitySaveInstanceState(
1353
+ activity: Activity,
1354
+ bundle: Bundle,
1355
+ ) {
1356
+ }
1357
+
1358
+ override fun onActivityDestroyed(activity: Activity) {
1359
+ }
1360
+ }
1361
+
1362
+ /**
1363
+ * React native apps do not properly handle activity re-creation so make
1364
+ * sure to dismiss any stripe ui when that happens to make sure apps stay
1365
+ * in a consistent state.
1366
+ *
1367
+ * Note that because of some restrictions on some system ui like google
1368
+ * pay this might not always work.
1369
+ */
1370
+ private fun preventActivityRecreation() {
1371
+ currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
1372
+ }
1373
+
1374
+ private fun setupComposeCompatView() {
1375
+ UiThreadUtil.runOnUiThread {
1376
+ composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(context = reactApplicationContext).also {
1377
+ currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
1378
+ it,
1379
+ )
1380
+ }
1381
+ }
1382
+ }
1383
+
1269
1384
  companion object {
1270
- const val NAME = "StripeSdk"
1385
+ const val NAME = NativeStripeSdkModuleSpec.NAME
1271
1386
  }
1272
1387
  }
@@ -1,15 +1,44 @@
1
1
  package com.reactnativestripesdk
2
2
 
3
- import com.facebook.react.ReactPackage
3
+ import com.facebook.react.BaseReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.annotations.ReactModule
7
+ import com.facebook.react.module.model.ReactModuleInfo
8
+ import com.facebook.react.module.model.ReactModuleInfoProvider
6
9
  import com.facebook.react.uimanager.ViewManager
7
10
  import com.reactnativestripesdk.addresssheet.AddressSheetViewManager
8
11
  import com.reactnativestripesdk.pushprovisioning.AddToWalletButtonManager
9
12
 
10
- class StripeSdkPackage : ReactPackage {
11
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
12
- listOf<NativeModule>(StripeSdkModule(reactContext))
13
+ // Fool autolinking for older versions that do not support BaseReactPackage.
14
+ // public class StripeSdkPackage implements ReactPackage {
15
+ class StripeSdkPackage : BaseReactPackage() {
16
+ override fun getModule(
17
+ name: String,
18
+ reactContext: ReactApplicationContext,
19
+ ): NativeModule? =
20
+ when (name) {
21
+ StripeSdkModule.NAME -> StripeSdkModule(reactContext)
22
+ else -> null
23
+ }
24
+
25
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
26
+ val moduleList: Array<Class<out NativeModule?>> = arrayOf(StripeSdkModule::class.java)
27
+ val reactModuleInfoMap: MutableMap<String, ReactModuleInfo> = HashMap()
28
+ for (moduleClass in moduleList) {
29
+ val reactModule = moduleClass.getAnnotation(ReactModule::class.java) ?: continue
30
+ reactModuleInfoMap[reactModule.name] =
31
+ ReactModuleInfo(
32
+ reactModule.name,
33
+ moduleClass.name,
34
+ true,
35
+ reactModule.needsEagerInit,
36
+ reactModule.isCxxModule,
37
+ BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
38
+ )
39
+ }
40
+ return ReactModuleInfoProvider { reactModuleInfoMap }
41
+ }
13
42
 
14
43
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
15
44
  listOf<ViewManager<*, *>>(
@@ -20,5 +49,6 @@ class StripeSdkPackage : ReactPackage {
20
49
  GooglePayButtonManager(),
21
50
  AddToWalletButtonManager(reactContext),
22
51
  AddressSheetViewManager(),
52
+ EmbeddedPaymentElementViewManager(),
23
53
  )
24
54
  }
@@ -1,22 +1,17 @@
1
1
  package com.reactnativestripesdk.addresssheet
2
2
 
3
- import android.os.Bundle
4
- import android.view.LayoutInflater
5
- import android.view.View
6
- import android.view.ViewGroup
7
- import android.widget.FrameLayout
8
- import androidx.fragment.app.Fragment
9
3
  import androidx.fragment.app.FragmentActivity
10
4
  import com.facebook.react.bridge.ReactContext
11
5
  import com.facebook.react.bridge.WritableMap
12
6
  import com.reactnativestripesdk.utils.ErrorType
7
+ import com.reactnativestripesdk.utils.StripeFragment
13
8
  import com.reactnativestripesdk.utils.createError
14
9
  import com.stripe.android.paymentsheet.PaymentSheet
15
10
  import com.stripe.android.paymentsheet.addresselement.AddressDetails
16
11
  import com.stripe.android.paymentsheet.addresselement.AddressLauncher
17
12
  import com.stripe.android.paymentsheet.addresselement.AddressLauncherResult
18
13
 
19
- class AddressLauncherFragment : Fragment() {
14
+ class AddressLauncherFragment : StripeFragment() {
20
15
  companion object {
21
16
  internal var publishableKey: String? = null
22
17
  internal const val TAG = "address_launcher_fragment"
@@ -26,16 +21,7 @@ class AddressLauncherFragment : Fragment() {
26
21
  private var configuration = AddressLauncher.Configuration()
27
22
  private var callback: ((error: WritableMap?, address: AddressDetails?) -> Unit)? = null
28
23
 
29
- override fun onCreateView(
30
- inflater: LayoutInflater,
31
- container: ViewGroup?,
32
- savedInstanceState: Bundle?,
33
- ): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
34
-
35
- override fun onViewCreated(
36
- view: View,
37
- savedInstanceState: Bundle?,
38
- ) {
24
+ override fun prepare() {
39
25
  publishableKey?.let { publishableKey ->
40
26
  addressLauncher =
41
27
  AddressLauncher(this, ::onAddressLauncherResult).also {