@stripe/stripe-react-native 0.42.0 → 0.44.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 (309) hide show
  1. package/.husky/pre-commit +0 -3
  2. package/CHANGELOG.md +26 -0
  3. package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  10. package/android/.project +0 -11
  11. package/android/.settings/org.eclipse.buildship.core.prefs +3 -3
  12. package/android/build.gradle +8 -1
  13. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  14. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  15. package/android/gradle.properties +4 -1
  16. package/android/gradlew +249 -0
  17. package/android/gradlew.bat +92 -0
  18. package/android/spotless.gradle +19 -0
  19. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +30 -34
  20. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +20 -10
  21. package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +12 -13
  22. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +242 -105
  23. package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +58 -20
  24. package/android/src/main/java/com/reactnativestripesdk/CardFocusEvent.kt +8 -11
  25. package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +10 -12
  26. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +135 -87
  27. package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +57 -22
  28. package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +33 -24
  29. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +107 -85
  30. package/android/src/main/java/com/reactnativestripesdk/FormCompleteEvent.kt +9 -11
  31. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +16 -9
  32. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +36 -28
  33. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +67 -43
  34. package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +21 -16
  35. package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +101 -56
  36. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +244 -166
  37. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +137 -156
  38. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +181 -57
  39. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +422 -258
  40. package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -4
  41. package/android/src/main/java/com/reactnativestripesdk/StripeContainerView.kt +5 -1
  42. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +656 -299
  43. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +12 -14
  44. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +42 -37
  45. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +12 -11
  46. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +29 -29
  47. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +50 -18
  48. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +227 -147
  49. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +15 -18
  50. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +33 -15
  51. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +63 -37
  52. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletCompleteEvent.kt +9 -13
  53. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/EphemeralKeyProvider.kt +15 -17
  54. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +76 -60
  55. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +71 -47
  56. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +117 -51
  57. package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -3
  58. package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +39 -0
  59. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +295 -258
  60. package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
  61. package/ios/CustomerSheet/CustomerSheetUtils.swift +13 -7
  62. package/ios/FinancialConnections.swift +6 -2
  63. package/ios/StripeSdk+CustomerSheet.swift +3 -1
  64. package/ios/StripeSdk+PaymentSheet.swift +86 -21
  65. package/ios/StripeSdk.m +2 -0
  66. package/ios/StripeSdk.swift +72 -11
  67. package/lib/commonjs/NativeStripeSdk.js +1 -1
  68. package/lib/commonjs/NativeStripeSdk.js.map +1 -1
  69. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  70. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  71. package/lib/commonjs/components/AddressSheet.js +1 -1
  72. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  73. package/lib/commonjs/components/ApplePayButtonNative.js +1 -1
  74. package/lib/commonjs/components/ApplePayButtonNative.js.map +1 -1
  75. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  76. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  77. package/lib/commonjs/components/CardField.js +1 -1
  78. package/lib/commonjs/components/CardField.js.map +1 -1
  79. package/lib/commonjs/components/CardForm.js +1 -1
  80. package/lib/commonjs/components/CardForm.js.map +1 -1
  81. package/lib/commonjs/components/CustomerSheet.js +1 -1
  82. package/lib/commonjs/components/CustomerSheet.js.map +1 -1
  83. package/lib/commonjs/components/GooglePayButtonNative.js +1 -1
  84. package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -1
  85. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  86. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  87. package/lib/commonjs/components/StripeContainer.js +1 -1
  88. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  89. package/lib/commonjs/components/StripeProvider.js +1 -1
  90. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  91. package/lib/commonjs/functions.js +1 -1
  92. package/lib/commonjs/functions.js.map +1 -1
  93. package/lib/commonjs/helpers.js +1 -1
  94. package/lib/commonjs/helpers.js.map +1 -1
  95. package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
  96. package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
  97. package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
  98. package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
  99. package/lib/commonjs/hooks/usePlatformPay.js.map +1 -1
  100. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  101. package/lib/commonjs/index.js.map +1 -1
  102. package/lib/commonjs/package.json +1 -0
  103. package/lib/commonjs/plugin/withStripe.js +1 -1
  104. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  105. package/lib/commonjs/types/ApplePay.js.map +1 -1
  106. package/lib/commonjs/types/Common.js +1 -1
  107. package/lib/commonjs/types/Common.js.map +1 -1
  108. package/lib/commonjs/types/CustomerSheet.js.map +1 -1
  109. package/lib/commonjs/types/Errors.js +1 -1
  110. package/lib/commonjs/types/Errors.js.map +1 -1
  111. package/lib/commonjs/types/FinancialConnections.js +1 -1
  112. package/lib/commonjs/types/FinancialConnections.js.map +1 -1
  113. package/lib/commonjs/types/NextAction.js.map +1 -1
  114. package/lib/commonjs/types/PaymentIntent.js +1 -1
  115. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  116. package/lib/commonjs/types/PaymentMethod.js.map +1 -1
  117. package/lib/commonjs/types/PaymentSheet.js +1 -1
  118. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  119. package/lib/commonjs/types/PlatformPay.js +1 -1
  120. package/lib/commonjs/types/PlatformPay.js.map +1 -1
  121. package/lib/commonjs/types/PushProvisioning.js +1 -1
  122. package/lib/commonjs/types/PushProvisioning.js.map +1 -1
  123. package/lib/commonjs/types/SetupIntent.js +1 -1
  124. package/lib/commonjs/types/SetupIntent.js.map +1 -1
  125. package/lib/commonjs/types/ThreeDSecure.js +1 -1
  126. package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
  127. package/lib/commonjs/types/Token.js.map +1 -1
  128. package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
  129. package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
  130. package/lib/commonjs/types/components/CardFieldInput.js +1 -1
  131. package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
  132. package/lib/commonjs/types/components/CardFormView.js.map +1 -1
  133. package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -1
  134. package/lib/commonjs/types/index.js +1 -1
  135. package/lib/commonjs/types/index.js.map +1 -1
  136. package/lib/module/NativeStripeSdk.js +1 -1
  137. package/lib/module/NativeStripeSdk.js.map +1 -1
  138. package/lib/module/components/AddToWalletButton.js +1 -1
  139. package/lib/module/components/AddToWalletButton.js.map +1 -1
  140. package/lib/module/components/AddressSheet.js +1 -1
  141. package/lib/module/components/AddressSheet.js.map +1 -1
  142. package/lib/module/components/ApplePayButtonNative.js +1 -1
  143. package/lib/module/components/ApplePayButtonNative.js.map +1 -1
  144. package/lib/module/components/AuBECSDebitForm.js +1 -1
  145. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  146. package/lib/module/components/CardField.js +1 -1
  147. package/lib/module/components/CardField.js.map +1 -1
  148. package/lib/module/components/CardForm.js +1 -1
  149. package/lib/module/components/CardForm.js.map +1 -1
  150. package/lib/module/components/CustomerSheet.js +1 -1
  151. package/lib/module/components/CustomerSheet.js.map +1 -1
  152. package/lib/module/components/GooglePayButtonNative.js +1 -1
  153. package/lib/module/components/GooglePayButtonNative.js.map +1 -1
  154. package/lib/module/components/PlatformPayButton.js +1 -1
  155. package/lib/module/components/PlatformPayButton.js.map +1 -1
  156. package/lib/module/components/StripeContainer.js +1 -1
  157. package/lib/module/components/StripeContainer.js.map +1 -1
  158. package/lib/module/components/StripeProvider.js +1 -1
  159. package/lib/module/components/StripeProvider.js.map +1 -1
  160. package/lib/module/functions.js +1 -1
  161. package/lib/module/functions.js.map +1 -1
  162. package/lib/module/helpers.js +1 -1
  163. package/lib/module/helpers.js.map +1 -1
  164. package/lib/module/hooks/useConfirmPayment.js.map +1 -1
  165. package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
  166. package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
  167. package/lib/module/hooks/usePaymentSheet.js.map +1 -1
  168. package/lib/module/hooks/usePlatformPay.js.map +1 -1
  169. package/lib/module/hooks/useStripe.js.map +1 -1
  170. package/lib/module/index.js.map +1 -1
  171. package/lib/module/package.json +1 -0
  172. package/lib/module/plugin/withStripe.js +1 -1
  173. package/lib/module/plugin/withStripe.js.map +1 -1
  174. package/lib/module/types/ApplePay.js.map +1 -1
  175. package/lib/module/types/Common.js +1 -1
  176. package/lib/module/types/Common.js.map +1 -1
  177. package/lib/module/types/CustomerSheet.js.map +1 -1
  178. package/lib/module/types/Errors.js +1 -1
  179. package/lib/module/types/Errors.js.map +1 -1
  180. package/lib/module/types/FinancialConnections.js +1 -1
  181. package/lib/module/types/FinancialConnections.js.map +1 -1
  182. package/lib/module/types/NextAction.js.map +1 -1
  183. package/lib/module/types/PaymentIntent.js +1 -1
  184. package/lib/module/types/PaymentIntent.js.map +1 -1
  185. package/lib/module/types/PaymentMethod.js.map +1 -1
  186. package/lib/module/types/PaymentSheet.js +1 -1
  187. package/lib/module/types/PaymentSheet.js.map +1 -1
  188. package/lib/module/types/PlatformPay.js +1 -1
  189. package/lib/module/types/PlatformPay.js.map +1 -1
  190. package/lib/module/types/PushProvisioning.js +1 -1
  191. package/lib/module/types/PushProvisioning.js.map +1 -1
  192. package/lib/module/types/SetupIntent.js +1 -1
  193. package/lib/module/types/SetupIntent.js.map +1 -1
  194. package/lib/module/types/ThreeDSecure.js +1 -1
  195. package/lib/module/types/ThreeDSecure.js.map +1 -1
  196. package/lib/module/types/Token.js.map +1 -1
  197. package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
  198. package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
  199. package/lib/module/types/components/CardFieldInput.js +1 -1
  200. package/lib/module/types/components/CardFieldInput.js.map +1 -1
  201. package/lib/module/types/components/CardFormView.js.map +1 -1
  202. package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -1
  203. package/lib/module/types/index.js +1 -1
  204. package/lib/module/types/index.js.map +1 -1
  205. package/lib/typescript/src/NativeStripeSdk.d.ts +4 -3
  206. package/lib/typescript/src/NativeStripeSdk.d.ts.map +1 -0
  207. package/lib/typescript/src/components/AddToWalletButton.d.ts +3 -1
  208. package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -0
  209. package/lib/typescript/src/components/AddressSheet.d.ts +4 -2
  210. package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -0
  211. package/lib/typescript/src/components/ApplePayButtonNative.d.ts +1 -0
  212. package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +1 -0
  213. package/lib/typescript/src/components/AuBECSDebitForm.d.ts +3 -1
  214. package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -0
  215. package/lib/typescript/src/components/CardField.d.ts +1 -0
  216. package/lib/typescript/src/components/CardField.d.ts.map +1 -0
  217. package/lib/typescript/src/components/CardForm.d.ts +1 -0
  218. package/lib/typescript/src/components/CardForm.d.ts.map +1 -0
  219. package/lib/typescript/src/components/CustomerSheet.d.ts +2 -1
  220. package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -0
  221. package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -0
  222. package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +1 -0
  223. package/lib/typescript/src/components/PlatformPayButton.d.ts +3 -1
  224. package/lib/typescript/src/components/PlatformPayButton.d.ts.map +1 -0
  225. package/lib/typescript/src/components/StripeContainer.d.ts +2 -1
  226. package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -0
  227. package/lib/typescript/src/components/StripeProvider.d.ts +3 -2
  228. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -0
  229. package/lib/typescript/src/functions.d.ts +6 -5
  230. package/lib/typescript/src/functions.d.ts.map +1 -0
  231. package/lib/typescript/src/helpers.d.ts +1 -0
  232. package/lib/typescript/src/helpers.d.ts.map +1 -0
  233. package/lib/typescript/src/hooks/useConfirmPayment.d.ts +2 -1
  234. package/lib/typescript/src/hooks/useConfirmPayment.d.ts.map +1 -0
  235. package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts +1 -0
  236. package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts.map +1 -0
  237. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +3 -2
  238. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -0
  239. package/lib/typescript/src/hooks/usePaymentSheet.d.ts +2 -1
  240. package/lib/typescript/src/hooks/usePaymentSheet.d.ts.map +1 -0
  241. package/lib/typescript/src/hooks/usePlatformPay.d.ts +4 -3
  242. package/lib/typescript/src/hooks/usePlatformPay.d.ts.map +1 -0
  243. package/lib/typescript/src/hooks/useStripe.d.ts +11 -8
  244. package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -0
  245. package/lib/typescript/src/index.d.ts +1 -0
  246. package/lib/typescript/src/index.d.ts.map +1 -0
  247. package/lib/typescript/src/plugin/withStripe.d.ts +2 -1
  248. package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -0
  249. package/lib/typescript/src/types/ApplePay.d.ts +6 -5
  250. package/lib/typescript/src/types/ApplePay.d.ts.map +1 -0
  251. package/lib/typescript/src/types/Common.d.ts +4 -1
  252. package/lib/typescript/src/types/Common.d.ts.map +1 -0
  253. package/lib/typescript/src/types/CustomerSheet.d.ts +16 -4
  254. package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -0
  255. package/lib/typescript/src/types/Errors.d.ts +2 -1
  256. package/lib/typescript/src/types/Errors.d.ts.map +1 -0
  257. package/lib/typescript/src/types/FinancialConnections.d.ts +21 -17
  258. package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -0
  259. package/lib/typescript/src/types/NextAction.d.ts +9 -8
  260. package/lib/typescript/src/types/NextAction.d.ts.map +1 -0
  261. package/lib/typescript/src/types/PaymentIntent.d.ts +16 -15
  262. package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
  263. package/lib/typescript/src/types/PaymentMethod.d.ts +21 -16
  264. package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -0
  265. package/lib/typescript/src/types/PaymentSheet.d.ts +91 -22
  266. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -0
  267. package/lib/typescript/src/types/PlatformPay.d.ts +22 -21
  268. package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -0
  269. package/lib/typescript/src/types/PushProvisioning.d.ts +5 -4
  270. package/lib/typescript/src/types/PushProvisioning.d.ts.map +1 -0
  271. package/lib/typescript/src/types/SetupIntent.d.ts +4 -3
  272. package/lib/typescript/src/types/SetupIntent.d.ts.map +1 -0
  273. package/lib/typescript/src/types/ThreeDSecure.d.ts +1 -0
  274. package/lib/typescript/src/types/ThreeDSecure.d.ts.map +1 -0
  275. package/lib/typescript/src/types/Token.d.ts +10 -9
  276. package/lib/typescript/src/types/Token.d.ts.map +1 -0
  277. package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +3 -2
  278. package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts.map +1 -0
  279. package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts +1 -0
  280. package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts.map +1 -0
  281. package/lib/typescript/src/types/components/CardFieldInput.d.ts +8 -5
  282. package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -0
  283. package/lib/typescript/src/types/components/CardFormView.d.ts +9 -6
  284. package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -0
  285. package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +1 -0
  286. package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts.map +1 -0
  287. package/lib/typescript/src/types/index.d.ts +24 -23
  288. package/lib/typescript/src/types/index.d.ts.map +1 -0
  289. package/package.json +32 -40
  290. package/src/NativeStripeSdk.tsx +4 -2
  291. package/src/components/CardField.tsx +1 -1
  292. package/src/components/CardForm.tsx +12 -9
  293. package/src/components/CustomerSheet.tsx +4 -6
  294. package/src/components/StripeProvider.tsx +17 -0
  295. package/src/functions.ts +13 -14
  296. package/src/helpers.ts +2 -1
  297. package/src/types/Common.ts +3 -0
  298. package/src/types/CustomerSheet.ts +11 -0
  299. package/src/types/FinancialConnections.ts +3 -0
  300. package/src/types/PaymentMethod.ts +5 -1
  301. package/src/types/PaymentSheet.ts +85 -4
  302. package/src/types/components/CardFieldInput.ts +8 -4
  303. package/src/types/components/CardFormView.ts +8 -4
  304. package/stripe-react-native.podspec +2 -1
  305. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  306. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  307. package/android/.gradle/8.9/gc.properties +0 -0
  308. /package/android/.gradle/{8.9 → 8.11.1}/fileChanges/last-build.bin +0 -0
  309. /package/android/.gradle/{8.9/dependencies-accessors → 8.11.1}/gc.properties +0 -0
