@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
@@ -84,35 +84,35 @@ class AddressSheetView(
84
84
  }
85
85
  }
86
86
 
87
- fun setAppearance(appearanceParams: ReadableMap) {
87
+ fun setAppearance(appearanceParams: ReadableMap?) {
88
88
  this.appearanceParams = appearanceParams
89
89
  }
90
90
 
91
- fun setDefaultValues(defaults: ReadableMap) {
92
- defaultAddress = buildAddressDetails(defaults)
91
+ fun setDefaultValues(defaults: ReadableMap?) {
92
+ defaultAddress = defaults?.let { buildAddressDetails(it) }
93
93
  }
94
94
 
95
- fun setAdditionalFields(fields: ReadableMap) {
96
- additionalFields = buildAdditionalFieldsConfiguration(fields)
95
+ fun setAdditionalFields(fields: ReadableMap?) {
96
+ additionalFields = fields?.let { buildAdditionalFieldsConfiguration(it) }
97
97
  }
98
98
 
99
- fun setAllowedCountries(countries: List<String>) {
100
- allowedCountries = countries.toSet()
99
+ fun setAllowedCountries(countries: List<String>?) {
100
+ allowedCountries = countries?.toSet() ?: emptySet()
101
101
  }
102
102
 
103
- fun setAutocompleteCountries(countries: List<String>) {
104
- autocompleteCountries = countries.toSet()
103
+ fun setAutocompleteCountries(countries: List<String>?) {
104
+ autocompleteCountries = countries?.toSet() ?: emptySet()
105
105
  }
106
106
 
107
- fun setPrimaryButtonTitle(title: String) {
107
+ fun setPrimaryButtonTitle(title: String?) {
108
108
  buttonTitle = title
109
109
  }
110
110
 
111
- fun setSheetTitle(title: String) {
111
+ fun setSheetTitle(title: String?) {
112
112
  sheetTitle = title
113
113
  }
114
114
 
115
- fun setGooglePlacesApiKey(key: String) {
115
+ fun setGooglePlacesApiKey(key: String?) {
116
116
  googlePlacesApiKey = key
117
117
  }
118
118
 
@@ -158,21 +158,27 @@ class AddressSheetView(
158
158
  )
159
159
  }
160
160
 
161
- internal fun buildResult(addressDetails: AddressDetails): WritableMap {
162
- val result = WritableNativeMap()
163
- result.putString("name", addressDetails.name)
164
- WritableNativeMap().let {
165
- it.putString("city", addressDetails.address?.city)
166
- it.putString("country", addressDetails.address?.country)
167
- it.putString("line1", addressDetails.address?.line1)
168
- it.putString("line2", addressDetails.address?.line2)
169
- it.putString("postalCode", addressDetails.address?.postalCode)
170
- it.putString("state", addressDetails.address?.state)
171
- result.putMap("address", it)
161
+ internal fun buildResult(addressDetails: AddressDetails): WritableMap =
162
+ WritableNativeMap().apply {
163
+ putMap(
164
+ "result",
165
+ WritableNativeMap().apply {
166
+ putString("name", addressDetails.name)
167
+ putMap(
168
+ "address",
169
+ WritableNativeMap().apply {
170
+ putString("city", addressDetails.address?.city)
171
+ putString("country", addressDetails.address?.country)
172
+ putString("line1", addressDetails.address?.line1)
173
+ putString("line2", addressDetails.address?.line2)
174
+ putString("postalCode", addressDetails.address?.postalCode)
175
+ putString("state", addressDetails.address?.state)
176
+ },
177
+ )
178
+ putString("phone", addressDetails.phoneNumber)
179
+ putBoolean("isCheckboxSelected", addressDetails.isCheckboxSelected ?: false)
180
+ },
181
+ )
172
182
  }
173
- result.putString("phone", addressDetails.phoneNumber)
174
- result.putBoolean("isCheckboxSelected", addressDetails.isCheckboxSelected ?: false)
175
- return result
176
- }
177
183
  }
178
184
  }
@@ -1,16 +1,25 @@
1
1
  package com.reactnativestripesdk.addresssheet
2
2
 
3
+ import com.facebook.react.bridge.Dynamic
3
4
  import com.facebook.react.bridge.ReadableArray
4
- import com.facebook.react.bridge.ReadableMap
5
5
  import com.facebook.react.module.annotations.ReactModule
6
6
  import com.facebook.react.uimanager.SimpleViewManager
7
7
  import com.facebook.react.uimanager.ThemedReactContext
8
8
  import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.facebook.react.viewmanagers.AddressSheetViewManagerDelegate
10
+ import com.facebook.react.viewmanagers.AddressSheetViewManagerInterface
11
+ import com.reactnativestripesdk.utils.asMapOrNull
9
12
 
10
13
  @ReactModule(name = AddressSheetViewManager.REACT_CLASS)
11
- class AddressSheetViewManager : SimpleViewManager<AddressSheetView>() {
14
+ class AddressSheetViewManager :
15
+ SimpleViewManager<AddressSheetView>(),
16
+ AddressSheetViewManagerInterface<AddressSheetView> {
17
+ private val delegate = AddressSheetViewManagerDelegate(this)
18
+
12
19
  override fun getName() = REACT_CLASS
13
20
 
21
+ override fun getDelegate() = delegate
22
+
14
23
  override fun getExportedCustomDirectEventTypeConstants() =
15
24
  mutableMapOf(
16
25
  AddressSheetEvent.ON_SUBMIT to
@@ -20,7 +29,7 @@ class AddressSheetViewManager : SimpleViewManager<AddressSheetView>() {
20
29
  )
21
30
 
22
31
  @ReactProp(name = "visible")
23
- fun setVisible(
32
+ override fun setVisible(
24
33
  view: AddressSheetView,
25
34
  visibility: Boolean,
26
35
  ) {
@@ -28,69 +37,85 @@ class AddressSheetViewManager : SimpleViewManager<AddressSheetView>() {
28
37
  }
29
38
 
30
39
  @ReactProp(name = "appearance")
31
- fun setAppearance(
40
+ override fun setAppearance(
32
41
  view: AddressSheetView,
33
- appearance: ReadableMap,
42
+ appearance: Dynamic,
34
43
  ) {
35
- view.setAppearance(appearance)
44
+ view.setAppearance(appearance.asMap())
36
45
  }
37
46
 
38
47
  @ReactProp(name = "defaultValues")
39
- fun setDefaultValues(
48
+ override fun setDefaultValues(
40
49
  view: AddressSheetView,
41
- defaults: ReadableMap,
50
+ defaults: Dynamic,
42
51
  ) {
43
- view.setDefaultValues(defaults)
52
+ view.setDefaultValues(defaults.asMap())
44
53
  }
45
54
 
46
55
  @ReactProp(name = "additionalFields")
47
- fun setAdditionalFields(
56
+ override fun setAdditionalFields(
48
57
  view: AddressSheetView,
49
- fields: ReadableMap,
58
+ fields: Dynamic,
50
59
  ) {
51
- view.setAdditionalFields(fields)
60
+ view.setAdditionalFields(fields.asMapOrNull())
52
61
  }
53
62
 
54
63
  @ReactProp(name = "allowedCountries")
55
- fun setAllowedCountries(
64
+ override fun setAllowedCountries(
56
65
  view: AddressSheetView,
57
- countries: ReadableArray,
66
+ countries: ReadableArray?,
58
67
  ) {
59
- view.setAllowedCountries(countries.toArrayList().filterIsInstance<String>())
68
+ view.setAllowedCountries(countries?.toArrayList()?.filterIsInstance<String>())
60
69
  }
61
70
 
62
71
  @ReactProp(name = "autocompleteCountries")
63
- fun setAutocompleteCountries(
72
+ override fun setAutocompleteCountries(
64
73
  view: AddressSheetView,
65
- countries: ReadableArray,
74
+ countries: ReadableArray?,
66
75
  ) {
67
- view.setAutocompleteCountries(countries.toArrayList().filterIsInstance<String>())
76
+ view.setAutocompleteCountries(countries?.toArrayList()?.filterIsInstance<String>())
68
77
  }
69
78
 
70
79
  @ReactProp(name = "primaryButtonTitle")
71
- fun setPrimaryButtonTitle(
80
+ override fun setPrimaryButtonTitle(
72
81
  view: AddressSheetView,
73
- title: String,
82
+ title: String?,
74
83
  ) {
75
84
  view.setPrimaryButtonTitle(title)
76
85
  }
77
86
 
78
87
  @ReactProp(name = "sheetTitle")
79
- fun setSheetTitle(
88
+ override fun setSheetTitle(
80
89
  view: AddressSheetView,
81
- title: String,
90
+ title: String?,
82
91
  ) {
83
92
  view.setSheetTitle(title)
84
93
  }
85
94
 
86
95
  @ReactProp(name = "googlePlacesApiKey")
87
- fun setGooglePlacesApiKey(
96
+ override fun setGooglePlacesApiKey(
88
97
  view: AddressSheetView,
89
- key: String,
98
+ key: String?,
90
99
  ) {
91
100
  view.setGooglePlacesApiKey(key)
92
101
  }
93
102
 
103
+ @ReactProp(name = "presentationStyle")
104
+ override fun setPresentationStyle(
105
+ view: AddressSheetView,
106
+ value: String?,
107
+ ) {
108
+ // noop iOS only.
109
+ }
110
+
111
+ @ReactProp(name = "animationStyle")
112
+ override fun setAnimationStyle(
113
+ view: AddressSheetView,
114
+ value: String?,
115
+ ) {
116
+ // noop iOS only.
117
+ }
118
+
94
119
  override fun createViewInstance(reactContext: ThemedReactContext): AddressSheetView = AddressSheetView(reactContext)
95
120
 
96
121
  companion object {
@@ -1,4 +1,4 @@
1
- package com.reactnativestripesdk
1
+ package com.reactnativestripesdk.customersheet
2
2
 
3
3
  import android.app.Activity
4
4
  import android.app.Application
@@ -7,21 +7,23 @@ import android.os.Bundle
7
7
  import android.os.Handler
8
8
  import android.os.Looper
9
9
  import android.util.Log
10
- import android.view.LayoutInflater
11
- import android.view.View
12
- import android.view.ViewGroup
13
- import android.widget.FrameLayout
14
- import androidx.fragment.app.Fragment
15
10
  import com.facebook.react.bridge.Arguments
16
11
  import com.facebook.react.bridge.Promise
17
12
  import com.facebook.react.bridge.ReactApplicationContext
18
13
  import com.facebook.react.bridge.WritableMap
19
14
  import com.facebook.react.bridge.WritableNativeMap
20
- import com.reactnativestripesdk.customersheet.ReactNativeCustomerAdapter
15
+ import com.reactnativestripesdk.ReactNativeCustomerAdapter
16
+ import com.reactnativestripesdk.buildPaymentSheetAppearance
17
+ import com.reactnativestripesdk.getBase64FromBitmap
18
+ import com.reactnativestripesdk.getBitmapFromDrawable
19
+ import com.reactnativestripesdk.mapToAddressCollectionMode
20
+ import com.reactnativestripesdk.mapToCardBrandAcceptance
21
+ import com.reactnativestripesdk.mapToCollectionMode
21
22
  import com.reactnativestripesdk.utils.CreateTokenErrorType
22
23
  import com.reactnativestripesdk.utils.ErrorType
23
24
  import com.reactnativestripesdk.utils.KeepJsAwakeTask
24
25
  import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
26
+ import com.reactnativestripesdk.utils.StripeFragment
25
27
  import com.reactnativestripesdk.utils.createError
26
28
  import com.reactnativestripesdk.utils.mapFromPaymentMethod
27
29
  import com.reactnativestripesdk.utils.mapToPreferredNetworks
@@ -38,7 +40,7 @@ import kotlinx.coroutines.Dispatchers
38
40
  import kotlinx.coroutines.launch
39
41
 
40
42
  @OptIn(ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi::class)
41
- class CustomerSheetFragment : Fragment() {
43
+ class CustomerSheetFragment : StripeFragment() {
42
44
  private var customerSheet: CustomerSheet? = null
43
45
  internal var customerAdapter: ReactNativeCustomerAdapter? = null
44
46
  internal var context: ReactApplicationContext? = null
@@ -46,18 +48,7 @@ class CustomerSheetFragment : Fragment() {
46
48
  private var presentPromise: Promise? = null
47
49
  private var keepJsAwake: KeepJsAwakeTask? = null
48
50
 
49
- override fun onCreateView(
50
- inflater: LayoutInflater,
51
- container: ViewGroup?,
52
- savedInstanceState: Bundle?,
53
- ): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
54
-
55
- override fun onViewCreated(
56
- view: View,
57
- savedInstanceState: Bundle?,
58
- ) {
59
- super.onViewCreated(view, savedInstanceState)
60
-
51
+ override fun prepare() {
61
52
  val context =
62
53
  context
63
54
  ?: run {
@@ -161,9 +152,11 @@ class CustomerSheetFragment : Fragment() {
161
152
  is CustomerSheetResult.Failed -> {
162
153
  resolvePresentPromise(createError(ErrorType.Failed.toString(), result.exception))
163
154
  }
155
+
164
156
  is CustomerSheetResult.Selected -> {
165
157
  promiseResult = createPaymentOptionResult(result.selection)
166
158
  }
159
+
167
160
  is CustomerSheetResult.Canceled -> {
168
161
  promiseResult = createPaymentOptionResult(result.selection)
169
162
  promiseResult.putMap(
@@ -188,7 +181,6 @@ class CustomerSheetFragment : Fragment() {
188
181
  }
189
182
 
190
183
  private fun presentWithTimeout(timeout: Long) {
191
- var customerSheetActivity: Activity? = null
192
184
  var activities: MutableList<Activity> = mutableListOf()
193
185
  val activityLifecycleCallbacks =
194
186
  object : Application.ActivityLifecycleCallbacks {
@@ -196,7 +188,6 @@ class CustomerSheetFragment : Fragment() {
196
188
  activity: Activity,
197
189
  savedInstanceState: Bundle?,
198
190
  ) {
199
- customerSheetActivity = activity
200
191
  activities.add(activity)
201
192
  }
202
193
 
@@ -211,10 +202,10 @@ class CustomerSheetFragment : Fragment() {
211
202
  override fun onActivitySaveInstanceState(
212
203
  activity: Activity,
213
204
  outState: Bundle,
214
- ) {}
205
+ ) {
206
+ }
215
207
 
216
208
  override fun onActivityDestroyed(activity: Activity) {
217
- customerSheetActivity = null
218
209
  activities = mutableListOf()
219
210
  context?.currentActivity?.application?.unregisterActivityLifecycleCallbacks(this)
220
211
  }
@@ -253,9 +244,11 @@ class CustomerSheetFragment : Fragment() {
253
244
  is CustomerSheetResult.Failed -> {
254
245
  promise.resolve(createError(ErrorType.Failed.toString(), result.exception))
255
246
  }
247
+
256
248
  is CustomerSheetResult.Selected -> {
257
249
  promiseResult = createPaymentOptionResult(result.selection)
258
250
  }
251
+
259
252
  is CustomerSheetResult.Canceled -> {
260
253
  promiseResult = createPaymentOptionResult(result.selection)
261
254
  promiseResult.putMap(
@@ -380,6 +373,7 @@ class CustomerSheetFragment : Fragment() {
380
373
  paymentOptionResult =
381
374
  buildResult(selection.paymentOption.label, selection.paymentOption.icon(), null)
382
375
  }
376
+
383
377
  is PaymentOptionSelection.PaymentMethod -> {
384
378
  paymentOptionResult =
385
379
  buildResult(
@@ -388,6 +382,7 @@ class CustomerSheetFragment : Fragment() {
388
382
  selection.paymentMethod,
389
383
  )
390
384
  }
385
+
391
386
  null -> {}
392
387
  }
393
388
 
@@ -1,16 +1,14 @@
1
- package com.reactnativestripesdk.customersheet
1
+ // This needs to be in the same package as StripeSdkModule to access protected methods.
2
+ package com.reactnativestripesdk
2
3
 
3
- import android.util.Log
4
4
  import com.facebook.react.bridge.Arguments
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.bridge.WritableMap
7
- import com.reactnativestripesdk.StripeSdkModule
8
6
  import com.stripe.android.customersheet.CustomerAdapter
9
7
  import com.stripe.android.model.PaymentMethod
10
8
  import kotlinx.coroutines.CompletableDeferred
11
9
 
12
10
  class ReactNativeCustomerAdapter(
13
- private val context: ReactApplicationContext,
11
+ val context: ReactApplicationContext,
14
12
  private val adapter: CustomerAdapter,
15
13
  private val overridesFetchPaymentMethods: Boolean,
16
14
  private val overridesAttachPaymentMethod: Boolean,
@@ -19,6 +17,8 @@ class ReactNativeCustomerAdapter(
19
17
  private val overridesFetchSelectedPaymentOption: Boolean,
20
18
  private val overridesSetupIntentClientSecretForCustomerAttach: Boolean,
21
19
  ) : CustomerAdapter by adapter {
20
+ private val stripeSdkModule = context.getNativeModule(StripeSdkModule::class.java)
21
+
22
22
  internal var fetchPaymentMethodsCallback: CompletableDeferred<List<PaymentMethod>>? = null
23
23
  internal var attachPaymentMethodCallback: CompletableDeferred<PaymentMethod>? = null
24
24
  internal var detachPaymentMethodCallback: CompletableDeferred<PaymentMethod>? = null
@@ -30,7 +30,7 @@ class ReactNativeCustomerAdapter(
30
30
  if (overridesFetchPaymentMethods) {
31
31
  CompletableDeferred<List<PaymentMethod>>().also {
32
32
  fetchPaymentMethodsCallback = it
33
- emitEvent("onCustomerAdapterFetchPaymentMethodsCallback", Arguments.createMap())
33
+ stripeSdkModule?.emitOnCustomerAdapterFetchPaymentMethodsCallback()
34
34
  val resultFromJavascript = it.await()
35
35
  return CustomerAdapter.Result.success(resultFromJavascript)
36
36
  }
@@ -44,7 +44,7 @@ class ReactNativeCustomerAdapter(
44
44
  CompletableDeferred<PaymentMethod>().also {
45
45
  attachPaymentMethodCallback = it
46
46
  val params = Arguments.createMap().also { it.putString("paymentMethodId", paymentMethodId) }
47
- emitEvent("onCustomerAdapterAttachPaymentMethodCallback", params)
47
+ stripeSdkModule?.emitOnCustomerAdapterAttachPaymentMethodCallback(params)
48
48
  val resultFromJavascript = it.await()
49
49
  return CustomerAdapter.Result.success(resultFromJavascript)
50
50
  }
@@ -58,7 +58,7 @@ class ReactNativeCustomerAdapter(
58
58
  CompletableDeferred<PaymentMethod>().also {
59
59
  detachPaymentMethodCallback = it
60
60
  val params = Arguments.createMap().also { it.putString("paymentMethodId", paymentMethodId) }
61
- emitEvent("onCustomerAdapterDetachPaymentMethodCallback", params)
61
+ stripeSdkModule?.emitOnCustomerAdapterDetachPaymentMethodCallback(params)
62
62
  val resultFromJavascript = it.await()
63
63
  return CustomerAdapter.Result.success(resultFromJavascript)
64
64
  }
@@ -72,7 +72,7 @@ class ReactNativeCustomerAdapter(
72
72
  CompletableDeferred<Unit>().also {
73
73
  setSelectedPaymentOptionCallback = it
74
74
  val params = Arguments.createMap().also { it.putString("paymentOption", paymentOption?.id) }
75
- emitEvent("onCustomerAdapterSetSelectedPaymentOptionCallback", params)
75
+ stripeSdkModule?.emitOnCustomerAdapterSetSelectedPaymentOptionCallback(params)
76
76
  val resultFromJavascript = it.await()
77
77
  return CustomerAdapter.Result.success(resultFromJavascript)
78
78
  }
@@ -85,7 +85,7 @@ class ReactNativeCustomerAdapter(
85
85
  if (overridesFetchSelectedPaymentOption) {
86
86
  CompletableDeferred<String?>().also {
87
87
  fetchSelectedPaymentOptionCallback = it
88
- emitEvent("onCustomerAdapterFetchSelectedPaymentOptionCallback", Arguments.createMap())
88
+ stripeSdkModule?.emitOnCustomerAdapterFetchSelectedPaymentOptionCallback()
89
89
  val resultFromJavascript = it.await()
90
90
  return CustomerAdapter.Result.success(
91
91
  if (resultFromJavascript != null) {
@@ -104,10 +104,7 @@ class ReactNativeCustomerAdapter(
104
104
  if (overridesSetupIntentClientSecretForCustomerAttach) {
105
105
  CompletableDeferred<String>().also {
106
106
  setupIntentClientSecretForCustomerAttachCallback = it
107
- emitEvent(
108
- "onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback",
109
- Arguments.createMap(),
110
- )
107
+ stripeSdkModule?.emitOnCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback()
111
108
  val resultFromJavascript = it.await()
112
109
  return CustomerAdapter.Result.success(resultFromJavascript)
113
110
  }
@@ -115,19 +112,4 @@ class ReactNativeCustomerAdapter(
115
112
 
116
113
  return adapter.setupIntentClientSecretForCustomerAttach()
117
114
  }
118
-
119
- private fun emitEvent(
120
- eventName: String,
121
- params: WritableMap,
122
- ) {
123
- val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
124
- if (stripeSdkModule == null || stripeSdkModule.eventListenerCount == 0) {
125
- Log.e(
126
- "StripeReactNative",
127
- "Tried to call $eventName, but no callback was found. Please file an issue: https://github.com/stripe/stripe-react-native/issues",
128
- )
129
- }
130
-
131
- stripeSdkModule?.sendEvent(context, eventName, params)
132
- }
133
115
  }
@@ -2,20 +2,28 @@ package com.reactnativestripesdk.pushprovisioning
2
2
 
3
3
  import android.content.Context
4
4
  import com.bumptech.glide.Glide
5
+ import com.facebook.react.bridge.Dynamic
5
6
  import com.facebook.react.bridge.ReadableMap
6
7
  import com.facebook.react.module.annotations.ReactModule
7
8
  import com.facebook.react.uimanager.SimpleViewManager
8
9
  import com.facebook.react.uimanager.ThemedReactContext
9
10
  import com.facebook.react.uimanager.annotations.ReactProp
11
+ import com.facebook.react.viewmanagers.AddToWalletButtonManagerDelegate
12
+ import com.facebook.react.viewmanagers.AddToWalletButtonManagerInterface
13
+ import com.reactnativestripesdk.utils.asMapOrNull
10
14
 
11
15
  @ReactModule(name = AddToWalletButtonManager.REACT_CLASS)
12
16
  class AddToWalletButtonManager(
13
17
  applicationContext: Context,
14
- ) : SimpleViewManager<AddToWalletButtonView>() {
18
+ ) : SimpleViewManager<AddToWalletButtonView>(),
19
+ AddToWalletButtonManagerInterface<AddToWalletButtonView> {
20
+ private val delegate = AddToWalletButtonManagerDelegate(this)
15
21
  private val requestManager = Glide.with(applicationContext)
16
22
 
17
23
  override fun getName() = REACT_CLASS
18
24
 
25
+ override fun getDelegate() = delegate
26
+
19
27
  override fun onDropViewInstance(view: AddToWalletButtonView) {
20
28
  view.onDropViewInstance()
21
29
  super.onDropViewInstance(view)
@@ -36,35 +44,51 @@ class AddToWalletButtonManager(
36
44
  )
37
45
 
38
46
  @ReactProp(name = "androidAssetSource")
39
- fun source(
47
+ override fun setAndroidAssetSource(
40
48
  view: AddToWalletButtonView,
41
- source: ReadableMap,
49
+ source: ReadableMap?,
42
50
  ) {
43
51
  view.setSourceMap(source)
44
52
  }
45
53
 
46
54
  @ReactProp(name = "cardDetails")
47
- fun cardDetails(
55
+ override fun setCardDetails(
48
56
  view: AddToWalletButtonView,
49
- cardDetails: ReadableMap,
57
+ cardDetails: Dynamic,
50
58
  ) {
51
- view.setCardDetails(cardDetails)
59
+ view.setCardDetails(cardDetails.asMapOrNull())
52
60
  }
53
61
 
54
62
  @ReactProp(name = "ephemeralKey")
55
- fun ephemeralKey(
63
+ override fun setEphemeralKey(
56
64
  view: AddToWalletButtonView,
57
- ephemeralKey: ReadableMap,
65
+ ephemeralKey: Dynamic,
58
66
  ) {
59
- view.setEphemeralKey(ephemeralKey)
67
+ view.setEphemeralKey(ephemeralKey.asMap())
60
68
  }
61
69
 
62
70
  @ReactProp(name = "token")
63
- fun token(
71
+ override fun setToken(
72
+ view: AddToWalletButtonView,
73
+ token: Dynamic,
74
+ ) {
75
+ view.setToken(token.asMap())
76
+ }
77
+
78
+ @ReactProp(name = "iOSButtonStyle")
79
+ override fun setIOSButtonStyle(
80
+ view: AddToWalletButtonView,
81
+ value: String?,
82
+ ) {
83
+ // noop, iOS only.
84
+ }
85
+
86
+ @ReactProp(name = "testEnv")
87
+ override fun setTestEnv(
64
88
  view: AddToWalletButtonView,
65
- token: ReadableMap?,
89
+ value: Boolean,
66
90
  ) {
67
- view.setToken(token)
91
+ // noop, iOS only.
68
92
  }
69
93
 
70
94
  companion object {
@@ -159,11 +159,11 @@ class AddToWalletButtonView(
159
159
  requestManager.clear(this)
160
160
  }
161
161
 
162
- fun setSourceMap(map: ReadableMap) {
162
+ fun setSourceMap(map: ReadableMap?) {
163
163
  sourceMap = map
164
164
  }
165
165
 
166
- fun setCardDetails(detailsMap: ReadableMap) {
166
+ fun setCardDetails(detailsMap: ReadableMap?) {
167
167
  cardDetails = detailsMap
168
168
  }
169
169
 
@@ -176,6 +176,8 @@ class AddToWalletButtonView(
176
176
  }
177
177
 
178
178
  fun dispatchEvent(error: WritableMap?) {
179
- UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(AddToWalletCompleteEvent(context.surfaceId, id, error))
179
+ UIManagerHelper
180
+ .getEventDispatcherForReactTag(context, id)
181
+ ?.dispatchEvent(AddToWalletCompleteEvent(context.surfaceId, id, error))
180
182
  }
181
183
  }
@@ -5,8 +5,10 @@ import android.view.View
5
5
  import android.view.inputmethod.InputMethodManager
6
6
  import androidx.fragment.app.Fragment
7
7
  import androidx.fragment.app.FragmentActivity
8
+ import com.facebook.react.bridge.Dynamic
8
9
  import com.facebook.react.bridge.ReactApplicationContext
9
10
  import com.facebook.react.bridge.ReadableMap
11
+ import com.facebook.react.bridge.ReadableType
10
12
 
11
13
  fun View.showSoftKeyboard() {
12
14
  post {
@@ -36,3 +38,5 @@ fun ReadableMap.getBooleanOr(
36
38
  key: String,
37
39
  default: Boolean,
38
40
  ): Boolean = if (this.hasKey(key)) this.getBoolean(key) else default
41
+
42
+ fun Dynamic.asMapOrNull(): ReadableMap? = if (this.type == ReadableType.Map) this.asMap() else null
@@ -1,7 +1,7 @@
1
1
  package com.reactnativestripesdk.utils
2
2
 
3
3
  import com.facebook.react.bridge.Arguments
4
- import com.facebook.react.bridge.ReactContext
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
5
  import com.facebook.react.bridge.UiThreadUtil
6
6
  import com.facebook.react.jstasks.HeadlessJsTaskConfig
7
7
  import com.facebook.react.jstasks.HeadlessJsTaskContext
@@ -12,7 +12,7 @@ import com.facebook.react.jstasks.HeadlessJsTaskContext
12
12
  * pausing timers.
13
13
  */
14
14
  internal class KeepJsAwakeTask(
15
- private val context: ReactContext,
15
+ private val context: ReactApplicationContext,
16
16
  ) {
17
17
  private var taskId: Int? = null
18
18
 
@@ -199,6 +199,27 @@ internal fun mapFromBillingDetails(billingDatails: PaymentMethod.BillingDetails?
199
199
  return details
200
200
  }
201
201
 
202
+ internal fun mapFromPaymentSheetBillingDetails(billing: com.stripe.android.paymentsheet.PaymentSheet.BillingDetails?): WritableMap {
203
+ val details = Arguments.createMap()
204
+ details.putString("name", billing?.name)
205
+ details.putString("email", billing?.email)
206
+ details.putString("phone", billing?.phone)
207
+
208
+ // map the nested address
209
+ val addrMap = Arguments.createMap()
210
+ billing?.address?.let { a ->
211
+ addrMap.putString("city", a.city)
212
+ addrMap.putString("country", a.country)
213
+ addrMap.putString("line1", a.line1)
214
+ addrMap.putString("line2", a.line2)
215
+ addrMap.putString("postalCode", a.postalCode)
216
+ addrMap.putString("state", a.state)
217
+ }
218
+ details.putMap("address", addrMap)
219
+
220
+ return details
221
+ }
222
+
202
223
  internal fun mapTokenType(type: Token.Type): String =
203
224
  when (type) {
204
225
  Token.Type.Account -> "Account"