@@ -8,19 +8,17 @@ import com.reactnativestripesdk.addresssheet.AddressSheetViewManager
8
8
  import com.reactnativestripesdk.pushprovisioning.AddToWalletButtonManager
9
9
 
10
10
  class StripeSdkPackage : ReactPackage {
11
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
12
- return listOf<NativeModule>(StripeSdkModule(reactContext))
13
- }
11
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
12
+ listOf<NativeModule>(StripeSdkModule(reactContext))
14
13
 
15
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
16
- return listOf<ViewManager<*, *>>(
17
- CardFieldViewManager(),
18
- AuBECSDebitFormViewManager(),
19
- StripeContainerManager(),
20
- CardFormViewManager(),
21
- GooglePayButtonManager(),
22
- AddToWalletButtonManager(reactContext),
23
- AddressSheetViewManager()
24
- )
25
- }
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
15
+ listOf<ViewManager<*, *>>(
16
+ CardFieldViewManager(),
17
+ AuBECSDebitFormViewManager(),
18
+ StripeContainerManager(),
19
+ CardFormViewManager(),
20
+ GooglePayButtonManager(),
21
+ AddToWalletButtonManager(reactContext),
22
+ AddressSheetViewManager(),
23
+ )
26
24
  }
@@ -26,28 +26,31 @@ class AddressLauncherFragment : Fragment() {
26
26
  private var configuration = AddressLauncher.Configuration()
27
27
  private var callback: ((error: WritableMap?, address: AddressDetails?) -> Unit)? = null
28
28
 
29
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
30
- savedInstanceState: Bundle?): View {
31
- return FrameLayout(requireActivity()).also {
32
- it.visibility = View.GONE
33
- }
34
- }
29
+ override fun onCreateView(
30
+ inflater: LayoutInflater,
31
+ container: ViewGroup?,
32
+ savedInstanceState: Bundle?,
33
+ ): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
35
34
 
36
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
35
+ override fun onViewCreated(
36
+ view: View,
37
+ savedInstanceState: Bundle?,
38
+ ) {
37
39
  publishableKey?.let { publishableKey ->
38
- addressLauncher = AddressLauncher(this,
39
- ::onAddressLauncherResult).also {
40
- it.present(
41
- publishableKey = publishableKey,
42
- configuration = configuration
40
+ addressLauncher =
41
+ AddressLauncher(this, ::onAddressLauncherResult).also {
42
+ it.present(publishableKey = publishableKey, configuration = configuration)
43
+ }
44
+ }
45
+ ?: run {
46
+ callback?.invoke(
47
+ createError(
48
+ ErrorType.Failed.toString(),
49
+ "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
50
+ ),
51
+ null,
43
52
  )
44
53
  }
45
- } ?: run {
46
- callback?.invoke(
47
- createError(ErrorType.Failed.toString(), "No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method."),
48
- null
49
- )
50
- }
51
54
  }
52
55
 
53
56
  private fun onAddressLauncherResult(result: AddressLauncherResult) {
@@ -55,14 +58,11 @@ class AddressLauncherFragment : Fragment() {
55
58
  is AddressLauncherResult.Canceled -> {
56
59
  callback?.invoke(
57
60
  createError(ErrorType.Canceled.toString(), "The flow has been canceled."),
58
- null
61
+ null,
59
62
  )
60
63
  }
61
64
  is AddressLauncherResult.Succeeded -> {
62
- callback?.invoke(
63
- null,
64
- result.address
65
- )
65
+ callback?.invoke(null, result.address)
66
66
  }
67
67
  }
68
68
  }
@@ -77,17 +77,19 @@ class AddressLauncherFragment : Fragment() {
77
77
  googlePlacesApiKey: String?,
78
78
  autocompleteCountries: Set<String>,
79
79
  additionalFields: AddressLauncher.AdditionalFieldsConfiguration?,
80
- callback: ((error: WritableMap?, address: AddressDetails?) -> Unit)) {
81
- configuration = AddressLauncher.Configuration(
82
- appearance = appearance,
83
- address = defaultAddress,
84
- allowedCountries = allowedCountries,
85
- buttonTitle = buttonTitle,
86
- additionalFields = additionalFields,
87
- title = title,
88
- googlePlacesApiKey = googlePlacesApiKey,
89
- autocompleteCountries = autocompleteCountries,
90
- )
80
+ callback: ((error: WritableMap?, address: AddressDetails?) -> Unit),
81
+ ) {
82
+ configuration =
83
+ AddressLauncher.Configuration(
84
+ appearance = appearance,
85
+ address = defaultAddress,
86
+ allowedCountries = allowedCountries,
87
+ buttonTitle = buttonTitle,
88
+ additionalFields = additionalFields,
89
+ title = title,
90
+ googlePlacesApiKey = googlePlacesApiKey,
91
+ autocompleteCountries = autocompleteCountries,
92
+ )
91
93
  this.callback = callback
92
94
  (context.currentActivity as? FragmentActivity)?.let {
93
95
  attemptToCleanupPreviousFragment(it)
@@ -96,16 +98,19 @@ class AddressLauncherFragment : Fragment() {
96
98
  }
97
99
 
98
100
  private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
99
- currentActivity.supportFragmentManager.beginTransaction()
101
+ currentActivity.supportFragmentManager
102
+ .beginTransaction()
100
103
  .remove(this)
101
104
  .commitAllowingStateLoss()
102
105
  }
103
106
 
104
107
  private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
105
108
  try {
106
- currentActivity.supportFragmentManager.beginTransaction()
109
+ currentActivity.supportFragmentManager
110
+ .beginTransaction()
107
111
  .add(this, TAG)
108
112
  .commit()
109
- } catch (_: IllegalStateException) {}
113
+ } catch (_: IllegalStateException) {
114
+ }
110
115
  }
111
116
  }
@@ -2,27 +2,28 @@ package com.reactnativestripesdk.addresssheet
2
2
 
3
3
  import com.facebook.react.bridge.WritableMap
4
4
  import com.facebook.react.uimanager.events.Event
5
- import com.facebook.react.uimanager.events.RCTEventEmitter
6
5
 
7
- internal class AddressSheetEvent constructor(viewTag: Int, private val eventType: EventType, private val eventMap: WritableMap?) : Event<AddressSheetEvent>(viewTag) {
6
+ internal class AddressSheetEvent(
7
+ surfaceId: Int,
8
+ viewTag: Int,
9
+ private val eventType: EventType,
10
+ private val eventMap: WritableMap?,
11
+ ) : Event<AddressSheetEvent>(surfaceId, viewTag) {
8
12
  enum class EventType {
9
13
  OnSubmit,
10
- OnError
14
+ OnError,
11
15
  }
12
16
 
13
- override fun dispatch(rctEventEmitter: RCTEventEmitter) {
14
- rctEventEmitter.receiveEvent(viewTag, eventName, eventMap)
15
- }
17
+ override fun getEventData() = eventMap
16
18
 
17
19
  companion object {
18
- const val ON_SUBMIT = "onSubmitAction"
19
- const val ON_ERROR = "onErrorAction"
20
+ const val ON_SUBMIT = "topSubmitAction"
21
+ const val ON_ERROR = "topErrorAction"
20
22
  }
21
23
 
22
- override fun getEventName(): String {
23
- return when (eventType) {
24
+ override fun getEventName(): String =
25
+ when (eventType) {
24
26
  EventType.OnSubmit -> ON_SUBMIT
25
27
  EventType.OnError -> ON_ERROR
26
28
  }
27
- }
28
29
  }
@@ -1,15 +1,14 @@
1
1
  package com.reactnativestripesdk.addresssheet
2
2
 
3
+ import android.annotation.SuppressLint
3
4
  import android.os.Bundle
4
5
  import android.util.Log
5
6
  import android.widget.FrameLayout
6
- import com.facebook.react.bridge.Arguments
7
7
  import com.facebook.react.bridge.ReadableMap
8
8
  import com.facebook.react.bridge.WritableMap
9
9
  import com.facebook.react.bridge.WritableNativeMap
10
10
  import com.facebook.react.uimanager.ThemedReactContext
11
- import com.facebook.react.uimanager.UIManagerModule
12
- import com.facebook.react.uimanager.events.EventDispatcher
11
+ import com.facebook.react.uimanager.UIManagerHelper
13
12
  import com.reactnativestripesdk.buildPaymentSheetAppearance
14
13
  import com.reactnativestripesdk.utils.ErrorType
15
14
  import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
@@ -18,10 +17,11 @@ import com.reactnativestripesdk.utils.toBundleObject
18
17
  import com.stripe.android.paymentsheet.PaymentSheet
19
18
  import com.stripe.android.paymentsheet.addresselement.AddressDetails
20
19
  import com.stripe.android.paymentsheet.addresselement.AddressLauncher
21
- import com.stripe.android.paymentsheet.addresselement.AddressLauncherResult
22
20
 
23
- class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(context) {
24
- private var eventDispatcher: EventDispatcher? = context.getNativeModule(UIManagerModule::class.java)?.eventDispatcher
21
+ @SuppressLint("ViewConstructor")
22
+ class AddressSheetView(
23
+ private val context: ThemedReactContext,
24
+ ) : FrameLayout(context) {
25
25
  private var isVisible = false
26
26
  private var appearanceParams: ReadableMap? = null
27
27
  private var defaultAddress: AddressDetails? = null
@@ -33,14 +33,14 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
33
33
  private var additionalFields: AddressLauncher.AdditionalFieldsConfiguration? = null
34
34
 
35
35
  private fun onSubmit(params: WritableMap) {
36
- eventDispatcher?.dispatchEvent(
37
- AddressSheetEvent(id, AddressSheetEvent.EventType.OnSubmit, params)
36
+ UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(
37
+ AddressSheetEvent(context.surfaceId, id, AddressSheetEvent.EventType.OnSubmit, params),
38
38
  )
39
39
  }
40
40
 
41
41
  private fun onError(params: WritableMap?) {
42
- eventDispatcher?.dispatchEvent(
43
- AddressSheetEvent(id, AddressSheetEvent.EventType.OnError, params)
42
+ UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(
43
+ AddressSheetEvent(context.surfaceId, id, AddressSheetEvent.EventType.OnError, params),
44
44
  )
45
45
  }
46
46
 
@@ -48,18 +48,22 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
48
48
  if (newVisibility && !isVisible) {
49
49
  launchAddressSheet()
50
50
  } else if (!newVisibility && isVisible) {
51
- Log.w("StripeReactNative", "Programmatically dismissing the Address Sheet is not supported on Android.")
51
+ Log.w(
52
+ "StripeReactNative",
53
+ "Programmatically dismissing the Address Sheet is not supported on Android.",
54
+ )
52
55
  }
53
56
  isVisible = newVisibility
54
57
  }
55
58
 
56
59
  private fun launchAddressSheet() {
57
- val appearance = try {
58
- buildPaymentSheetAppearance(toBundleObject(appearanceParams), context)
59
- } catch (error: PaymentSheetAppearanceException) {
60
- onError(createError(ErrorType.Failed.toString(), error))
61
- return
62
- }
60
+ val appearance =
61
+ try {
62
+ buildPaymentSheetAppearance(toBundleObject(appearanceParams), context)
63
+ } catch (error: PaymentSheetAppearanceException) {
64
+ onError(createError(ErrorType.Failed.toString(), error))
65
+ return
66
+ }
63
67
  AddressLauncherFragment().presentAddressSheet(
64
68
  context,
65
69
  appearance,
@@ -69,7 +73,7 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
69
73
  sheetTitle,
70
74
  googlePlacesApiKey,
71
75
  autocompleteCountries,
72
- additionalFields
76
+ additionalFields,
73
77
  ) { error, address ->
74
78
  if (address != null) {
75
79
  onSubmit(buildResult(address))
@@ -113,18 +117,15 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
113
117
  }
114
118
 
115
119
  companion object {
116
- internal fun buildAddressDetails(bundle: Bundle): AddressDetails {
117
- return AddressDetails(
120
+ internal fun buildAddressDetails(bundle: Bundle): AddressDetails =
121
+ AddressDetails(
118
122
  name = bundle.getString("name"),
119
123
  address = buildAddress(bundle.getBundle("address")),
120
124
  phoneNumber = bundle.getString("phone"),
121
125
  isCheckboxSelected = bundle.getBoolean("isCheckboxSelected"),
122
126
  )
123
- }
124
127
 
125
- internal fun buildAddressDetails(map: ReadableMap): AddressDetails {
126
- return buildAddressDetails(toBundleObject(map))
127
- }
128
+ internal fun buildAddressDetails(map: ReadableMap): AddressDetails = buildAddressDetails(toBundleObject(map))
128
129
 
129
130
  internal fun buildAddress(bundle: Bundle?): PaymentSheet.Address? {
130
131
  if (bundle == null) {
@@ -136,25 +137,24 @@ class AddressSheetView(private val context: ThemedReactContext) : FrameLayout(co
136
137
  line1 = bundle.getString("line1"),
137
138
  line2 = bundle.getString("line2"),
138
139
  state = bundle.getString("state"),
139
- postalCode = bundle.getString("postalCode")
140
+ postalCode = bundle.getString("postalCode"),
140
141
  )
141
142
  }
142
143
 
143
- internal fun getFieldConfiguration(key: String?): AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration {
144
- return when (key) {
144
+ internal fun getFieldConfiguration(key: String?): AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration =
145
+ when (key) {
145
146
  "hidden" -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN
146
147
  "optional" -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.OPTIONAL
147
148
  "required" -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.REQUIRED
148
149
  else -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN
149
150
  }
150
- }
151
151
 
152
152
  internal fun buildAdditionalFieldsConfiguration(params: ReadableMap): AddressLauncher.AdditionalFieldsConfiguration {
153
153
  val phoneConfiguration = getFieldConfiguration(params.getString("phoneNumber"))
154
154
 
155
155
  return AddressLauncher.AdditionalFieldsConfiguration(
156
156
  phone = phoneConfiguration,
157
- checkboxLabel = params.getString("checkboxLabel")
157
+ checkboxLabel = params.getString("checkboxLabel"),
158
158
  )
159
159
  }
160
160
 
@@ -2,66 +2,98 @@ package com.reactnativestripesdk.addresssheet
2
2
 
3
3
  import com.facebook.react.bridge.ReadableArray
4
4
  import com.facebook.react.bridge.ReadableMap
5
- import com.facebook.react.common.MapBuilder
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
9
 
10
+ @ReactModule(name = AddressSheetViewManager.REACT_CLASS)
10
11
  class AddressSheetViewManager : SimpleViewManager<AddressSheetView>() {
11
- override fun getName() = "AddressSheetView"
12
+ override fun getName() = REACT_CLASS
12
13
 
13
- override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
14
- return MapBuilder.of(
15
- AddressSheetEvent.ON_SUBMIT, MapBuilder.of("registrationName", "onSubmitAction"),
16
- AddressSheetEvent.ON_ERROR, MapBuilder.of("registrationName", "onErrorAction"))
17
- }
14
+ override fun getExportedCustomDirectEventTypeConstants() =
15
+ mutableMapOf(
16
+ AddressSheetEvent.ON_SUBMIT to
17
+ mutableMapOf("registrationName" to "onSubmitAction"),
18
+ AddressSheetEvent.ON_ERROR to
19
+ mutableMapOf("registrationName" to "onErrorAction"),
20
+ )
18
21
 
19
22
  @ReactProp(name = "visible")
20
- fun setVisible(view: AddressSheetView, visibility: Boolean) {
23
+ fun setVisible(
24
+ view: AddressSheetView,
25
+ visibility: Boolean,
26
+ ) {
21
27
  view.setVisible(visibility)
22
28
  }
23
29
 
24
30
  @ReactProp(name = "appearance")
25
- fun setAppearance(view: AddressSheetView, appearance: ReadableMap) {
31
+ fun setAppearance(
32
+ view: AddressSheetView,
33
+ appearance: ReadableMap,
34
+ ) {
26
35
  view.setAppearance(appearance)
27
36
  }
28
37
 
29
38
  @ReactProp(name = "defaultValues")
30
- fun setDefaultValues(view: AddressSheetView, defaults: ReadableMap) {
39
+ fun setDefaultValues(
40
+ view: AddressSheetView,
41
+ defaults: ReadableMap,
42
+ ) {
31
43
  view.setDefaultValues(defaults)
32
44
  }
33
45
 
34
46
  @ReactProp(name = "additionalFields")
35
- fun setAdditionalFields(view: AddressSheetView, fields: ReadableMap) {
47
+ fun setAdditionalFields(
48
+ view: AddressSheetView,
49
+ fields: ReadableMap,
50
+ ) {
36
51
  view.setAdditionalFields(fields)
37
52
  }
38
53
 
39
54
  @ReactProp(name = "allowedCountries")
40
- fun setAllowedCountries(view: AddressSheetView, countries: ReadableArray) {
55
+ fun setAllowedCountries(
56
+ view: AddressSheetView,
57
+ countries: ReadableArray,
58
+ ) {
41
59
  view.setAllowedCountries(countries.toArrayList().filterIsInstance<String>())
42
60
  }
43
61
 
44
62
  @ReactProp(name = "autocompleteCountries")
45
- fun setAutocompleteCountries(view: AddressSheetView, countries: ReadableArray) {
63
+ fun setAutocompleteCountries(
64
+ view: AddressSheetView,
65
+ countries: ReadableArray,
66
+ ) {
46
67
  view.setAutocompleteCountries(countries.toArrayList().filterIsInstance<String>())
47
68
  }
48
69
 
49
70
  @ReactProp(name = "primaryButtonTitle")
50
- fun setPrimaryButtonTitle(view: AddressSheetView, title: String) {
71
+ fun setPrimaryButtonTitle(
72
+ view: AddressSheetView,
73
+ title: String,
74
+ ) {
51
75
  view.setPrimaryButtonTitle(title)
52
76
  }
53
77
 
54
78
  @ReactProp(name = "sheetTitle")
55
- fun setSheetTitle(view: AddressSheetView, title: String) {
79
+ fun setSheetTitle(
80
+ view: AddressSheetView,
81
+ title: String,
82
+ ) {
56
83
  view.setSheetTitle(title)
57
84
  }
58
85
 
59
86
  @ReactProp(name = "googlePlacesApiKey")
60
- fun setGooglePlacesApiKey(view: AddressSheetView, key: String) {
87
+ fun setGooglePlacesApiKey(
88
+ view: AddressSheetView,
89
+ key: String,
90
+ ) {
61
91
  view.setGooglePlacesApiKey(key)
62
92
  }
63
93
 
64
- override fun createViewInstance(reactContext: ThemedReactContext): AddressSheetView {
65
- return AddressSheetView(reactContext)
94
+ override fun createViewInstance(reactContext: ThemedReactContext): AddressSheetView = AddressSheetView(reactContext)
95
+
96
+ companion object {
97
+ const val REACT_CLASS = "AddressSheetView"
66
98
  }
67
99
  }