@stripe/stripe-react-native 0.41.0 → 0.43.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 (314) hide show
  1. package/.husky/pre-commit +0 -3
  2. package/CHANGELOG.md +27 -0
  3. package/README.md +3 -0
  4. package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
  5. package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
  6. package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
  7. package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
  9. package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/8.11.1/gc.properties +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  13. package/android/.gradle/vcs-1/gc.properties +0 -0
  14. package/android/build.gradle +7 -1
  15. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  16. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  17. package/android/gradle.properties +4 -1
  18. package/android/gradlew +249 -0
  19. package/android/gradlew.bat +92 -0
  20. package/android/spotless.gradle +19 -0
  21. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +30 -34
  22. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +20 -10
  23. package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +12 -13
  24. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +242 -105
  25. package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +58 -20
  26. package/android/src/main/java/com/reactnativestripesdk/CardFocusEvent.kt +8 -11
  27. package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +10 -12
  28. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +135 -87
  29. package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +57 -22
  30. package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +53 -23
  31. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +125 -83
  32. package/android/src/main/java/com/reactnativestripesdk/FormCompleteEvent.kt +9 -11
  33. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +16 -9
  34. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +36 -28
  35. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +67 -43
  36. package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +21 -16
  37. package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +101 -56
  38. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +244 -166
  39. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +183 -123
  40. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +181 -57
  41. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +402 -258
  42. package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -4
  43. package/android/src/main/java/com/reactnativestripesdk/StripeContainerView.kt +5 -1
  44. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +654 -299
  45. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +12 -14
  46. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +42 -37
  47. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +12 -11
  48. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +29 -29
  49. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +50 -18
  50. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +227 -147
  51. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +15 -18
  52. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +33 -15
  53. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +63 -37
  54. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletCompleteEvent.kt +9 -13
  55. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/EphemeralKeyProvider.kt +15 -17
  56. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +76 -60
  57. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +71 -47
  58. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +117 -51
  59. package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -3
  60. package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +39 -0
  61. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +337 -250
  62. package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
  63. package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
  64. package/ios/FinancialConnections.swift +18 -2
  65. package/ios/Mappers.swift +23 -0
  66. package/ios/PaymentMethodFactory.swift +31 -29
  67. package/ios/StripeSdk+CustomerSheet.swift +2 -1
  68. package/ios/StripeSdk+PaymentSheet.swift +42 -0
  69. package/ios/StripeSdk.m +2 -0
  70. package/ios/StripeSdk.swift +116 -24
  71. package/lib/commonjs/NativeStripeSdk.js +1 -1
  72. package/lib/commonjs/NativeStripeSdk.js.map +1 -1
  73. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  74. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  75. package/lib/commonjs/components/AddressSheet.js +1 -1
  76. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  77. package/lib/commonjs/components/ApplePayButtonNative.js +1 -1
  78. package/lib/commonjs/components/ApplePayButtonNative.js.map +1 -1
  79. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  80. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  81. package/lib/commonjs/components/CardField.js +1 -1
  82. package/lib/commonjs/components/CardField.js.map +1 -1
  83. package/lib/commonjs/components/CardForm.js +1 -1
  84. package/lib/commonjs/components/CardForm.js.map +1 -1
  85. package/lib/commonjs/components/CustomerSheet.js +1 -1
  86. package/lib/commonjs/components/CustomerSheet.js.map +1 -1
  87. package/lib/commonjs/components/GooglePayButtonNative.js +1 -1
  88. package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -1
  89. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  90. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  91. package/lib/commonjs/components/StripeContainer.js +1 -1
  92. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  93. package/lib/commonjs/components/StripeProvider.js +1 -1
  94. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  95. package/lib/commonjs/functions.js +1 -1
  96. package/lib/commonjs/functions.js.map +1 -1
  97. package/lib/commonjs/helpers.js +1 -1
  98. package/lib/commonjs/helpers.js.map +1 -1
  99. package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
  100. package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
  101. package/lib/commonjs/hooks/useFinancialConnectionsSheet.js +1 -1
  102. package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
  103. package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
  104. package/lib/commonjs/hooks/usePlatformPay.js.map +1 -1
  105. package/lib/commonjs/hooks/useStripe.js +1 -1
  106. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  107. package/lib/commonjs/index.js.map +1 -1
  108. package/lib/commonjs/package.json +1 -0
  109. package/lib/commonjs/plugin/withStripe.js +1 -1
  110. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  111. package/lib/commonjs/types/ApplePay.js.map +1 -1
  112. package/lib/commonjs/types/Common.js +1 -1
  113. package/lib/commonjs/types/Common.js.map +1 -1
  114. package/lib/commonjs/types/CustomerSheet.js.map +1 -1
  115. package/lib/commonjs/types/Errors.js +1 -1
  116. package/lib/commonjs/types/Errors.js.map +1 -1
  117. package/lib/commonjs/types/FinancialConnections.js +1 -1
  118. package/lib/commonjs/types/FinancialConnections.js.map +1 -1
  119. package/lib/commonjs/types/NextAction.js.map +1 -1
  120. package/lib/commonjs/types/PaymentIntent.js +1 -1
  121. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  122. package/lib/commonjs/types/PaymentMethod.js.map +1 -1
  123. package/lib/commonjs/types/PaymentSheet.js +1 -1
  124. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  125. package/lib/commonjs/types/PlatformPay.js +1 -1
  126. package/lib/commonjs/types/PlatformPay.js.map +1 -1
  127. package/lib/commonjs/types/PushProvisioning.js +1 -1
  128. package/lib/commonjs/types/PushProvisioning.js.map +1 -1
  129. package/lib/commonjs/types/SetupIntent.js +1 -1
  130. package/lib/commonjs/types/SetupIntent.js.map +1 -1
  131. package/lib/commonjs/types/ThreeDSecure.js +1 -1
  132. package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
  133. package/lib/commonjs/types/Token.js.map +1 -1
  134. package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
  135. package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
  136. package/lib/commonjs/types/components/CardFieldInput.js +1 -1
  137. package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
  138. package/lib/commonjs/types/components/CardFormView.js.map +1 -1
  139. package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -1
  140. package/lib/commonjs/types/index.js +1 -1
  141. package/lib/commonjs/types/index.js.map +1 -1
  142. package/lib/module/NativeStripeSdk.js +1 -1
  143. package/lib/module/NativeStripeSdk.js.map +1 -1
  144. package/lib/module/components/AddToWalletButton.js +1 -1
  145. package/lib/module/components/AddToWalletButton.js.map +1 -1
  146. package/lib/module/components/AddressSheet.js +1 -1
  147. package/lib/module/components/AddressSheet.js.map +1 -1
  148. package/lib/module/components/ApplePayButtonNative.js +1 -1
  149. package/lib/module/components/ApplePayButtonNative.js.map +1 -1
  150. package/lib/module/components/AuBECSDebitForm.js +1 -1
  151. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  152. package/lib/module/components/CardField.js +1 -1
  153. package/lib/module/components/CardField.js.map +1 -1
  154. package/lib/module/components/CardForm.js +1 -1
  155. package/lib/module/components/CardForm.js.map +1 -1
  156. package/lib/module/components/CustomerSheet.js +1 -1
  157. package/lib/module/components/CustomerSheet.js.map +1 -1
  158. package/lib/module/components/GooglePayButtonNative.js +1 -1
  159. package/lib/module/components/GooglePayButtonNative.js.map +1 -1
  160. package/lib/module/components/PlatformPayButton.js +1 -1
  161. package/lib/module/components/PlatformPayButton.js.map +1 -1
  162. package/lib/module/components/StripeContainer.js +1 -1
  163. package/lib/module/components/StripeContainer.js.map +1 -1
  164. package/lib/module/components/StripeProvider.js +1 -1
  165. package/lib/module/components/StripeProvider.js.map +1 -1
  166. package/lib/module/functions.js +1 -1
  167. package/lib/module/functions.js.map +1 -1
  168. package/lib/module/helpers.js +1 -1
  169. package/lib/module/helpers.js.map +1 -1
  170. package/lib/module/hooks/useConfirmPayment.js.map +1 -1
  171. package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
  172. package/lib/module/hooks/useFinancialConnectionsSheet.js +1 -1
  173. package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
  174. package/lib/module/hooks/usePaymentSheet.js.map +1 -1
  175. package/lib/module/hooks/usePlatformPay.js.map +1 -1
  176. package/lib/module/hooks/useStripe.js +1 -1
  177. package/lib/module/hooks/useStripe.js.map +1 -1
  178. package/lib/module/index.js.map +1 -1
  179. package/lib/module/package.json +1 -0
  180. package/lib/module/plugin/withStripe.js +1 -1
  181. package/lib/module/plugin/withStripe.js.map +1 -1
  182. package/lib/module/types/ApplePay.js.map +1 -1
  183. package/lib/module/types/Common.js +1 -1
  184. package/lib/module/types/Common.js.map +1 -1
  185. package/lib/module/types/CustomerSheet.js.map +1 -1
  186. package/lib/module/types/Errors.js +1 -1
  187. package/lib/module/types/Errors.js.map +1 -1
  188. package/lib/module/types/FinancialConnections.js +1 -1
  189. package/lib/module/types/FinancialConnections.js.map +1 -1
  190. package/lib/module/types/NextAction.js.map +1 -1
  191. package/lib/module/types/PaymentIntent.js +1 -1
  192. package/lib/module/types/PaymentIntent.js.map +1 -1
  193. package/lib/module/types/PaymentMethod.js.map +1 -1
  194. package/lib/module/types/PaymentSheet.js +1 -1
  195. package/lib/module/types/PaymentSheet.js.map +1 -1
  196. package/lib/module/types/PlatformPay.js +1 -1
  197. package/lib/module/types/PlatformPay.js.map +1 -1
  198. package/lib/module/types/PushProvisioning.js +1 -1
  199. package/lib/module/types/PushProvisioning.js.map +1 -1
  200. package/lib/module/types/SetupIntent.js +1 -1
  201. package/lib/module/types/SetupIntent.js.map +1 -1
  202. package/lib/module/types/ThreeDSecure.js +1 -1
  203. package/lib/module/types/ThreeDSecure.js.map +1 -1
  204. package/lib/module/types/Token.js.map +1 -1
  205. package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
  206. package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
  207. package/lib/module/types/components/CardFieldInput.js +1 -1
  208. package/lib/module/types/components/CardFieldInput.js.map +1 -1
  209. package/lib/module/types/components/CardFormView.js.map +1 -1
  210. package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -1
  211. package/lib/module/types/index.js +1 -1
  212. package/lib/module/types/index.js.map +1 -1
  213. package/lib/typescript/src/NativeStripeSdk.d.ts +5 -4
  214. package/lib/typescript/src/NativeStripeSdk.d.ts.map +1 -0
  215. package/lib/typescript/src/components/AddToWalletButton.d.ts +3 -1
  216. package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -0
  217. package/lib/typescript/src/components/AddressSheet.d.ts +4 -2
  218. package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -0
  219. package/lib/typescript/src/components/ApplePayButtonNative.d.ts +1 -0
  220. package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +1 -0
  221. package/lib/typescript/src/components/AuBECSDebitForm.d.ts +3 -1
  222. package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -0
  223. package/lib/typescript/src/components/CardField.d.ts +1 -0
  224. package/lib/typescript/src/components/CardField.d.ts.map +1 -0
  225. package/lib/typescript/src/components/CardForm.d.ts +1 -0
  226. package/lib/typescript/src/components/CardForm.d.ts.map +1 -0
  227. package/lib/typescript/src/components/CustomerSheet.d.ts +2 -1
  228. package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -0
  229. package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -0
  230. package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +1 -0
  231. package/lib/typescript/src/components/PlatformPayButton.d.ts +3 -1
  232. package/lib/typescript/src/components/PlatformPayButton.d.ts.map +1 -0
  233. package/lib/typescript/src/components/StripeContainer.d.ts +2 -1
  234. package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -0
  235. package/lib/typescript/src/components/StripeProvider.d.ts +3 -2
  236. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -0
  237. package/lib/typescript/src/functions.d.ts +12 -7
  238. package/lib/typescript/src/functions.d.ts.map +1 -0
  239. package/lib/typescript/src/helpers.d.ts +1 -0
  240. package/lib/typescript/src/helpers.d.ts.map +1 -0
  241. package/lib/typescript/src/hooks/useConfirmPayment.d.ts +2 -1
  242. package/lib/typescript/src/hooks/useConfirmPayment.d.ts.map +1 -0
  243. package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts +1 -0
  244. package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts.map +1 -0
  245. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +5 -2
  246. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -0
  247. package/lib/typescript/src/hooks/usePaymentSheet.d.ts +2 -1
  248. package/lib/typescript/src/hooks/usePaymentSheet.d.ts.map +1 -0
  249. package/lib/typescript/src/hooks/usePlatformPay.d.ts +4 -3
  250. package/lib/typescript/src/hooks/usePlatformPay.d.ts.map +1 -0
  251. package/lib/typescript/src/hooks/useStripe.d.ts +11 -8
  252. package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -0
  253. package/lib/typescript/src/index.d.ts +1 -0
  254. package/lib/typescript/src/index.d.ts.map +1 -0
  255. package/lib/typescript/src/plugin/withStripe.d.ts +2 -1
  256. package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -0
  257. package/lib/typescript/src/types/ApplePay.d.ts +6 -5
  258. package/lib/typescript/src/types/ApplePay.d.ts.map +1 -0
  259. package/lib/typescript/src/types/Common.d.ts +4 -1
  260. package/lib/typescript/src/types/Common.d.ts.map +1 -0
  261. package/lib/typescript/src/types/CustomerSheet.d.ts +12 -4
  262. package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -0
  263. package/lib/typescript/src/types/Errors.d.ts +2 -1
  264. package/lib/typescript/src/types/Errors.d.ts.map +1 -0
  265. package/lib/typescript/src/types/FinancialConnections.d.ts +82 -14
  266. package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -0
  267. package/lib/typescript/src/types/NextAction.d.ts +9 -8
  268. package/lib/typescript/src/types/NextAction.d.ts.map +1 -0
  269. package/lib/typescript/src/types/PaymentIntent.d.ts +41 -14
  270. package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
  271. package/lib/typescript/src/types/PaymentMethod.d.ts +27 -15
  272. package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -0
  273. package/lib/typescript/src/types/PaymentSheet.d.ts +72 -22
  274. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -0
  275. package/lib/typescript/src/types/PlatformPay.d.ts +22 -21
  276. package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -0
  277. package/lib/typescript/src/types/PushProvisioning.d.ts +5 -4
  278. package/lib/typescript/src/types/PushProvisioning.d.ts.map +1 -0
  279. package/lib/typescript/src/types/SetupIntent.d.ts +4 -3
  280. package/lib/typescript/src/types/SetupIntent.d.ts.map +1 -0
  281. package/lib/typescript/src/types/ThreeDSecure.d.ts +1 -0
  282. package/lib/typescript/src/types/ThreeDSecure.d.ts.map +1 -0
  283. package/lib/typescript/src/types/Token.d.ts +10 -9
  284. package/lib/typescript/src/types/Token.d.ts.map +1 -0
  285. package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +3 -2
  286. package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts.map +1 -0
  287. package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts +1 -0
  288. package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts.map +1 -0
  289. package/lib/typescript/src/types/components/CardFieldInput.d.ts +8 -5
  290. package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -0
  291. package/lib/typescript/src/types/components/CardFormView.d.ts +9 -6
  292. package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -0
  293. package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +1 -0
  294. package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts.map +1 -0
  295. package/lib/typescript/src/types/index.d.ts +24 -23
  296. package/lib/typescript/src/types/index.d.ts.map +1 -0
  297. package/package.json +33 -42
  298. package/src/NativeStripeSdk.tsx +5 -3
  299. package/src/components/CardField.tsx +1 -1
  300. package/src/components/CardForm.tsx +12 -9
  301. package/src/components/CustomerSheet.tsx +4 -6
  302. package/src/components/StripeProvider.tsx +17 -0
  303. package/src/functions.ts +70 -16
  304. package/src/hooks/useFinancialConnectionsSheet.tsx +12 -4
  305. package/src/hooks/useStripe.tsx +10 -4
  306. package/src/types/Common.ts +3 -0
  307. package/src/types/CustomerSheet.ts +7 -0
  308. package/src/types/FinancialConnections.ts +72 -0
  309. package/src/types/PaymentIntent.ts +30 -1
  310. package/src/types/PaymentMethod.ts +13 -1
  311. package/src/types/PaymentSheet.ts +65 -5
  312. package/src/types/components/CardFieldInput.ts +8 -4
  313. package/src/types/components/CardFormView.ts +8 -4
  314. package/stripe-react-native.podspec +2 -1
@@ -1,18 +1,9 @@
1
1
  package com.reactnativestripesdk.utils
2
2
 
3
3
  class PostalCodeUtilities {
4
-
5
4
  companion object {
6
- internal fun isValidGlobalPostalCodeCharacter(c: Char): Boolean {
7
- return Character.isLetterOrDigit(c)
8
- || c.isWhitespace()
9
- || c == '-'
10
- }
5
+ internal fun isValidGlobalPostalCodeCharacter(c: Char): Boolean = Character.isLetterOrDigit(c) || c.isWhitespace() || c == '-'
11
6
 
12
- internal fun isValidUsPostalCodeCharacter(c: Char): Boolean {
13
- return Character.isDigit(c)
14
- || c.isWhitespace()
15
- || c == '-'
16
- }
7
+ internal fun isValidUsPostalCodeCharacter(c: Char): Boolean = Character.isDigit(c) || c.isWhitespace() || c == '-'
17
8
  }
18
9
  }
@@ -20,7 +20,8 @@ class CustomerSheetUtils {
20
20
  billingDetailsCollectionConfiguration: NSDictionary?,
21
21
  defaultBillingDetails: NSDictionary?,
22
22
  preferredNetworks: Array<Int>?,
23
- allowsRemovalOfLastSavedPaymentMethod: Bool?
23
+ allowsRemovalOfLastSavedPaymentMethod: Bool?,
24
+ cardBrandAcceptance: PaymentSheet.CardBrandAcceptance
24
25
  ) -> CustomerSheet.Configuration {
25
26
  var config = CustomerSheet.Configuration()
26
27
  config.appearance = appearance
@@ -58,6 +59,7 @@ class CustomerSheetUtils {
58
59
  if let allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod {
59
60
  config.allowsRemovalOfLastSavedPaymentMethod = allowsRemovalOfLastSavedPaymentMethod
60
61
  }
62
+ config.cardBrandAcceptance = cardBrandAcceptance
61
63
  return config
62
64
  }
63
65
 
@@ -14,10 +14,18 @@ class FinancialConnections {
14
14
  internal static func present(
15
15
  withClientSecret: String,
16
16
  returnURL: String? = nil,
17
+ configuration: FinancialConnectionsSheet.Configuration? = nil,
18
+ onEvent: ((FinancialConnectionsEvent) -> Void)? = nil,
17
19
  resolve: @escaping RCTPromiseResolveBlock
18
20
  ) -> Void {
19
21
  DispatchQueue.main.async {
20
- FinancialConnectionsSheet(financialConnectionsSessionClientSecret: withClientSecret, returnURL: returnURL).present(
22
+ let financialConnectionsSheet = FinancialConnectionsSheet(
23
+ financialConnectionsSessionClientSecret: withClientSecret,
24
+ returnURL: returnURL,
25
+ configuration: configuration ?? .init()
26
+ )
27
+ financialConnectionsSheet.onEvent = onEvent
28
+ financialConnectionsSheet.present(
21
29
  from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
22
30
  completion: { result in
23
31
  switch result {
@@ -35,10 +43,18 @@ class FinancialConnections {
35
43
  internal static func presentForToken(
36
44
  withClientSecret: String,
37
45
  returnURL: String? = nil,
46
+ configuration: FinancialConnectionsSheet.Configuration? = nil,
47
+ onEvent: ((FinancialConnectionsEvent) -> Void)? = nil,
38
48
  resolve: @escaping RCTPromiseResolveBlock
39
49
  ) -> Void {
40
50
  DispatchQueue.main.async {
41
- FinancialConnectionsSheet(financialConnectionsSessionClientSecret: withClientSecret, returnURL: returnURL).presentForToken(
51
+ let financialConnectionsSheet = FinancialConnectionsSheet(
52
+ financialConnectionsSessionClientSecret: withClientSecret,
53
+ returnURL: returnURL,
54
+ configuration: configuration ?? .init()
55
+ )
56
+ financialConnectionsSheet.onEvent = onEvent
57
+ financialConnectionsSheet.presentForToken(
42
58
  from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
43
59
  completion: { result in
44
60
  switch result {
package/ios/Mappers.swift CHANGED
@@ -1050,4 +1050,27 @@ class Mappers {
1050
1050
  return nil
1051
1051
  }
1052
1052
  }
1053
+
1054
+ class func financialConnectionsEventToMap(_ event: FinancialConnectionsEvent) -> [String: Any] {
1055
+ var metadata: [String: Any] = [:]
1056
+
1057
+ if let manualEntry = event.metadata.manualEntry {
1058
+ metadata["manualEntry"] = manualEntry
1059
+ }
1060
+
1061
+ if let institutionName = event.metadata.institutionName {
1062
+ metadata["institutionName"] = institutionName
1063
+ }
1064
+
1065
+ if let errorCode = event.metadata.errorCode {
1066
+ metadata["errorCode"] = errorCode.rawValue
1067
+ }
1068
+
1069
+ let mappedEvent: [String: Any] = [
1070
+ "name": event.name.rawValue,
1071
+ "metadata": metadata
1072
+ ]
1073
+
1074
+ return mappedEvent
1075
+ }
1053
1076
  }
@@ -7,6 +7,7 @@ class PaymentMethodFactory {
7
7
  var paymentMethodOptions: NSDictionary? = nil
8
8
  var cardFieldView: CardFieldView? = nil
9
9
  var cardFormView: CardFormView? = nil
10
+ var metadata: [String: String]? = nil
10
11
 
11
12
  init(paymentMethodData: NSDictionary?, options: NSDictionary, cardFieldView: CardFieldView?, cardFormView: CardFormView?) {
12
13
  self.paymentMethodData = paymentMethodData
@@ -14,6 +15,7 @@ class PaymentMethodFactory {
14
15
  self.paymentMethodOptions = options
15
16
  self.cardFieldView = cardFieldView
16
17
  self.cardFormView = cardFormView
18
+ self.metadata = paymentMethodData?["metadata"] as? [String: String]
17
19
  }
18
20
 
19
21
  func createParams(paymentMethodType: STPPaymentMethodType) throws -> STPPaymentMethodParams? {
@@ -124,7 +126,7 @@ class PaymentMethodFactory {
124
126
 
125
127
  // private func createWeChatPayPaymentMethodParams() throws -> STPPaymentMethodParams {
126
128
  // let params = STPPaymentMethodWeChatPayParams()
127
- // return STPPaymentMethodParams(weChatPay: params, billingDetails: billingDetailsParams, metadata: nil)
129
+ // return STPPaymentMethodParams(weChatPay: params, billingDetails: billingDetailsParams, metadata: metadata)
128
130
  // }
129
131
  //
130
132
 
@@ -152,22 +154,22 @@ class PaymentMethodFactory {
152
154
  if let bankName = self.paymentMethodData?["bankName"] as? String {
153
155
  params.bankName = bankName
154
156
  }
155
-
156
157
 
157
- return STPPaymentMethodParams(iDEAL: params, billingDetails: billingDetailsParams, metadata: nil)
158
+
159
+ return STPPaymentMethodParams(iDEAL: params, billingDetails: billingDetailsParams, metadata: metadata)
158
160
  }
159
161
 
160
162
  private func createGrabpayPaymentMethodParams() -> STPPaymentMethodParams {
161
163
  let params = STPPaymentMethodGrabPayParams()
162
164
 
163
- return STPPaymentMethodParams(grabPay: params, billingDetails: billingDetailsParams, metadata: nil)
165
+ return STPPaymentMethodParams(grabPay: params, billingDetails: billingDetailsParams, metadata: metadata)
164
166
  }
165
167
 
166
168
  private func createCardPaymentMethodParams() throws -> STPPaymentMethodParams {
167
169
  if let token = paymentMethodData?["token"] as? String {
168
170
  let methodParams = STPPaymentMethodCardParams()
169
171
  methodParams.token = token
170
- return STPPaymentMethodParams(card: methodParams, billingDetails: billingDetailsParams, metadata: nil)
172
+ return STPPaymentMethodParams(card: methodParams, billingDetails: billingDetailsParams, metadata: metadata)
171
173
  }
172
174
 
173
175
  if let params = cardFieldView?.cardParams as? STPPaymentMethodParams {
@@ -197,7 +199,7 @@ class PaymentMethodFactory {
197
199
  billingDetailsParams?.address?.country = address.country
198
200
  }
199
201
  }
200
- return STPPaymentMethodParams(card: params, billingDetails: billingDetailsParams, metadata: nil)
202
+ return STPPaymentMethodParams(card: params, billingDetails: billingDetailsParams, metadata: metadata)
201
203
  }
202
204
 
203
205
  throw PaymentMethodError.cardPaymentMissingParams
@@ -225,11 +227,11 @@ class PaymentMethodFactory {
225
227
  params.rawBankString = "test_offline_bank"
226
228
  }
227
229
 
228
- return STPPaymentMethodParams(fpx: params, billingDetails: billingDetailsParams, metadata: nil)
230
+ return STPPaymentMethodParams(fpx: params, billingDetails: billingDetailsParams, metadata: metadata)
229
231
  }
230
232
 
231
233
  private func createAlipayPaymentMethodParams() throws -> STPPaymentMethodParams {
232
- return STPPaymentMethodParams(alipay: STPPaymentMethodAlipayParams(), billingDetails: billingDetailsParams, metadata: nil)
234
+ return STPPaymentMethodParams(alipay: STPPaymentMethodAlipayParams(), billingDetails: billingDetailsParams, metadata: metadata)
233
235
  }
234
236
 
235
237
  private func createP24PaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -239,7 +241,7 @@ class PaymentMethodFactory {
239
241
  throw PaymentMethodError.p24PaymentMissingParams
240
242
  }
241
243
 
242
- return STPPaymentMethodParams(przelewy24: params, billingDetails: billingDetails, metadata: nil)
244
+ return STPPaymentMethodParams(przelewy24: params, billingDetails: billingDetails, metadata: metadata)
243
245
  }
244
246
 
245
247
  private func createAlipayPaymentMethodOptions() throws -> STPConfirmPaymentMethodOptions {
@@ -255,7 +257,7 @@ class PaymentMethodFactory {
255
257
  let params = STPPaymentMethodSofortParams()
256
258
  params.country = country
257
259
 
258
- return STPPaymentMethodParams(sofort: params, billingDetails: billingDetailsParams, metadata: nil)
260
+ return STPPaymentMethodParams(sofort: params, billingDetails: billingDetailsParams, metadata: metadata)
259
261
  }
260
262
 
261
263
  private func createBancontactPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -265,7 +267,7 @@ class PaymentMethodFactory {
265
267
  throw PaymentMethodError.bancontactPaymentMissingParams
266
268
  }
267
269
 
268
- return STPPaymentMethodParams(bancontact: params, billingDetails: billingDetails, metadata: nil)
270
+ return STPPaymentMethodParams(bancontact: params, billingDetails: billingDetails, metadata: metadata)
269
271
  }
270
272
 
271
273
  private func createSepaPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -280,7 +282,7 @@ class PaymentMethodFactory {
280
282
 
281
283
  params.iban = iban
282
284
 
283
- return STPPaymentMethodParams(sepaDebit: params, billingDetails: billingDetails, metadata: nil)
285
+ return STPPaymentMethodParams(sepaDebit: params, billingDetails: billingDetails, metadata: metadata)
284
286
  }
285
287
 
286
288
  private func createOXXOPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -290,7 +292,7 @@ class PaymentMethodFactory {
290
292
  throw PaymentMethodError.bancontactPaymentMissingParams
291
293
  }
292
294
 
293
- return STPPaymentMethodParams(oxxo: params, billingDetails: billingDetails, metadata: nil)
295
+ return STPPaymentMethodParams(oxxo: params, billingDetails: billingDetails, metadata: metadata)
294
296
  }
295
297
 
296
298
  private func createGiropayPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -300,7 +302,7 @@ class PaymentMethodFactory {
300
302
  throw PaymentMethodError.giropayPaymentMissingParams
301
303
  }
302
304
 
303
- return STPPaymentMethodParams(giropay: params, billingDetails: billingDetails, metadata: nil)
305
+ return STPPaymentMethodParams(giropay: params, billingDetails: billingDetails, metadata: metadata)
304
306
  }
305
307
 
306
308
  private func createEPSPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -310,7 +312,7 @@ class PaymentMethodFactory {
310
312
  throw PaymentMethodError.epsPaymentMissingParams
311
313
  }
312
314
 
313
- return STPPaymentMethodParams(eps: params, billingDetails: billingDetails, metadata: nil)
315
+ return STPPaymentMethodParams(eps: params, billingDetails: billingDetails, metadata: metadata)
314
316
  }
315
317
 
316
318
  private func createBECSDebitPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -324,7 +326,7 @@ class PaymentMethodFactory {
324
326
  params.accountNumber = formDetails?["accountNumber"] as? String
325
327
  params.bsbNumber = formDetails?["bsbNumber"] as? String
326
328
 
327
- return STPPaymentMethodParams(aubecsDebit: params, billingDetails: billingDetails, metadata: nil)
329
+ return STPPaymentMethodParams(aubecsDebit: params, billingDetails: billingDetails, metadata: metadata)
328
330
  }
329
331
 
330
332
  private func createAfterpayClearpayPaymentMethodParams() throws -> STPPaymentMethodParams {
@@ -334,19 +336,19 @@ class PaymentMethodFactory {
334
336
  throw PaymentMethodError.afterpayClearpayPaymentMissingParams
335
337
  }
336
338
 
337
- return STPPaymentMethodParams(afterpayClearpay: params, billingDetails: billingDetails, metadata: nil)
339
+ return STPPaymentMethodParams(afterpayClearpay: params, billingDetails: billingDetails, metadata: metadata)
338
340
  }
339
341
 
340
342
  private func createKlarnaPaymentMethodParams() throws -> STPPaymentMethodParams {
341
343
  let params = STPPaymentMethodKlarnaParams()
342
344
 
343
345
  if let billingDetails = billingDetailsParams, billingDetails.address?.country != nil, billingDetails.email != nil {
344
- return STPPaymentMethodParams(klarna: params, billingDetails: billingDetails, metadata: nil)
346
+ return STPPaymentMethodParams(klarna: params, billingDetails: billingDetails, metadata: metadata)
345
347
  } else {
346
348
  throw PaymentMethodError.klarnaPaymentMissingParams
347
349
  }
348
350
  }
349
-
351
+
350
352
  private func createUSBankAccountPaymentMethodParams() throws -> STPPaymentMethodParams {
351
353
  let params = STPPaymentMethodUSBankAccountParams()
352
354
 
@@ -363,36 +365,36 @@ class PaymentMethodFactory {
363
365
  params.accountType = Mappers.mapToUSBankAccountType(type: self.paymentMethodData?["accountType"] as? String)
364
366
 
365
367
  if let billingDetails = billingDetailsParams, billingDetails.name != nil {
366
- return STPPaymentMethodParams(usBankAccount: params, billingDetails: billingDetails, metadata: nil)
368
+ return STPPaymentMethodParams(usBankAccount: params, billingDetails: billingDetails, metadata: metadata)
367
369
  } else {
368
370
  throw PaymentMethodError.usBankAccountPaymentMissingParams
369
371
  }
370
372
  }
371
-
373
+
372
374
  private func createPayPalPaymentMethodParams() throws -> STPPaymentMethodParams {
373
- return STPPaymentMethodParams(payPal: STPPaymentMethodPayPalParams(), billingDetails: billingDetailsParams, metadata: nil)
375
+ return STPPaymentMethodParams(payPal: STPPaymentMethodPayPalParams(), billingDetails: billingDetailsParams, metadata: metadata)
374
376
  }
375
-
377
+
376
378
  private func createAffirmPaymentMethodParams() throws -> STPPaymentMethodParams {
377
379
  let params = STPPaymentMethodAffirmParams()
378
- return STPPaymentMethodParams(affirm: params, metadata: nil)
380
+ return STPPaymentMethodParams(affirm: params, metadata: metadata)
379
381
  }
380
-
382
+
381
383
  private func createCashAppPaymentMethodParams() throws -> STPPaymentMethodParams {
382
384
  let params = STPPaymentMethodCashAppParams()
383
- return STPPaymentMethodParams(cashApp: params, billingDetails: billingDetailsParams, metadata: nil)
385
+ return STPPaymentMethodParams(cashApp: params, billingDetails: billingDetailsParams, metadata: metadata)
384
386
  }
385
-
387
+
386
388
  private func createRevolutPayPaymentMethodParams() throws -> STPPaymentMethodParams {
387
389
  let params = STPPaymentMethodRevolutPayParams()
388
- return STPPaymentMethodParams(revolutPay: params, billingDetails: billingDetailsParams, metadata: nil)
390
+ return STPPaymentMethodParams(revolutPay: params, billingDetails: billingDetailsParams, metadata: metadata)
389
391
  }
390
392
 
391
393
  func createMandateData() -> STPMandateDataParams? {
392
394
  if let mandateParams = paymentMethodData?["mandateData"] as? NSDictionary {
393
395
  if let customerAcceptanceParams = mandateParams["customerAcceptance"] as? NSDictionary {
394
396
  let mandate = STPMandateDataParams.init(customerAcceptance: STPMandateCustomerAcceptanceParams.init())
395
-
397
+
396
398
  mandate.customerAcceptance.type = .online
397
399
  if let onlineParams = customerAcceptanceParams["online"] as? NSDictionary {
398
400
  mandate.customerAcceptance.onlineParams = .init(ipAddress: onlineParams["ipAddress"] as? String ?? "", userAgent: onlineParams["userAgent"] as? String ?? "")
@@ -24,7 +24,8 @@ extension StripeSdk {
24
24
  billingDetailsCollectionConfiguration: params["billingDetailsCollectionConfiguration"] as? NSDictionary,
25
25
  defaultBillingDetails: params["defaultBillingDetails"] as? NSDictionary,
26
26
  preferredNetworks: params["preferredNetworks"] as? Array<Int>,
27
- allowsRemovalOfLastSavedPaymentMethod: params["allowsRemovalOfLastSavedPaymentMethod"] as? Bool
27
+ allowsRemovalOfLastSavedPaymentMethod: params["allowsRemovalOfLastSavedPaymentMethod"] as? Bool,
28
+ cardBrandAcceptance: computeCardBrandAcceptance(params: params)
28
29
  )
29
30
  } catch {
30
31
  resolve(
@@ -125,6 +125,8 @@ extension StripeSdk {
125
125
  default:
126
126
  configuration.paymentMethodLayout = .automatic
127
127
  }
128
+
129
+ configuration.cardBrandAcceptance = computeCardBrandAcceptance(params: params)
128
130
 
129
131
  return (nil, configuration)
130
132
  }
@@ -216,6 +218,46 @@ extension StripeSdk {
216
218
  }
217
219
  }
218
220
  }
221
+
222
+ internal func computeCardBrandAcceptance(params: NSDictionary) -> PaymentSheet.CardBrandAcceptance {
223
+ if let cardBrandAcceptanceParams = params["cardBrandAcceptance"] as? NSDictionary {
224
+ if let filter = cardBrandAcceptanceParams["filter"] as? String {
225
+ switch filter {
226
+ case "all":
227
+ return .all
228
+ case "allowed":
229
+ if let brands = cardBrandAcceptanceParams["brands"] as? [String] {
230
+ let cardBrands = brands.compactMap { mapToCardBrandCategory(brand: $0) }
231
+ return .allowed(brands: cardBrands)
232
+ }
233
+ case "disallowed":
234
+ if let brands = cardBrandAcceptanceParams["brands"] as? [String] {
235
+ let cardBrands = brands.compactMap { mapToCardBrandCategory(brand: $0) }
236
+ return .disallowed(brands: cardBrands)
237
+ }
238
+ default:
239
+ break
240
+ }
241
+ }
242
+ }
243
+
244
+ return .all
245
+ }
246
+
247
+ private func mapToCardBrandCategory(brand: String) -> PaymentSheet.CardBrandAcceptance.BrandCategory? {
248
+ switch brand {
249
+ case "visa":
250
+ return .visa
251
+ case "mastercard":
252
+ return .mastercard
253
+ case "amex":
254
+ return .amex
255
+ case "discover":
256
+ return .discover
257
+ default:
258
+ return nil
259
+ }
260
+ }
219
261
 
220
262
  private func mapCaptureMethod(_ captureMethod: String?) -> PaymentSheet.IntentConfiguration.CaptureMethod {
221
263
  if let captureMethod = captureMethod {
package/ios/StripeSdk.m CHANGED
@@ -170,11 +170,13 @@ RCT_EXTERN_METHOD(
170
170
  )
171
171
  RCT_EXTERN_METHOD(
172
172
  collectBankAccountToken:(NSString *)clientSecret
173
+ params:(NSDictionary *)params
173
174
  resolver: (RCTPromiseResolveBlock)resolve
174
175
  rejecter: (RCTPromiseRejectBlock)reject
175
176
  )
176
177
  RCT_EXTERN_METHOD(
177
178
  collectFinancialConnectionsAccounts:(NSString *)clientSecret
179
+ params:(NSDictionary *)params
178
180
  resolver: (RCTPromiseResolveBlock)resolve
179
181
  rejecter: (RCTPromiseRejectBlock)reject
180
182
  )
@@ -71,7 +71,7 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
71
71
  override func supportedEvents() -> [String]! {
72
72
  return ["onOrderTrackingCallback", "onConfirmHandlerCallback", "onCustomerAdapterFetchPaymentMethodsCallback", "onCustomerAdapterAttachPaymentMethodCallback",
73
73
  "onCustomerAdapterDetachPaymentMethodCallback", "onCustomerAdapterSetSelectedPaymentOptionCallback", "onCustomerAdapterFetchSelectedPaymentOptionCallback",
74
- "onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback"]
74
+ "onCustomerAdapterSetupIntentClientSecretForCustomerAttachCallback", "onFinancialConnectionsEvent"]
75
75
  }
76
76
 
77
77
  @objc override static func requiresMainQueueSetup() -> Bool {
@@ -129,7 +129,7 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
129
129
  }
130
130
 
131
131
  @objc(intentCreationCallback:resolver:rejecter:)
132
- func intentCreationCallback(result: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
132
+ @MainActor func intentCreationCallback(result: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
133
133
  rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
134
134
  guard let paymentSheetIntentCreationCallback = self.paymentSheetIntentCreationCallback else {
135
135
  resolve(Errors.createError(ErrorType.Failed, "No intent creation callback was set"))
@@ -138,18 +138,18 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
138
138
  if let clientSecret = result["clientSecret"] as? String {
139
139
  paymentSheetIntentCreationCallback(.success(clientSecret))
140
140
  } else {
141
- class ConfirmationError: Error, LocalizedError {
142
- private var errorMessage: String
143
- init(errorMessage: String) {
144
- self.errorMessage = errorMessage
145
- }
146
- public var errorDescription: String? {
147
- return errorMessage
148
- }
141
+ struct ConfirmationError: Error, LocalizedError {
142
+ private var errorMessage: String
143
+ init(errorMessage: String) {
144
+ self.errorMessage = errorMessage
145
+ }
146
+ public var errorDescription: String? {
147
+ return errorMessage
149
148
  }
150
- let errorParams = result["error"] as? NSDictionary
151
- let error = ConfirmationError.init(errorMessage: errorParams?["localizedMessage"] as? String ?? "An unknown error occurred.")
152
- paymentSheetIntentCreationCallback(.failure(error))
149
+ }
150
+ let errorParams = result["error"] as? NSDictionary
151
+ let error = ConfirmationError.init(errorMessage: errorParams?["localizedMessage"] as? String ?? "An unknown error occurred.")
152
+ paymentSheetIntentCreationCallback(.failure(error))
153
153
  }
154
154
  }
155
155
 
@@ -730,16 +730,29 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
730
730
  if let urlScheme = urlScheme {
731
731
  connectionsReturnURL = Mappers.mapToFinancialConnectionsReturnURL(urlScheme: urlScheme)
732
732
  } else {
733
- connectionsReturnURL = nil
733
+ connectionsReturnURL = nil
734
734
  }
735
735
 
736
+ var onEvent: ((FinancialConnectionsEvent) -> Void)? = nil
737
+
738
+ if hasEventListeners {
739
+ onEvent = { [weak self] event in
740
+ let mappedEvent = Mappers.financialConnectionsEventToMap(event)
741
+ self?.sendEvent(withName: "onFinancialConnectionsEvent", body: mappedEvent)
742
+ }
743
+ }
744
+
745
+ let style = STPBankAccountCollectorUserInterfaceStyle(from: params)
746
+ let bankAccountCollector = STPBankAccountCollector(style: style)
747
+
736
748
  if (isPaymentIntent) {
737
749
  DispatchQueue.main.async {
738
- STPBankAccountCollector().collectBankAccountForPayment(
750
+ bankAccountCollector.collectBankAccountForPayment(
739
751
  clientSecret: clientSecret as String,
740
752
  returnURL: connectionsReturnURL,
741
753
  params: collectParams,
742
- from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
754
+ from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
755
+ onEvent: onEvent
743
756
  ) { intent, error in
744
757
  if let error = error {
745
758
  resolve(Errors.createError(ErrorType.Failed, error as NSError))
@@ -761,11 +774,12 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
761
774
  }
762
775
  } else {
763
776
  DispatchQueue.main.async {
764
- STPBankAccountCollector().collectBankAccountForSetup(
777
+ bankAccountCollector.collectBankAccountForSetup(
765
778
  clientSecret: clientSecret as String,
766
779
  returnURL: connectionsReturnURL,
767
780
  params: collectParams,
768
- from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
781
+ from: findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController()),
782
+ onEvent: onEvent
769
783
  ) { intent, error in
770
784
  if let error = error {
771
785
  resolve(Errors.createError(ErrorType.Failed, error as NSError))
@@ -1026,9 +1040,10 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
1026
1040
  resolve(["isInWallet": PushProvisioningUtils.getPassLocation(last4: last4) != nil])
1027
1041
  }
1028
1042
 
1029
- @objc(collectBankAccountToken:resolver:rejecter:)
1043
+ @objc(collectBankAccountToken:params:resolver:rejecter:)
1030
1044
  func collectBankAccountToken(
1031
1045
  clientSecret: String,
1046
+ params: NSDictionary,
1032
1047
  resolver resolve: @escaping RCTPromiseResolveBlock,
1033
1048
  rejecter reject: @escaping RCTPromiseRejectBlock
1034
1049
  ) -> Void {
@@ -1040,14 +1055,32 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
1040
1055
  if let urlScheme = urlScheme {
1041
1056
  returnURL = Mappers.mapToFinancialConnectionsReturnURL(urlScheme: urlScheme)
1042
1057
  } else {
1043
- returnURL = nil
1058
+ returnURL = nil
1044
1059
  }
1045
- FinancialConnections.presentForToken(withClientSecret: clientSecret, returnURL: returnURL, resolve: resolve)
1060
+
1061
+ let configuration = FinancialConnectionsSheet.Configuration(from: params)
1062
+ var onEvent: ((FinancialConnectionsEvent) -> Void)? = nil
1063
+
1064
+ if hasEventListeners {
1065
+ onEvent = { [weak self] event in
1066
+ let mappedEvent = Mappers.financialConnectionsEventToMap(event)
1067
+ self?.sendEvent(withName: "onFinancialConnectionsEvent", body: mappedEvent)
1068
+ }
1069
+ }
1070
+
1071
+ FinancialConnections.presentForToken(
1072
+ withClientSecret: clientSecret,
1073
+ returnURL: returnURL,
1074
+ configuration: configuration,
1075
+ onEvent: onEvent,
1076
+ resolve: resolve
1077
+ )
1046
1078
  }
1047
1079
 
1048
- @objc(collectFinancialConnectionsAccounts:resolver:rejecter:)
1080
+ @objc(collectFinancialConnectionsAccounts:params:resolver:rejecter:)
1049
1081
  func collectFinancialConnectionsAccounts(
1050
1082
  clientSecret: String,
1083
+ params: NSDictionary,
1051
1084
  resolver resolve: @escaping RCTPromiseResolveBlock,
1052
1085
  rejecter reject: @escaping RCTPromiseRejectBlock
1053
1086
  ) -> Void {
@@ -1059,9 +1092,26 @@ class StripeSdk: RCTEventEmitter, UIAdaptivePresentationControllerDelegate {
1059
1092
  if let urlScheme = urlScheme {
1060
1093
  returnURL = Mappers.mapToFinancialConnectionsReturnURL(urlScheme: urlScheme)
1061
1094
  } else {
1062
- returnURL = nil
1095
+ returnURL = nil
1096
+ }
1097
+
1098
+ let configuration = FinancialConnectionsSheet.Configuration(from: params)
1099
+ var onEvent: ((FinancialConnectionsEvent) -> Void)? = nil
1100
+
1101
+ if hasEventListeners {
1102
+ onEvent = { [weak self] event in
1103
+ let mappedEvent = Mappers.financialConnectionsEventToMap(event)
1104
+ self?.sendEvent(withName: "onFinancialConnectionsEvent", body: mappedEvent)
1105
+ }
1063
1106
  }
1064
- FinancialConnections.present(withClientSecret: clientSecret, returnURL: returnURL, resolve: resolve)
1107
+
1108
+ FinancialConnections.present(
1109
+ withClientSecret: clientSecret,
1110
+ returnURL: returnURL,
1111
+ configuration: configuration,
1112
+ onEvent: onEvent,
1113
+ resolve: resolve
1114
+ )
1065
1115
  }
1066
1116
 
1067
1117
  @objc(configureOrderTracking:orderIdentifier:webServiceUrl:authenticationToken:resolver:rejecter:)
@@ -1146,3 +1196,45 @@ extension StripeSdk: STPAuthenticationContext {
1146
1196
  return findViewControllerPresenter(from: UIApplication.shared.delegate?.window??.rootViewController ?? UIViewController())
1147
1197
  }
1148
1198
  }
1199
+
1200
+ extension STPBankAccountCollectorUserInterfaceStyle {
1201
+ init(from params: NSDictionary) {
1202
+ guard let styleString = params["style"] as? String else {
1203
+ self = .automatic
1204
+ return
1205
+ }
1206
+
1207
+ switch styleString {
1208
+ case "automatic":
1209
+ self = .automatic
1210
+ case "alwaysLight":
1211
+ self = .alwaysLight
1212
+ case "alwaysDark":
1213
+ self = .alwaysDark
1214
+ default:
1215
+ self = .automatic
1216
+ }
1217
+ }
1218
+ }
1219
+
1220
+ extension FinancialConnectionsSheet.Configuration {
1221
+ init(from params: NSDictionary) {
1222
+ let style: FinancialConnectionsSheet.Configuration.UserInterfaceStyle = {
1223
+ guard let styleString = params["style"] as? String else {
1224
+ return .automatic
1225
+ }
1226
+
1227
+ switch styleString {
1228
+ case "automatic":
1229
+ return .automatic
1230
+ case "alwaysLight":
1231
+ return .alwaysLight
1232
+ case "alwaysDark":
1233
+ return .alwaysDark
1234
+ default:
1235
+ return .automatic
1236
+ }
1237
+ }()
1238
+ self.init(style: style)
1239
+ }
1240
+ }
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var StripeSdk=_reactNative.NativeModules.StripeSdk;var _default=StripeSdk;exports.default=_default;
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var StripeSdk=_reactNative.NativeModules.StripeSdk;var _default=exports.default=StripeSdk;
2
2
  //# sourceMappingURL=NativeStripeSdk.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["StripeSdk","NativeModules"],"sources":["NativeStripeSdk.tsx"],"sourcesContent":["import { NativeModules } from 'react-native';\nimport type {\n PaymentMethod,\n PaymentIntent,\n PlatformPay,\n PaymentSheet,\n SetupIntent,\n InitialiseParams,\n CreatePaymentMethodResult,\n RetrievePaymentIntentResult,\n RetrieveSetupIntentResult,\n ConfirmPaymentResult,\n HandleNextActionResult,\n HandleNextActionForSetupResult,\n ConfirmSetupIntentResult,\n CreateTokenForCVCUpdateResult,\n InitPaymentSheetResult,\n PresentPaymentSheetResult,\n ConfirmPaymentSheetPaymentResult,\n CreateTokenResult,\n OpenApplePaySetupResult,\n Token,\n VerifyMicrodepositsParams,\n IsCardInWalletResult,\n CanAddCardToWalletParams,\n CanAddCardToWalletResult,\n FinancialConnections,\n CustomerSheetInitParams,\n CustomerSheetPresentParams,\n CustomerSheetResult,\n CustomerSheetError,\n StripeError,\n CustomerPaymentOption,\n CustomerAdapter,\n} from './types';\n\ntype NativeStripeSdkType = {\n initialise(params: InitialiseParams): Promise<void>;\n createPaymentMethod(\n params: PaymentMethod.CreateParams,\n options: PaymentMethod.CreateOptions\n ): Promise<CreatePaymentMethodResult>;\n handleNextAction(\n paymentIntentClientSecret: string,\n returnURL?: string | null\n ): Promise<HandleNextActionResult>;\n handleNextActionForSetup(\n setupIntentClientSecret: string,\n returnURL?: string | null\n ): Promise<HandleNextActionForSetupResult>;\n confirmPayment(\n paymentIntentClientSecret: string,\n params?: PaymentIntent.ConfirmParams,\n options?: PaymentIntent.ConfirmOptions\n ): Promise<ConfirmPaymentResult>;\n confirmSetupIntent(\n paymentIntentClientSecret: string,\n params: SetupIntent.ConfirmParams,\n options: SetupIntent.ConfirmOptions\n ): Promise<ConfirmSetupIntentResult>;\n retrievePaymentIntent(\n clientSecret: string\n ): Promise<RetrievePaymentIntentResult>;\n retrieveSetupIntent(clientSecret: string): Promise<RetrieveSetupIntentResult>;\n initPaymentSheet(\n params: PaymentSheet.SetupParams\n ): Promise<InitPaymentSheetResult>;\n intentCreationCallback(\n result: PaymentSheet.IntentCreationCallbackParams\n ): void;\n presentPaymentSheet(\n options: PaymentSheet.PresentOptions\n ): Promise<PresentPaymentSheetResult>;\n confirmPaymentSheetPayment(): Promise<ConfirmPaymentSheetPaymentResult>;\n createTokenForCVCUpdate(cvc: string): Promise<CreateTokenForCVCUpdateResult>;\n handleURLCallback(url: string): Promise<boolean>;\n createToken(params: Token.CreateParams): Promise<CreateTokenResult>;\n openApplePaySetup(): Promise<OpenApplePaySetupResult>;\n verifyMicrodeposits(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: VerifyMicrodepositsParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n collectBankAccount(\n isPaymentIntent: boolean,\n clientSecret: string,\n params: PaymentMethod.CollectBankAccountParams\n ): Promise<ConfirmSetupIntentResult | ConfirmPaymentResult>;\n getConstants(): { API_VERSIONS: { CORE: string; ISSUING: string } };\n canAddCardToWallet(\n params: CanAddCardToWalletParams\n ): Promise<CanAddCardToWalletResult>;\n isCardInWallet(params: {\n cardLastFour: string;\n }): Promise<IsCardInWalletResult>;\n collectBankAccountToken(\n clientSecret: string\n ): Promise<FinancialConnections.TokenResult>;\n collectFinancialConnectionsAccounts(\n clientSecret: string\n ): Promise<FinancialConnections.SessionResult>;\n resetPaymentSheetCustomer(): Promise<null>;\n isPlatformPaySupported(params: {\n googlePay?: PlatformPay.IsGooglePaySupportedParams;\n }): Promise<boolean>;\n createPlatformPayPaymentMethod(\n params: PlatformPay.PaymentMethodParams,\n usesDeprecatedTokenFlow: boolean\n ): Promise<PlatformPay.PaymentMethodResult | PlatformPay.TokenResult>;\n dismissPlatformPay(): Promise<boolean>;\n updatePlatformPaySheet(\n summaryItems: Array<PlatformPay.CartSummaryItem>,\n shippingMethods: Array<PlatformPay.ShippingMethod>,\n errors: Array<PlatformPay.ApplePaySheetError>\n ): Promise<void>;\n confirmPlatformPay(\n clientSecret: string,\n params: PlatformPay.ConfirmParams,\n isPaymentIntent: boolean\n ): Promise<\n PlatformPay.ConfirmPaymentResult | PlatformPay.ConfirmSetupIntentResult\n >;\n configureOrderTracking(\n orderTypeIdentifier: string,\n orderIdentifier: string,\n webServiceUrl: string,\n authenticationToken: string\n ): Promise<void>;\n initCustomerSheet(\n params: CustomerSheetInitParams,\n customerAdapterOverrides: { [Property in keyof CustomerAdapter]: boolean }\n ): Promise<{ error?: StripeError<CustomerSheetError> }>;\n presentCustomerSheet(\n params: CustomerSheetPresentParams\n ): Promise<CustomerSheetResult>;\n retrieveCustomerSheetPaymentOptionSelection(): Promise<CustomerSheetResult>;\n customerAdapterFetchPaymentMethodsCallback(\n paymentMethods: Array<object>\n ): Promise<void>;\n customerAdapterAttachPaymentMethodCallback(\n paymentMethod: object\n ): Promise<void>;\n customerAdapterDetachPaymentMethodCallback(\n paymentMethod: object\n ): Promise<void>;\n customerAdapterSetSelectedPaymentOptionCallback(): Promise<void>;\n customerAdapterFetchSelectedPaymentOptionCallback(\n paymentOption: CustomerPaymentOption | null\n ): Promise<void>;\n customerAdapterSetupIntentClientSecretForCustomerAttachCallback(\n clientSecret: String\n ): Promise<void>;\n};\n\nconst { StripeSdk } = NativeModules;\n\nexport default StripeSdk as NativeStripeSdkType;\n"],"mappings":"gFAAA,yCA0JA,GAAQA,UAAS,CAAKC,0BAAa,CAA3BD,SAAS,CAAmB,aAErBA,SAAS"}
1
+ {"version":3,"names":["_reactNative","require","StripeSdk","NativeModules","_default","exports","default"],"sourceRoot":"../../src","sources":["NativeStripeSdk.tsx"],"mappings":"gFAAA,IAAAA,YAAA,CAAAC,OAAA,iBA4JA,GAAQ,CAAAC,SAAS,CAAKC,0BAAa,CAA3BD,SAAS,CAAmB,IAAAE,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAErBJ,SAAS","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.AddToWalletButton=AddToWalletButton;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _jsxFileName="/Users/davidestes/stripe/stripe-react-native/src/components/AddToWalletButton.tsx";var _excluded=["onComplete"];var AddToWalletButtonNative=(0,_reactNative.requireNativeComponent)('AddToWalletButton');function AddToWalletButton(_ref){var onComplete=_ref.onComplete,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);return _react.default.createElement(AddToWalletButtonNative,(0,_extends2.default)({},props,{onCompleteAction:function onCompleteAction(value){return onComplete(value.nativeEvent);},__self:this,__source:{fileName:_jsxFileName,lineNumber:84,columnNumber:5}}));}
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.AddToWalletButton=AddToWalletButton;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _jsxFileName="/Users/charliecruzan/stripe/stripe-react-native/src/components/AddToWalletButton.tsx";var _excluded=["onComplete"];var AddToWalletButtonNative=(0,_reactNative.requireNativeComponent)('AddToWalletButton');function AddToWalletButton(_ref){var onComplete=_ref.onComplete,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);return(0,_jsxRuntime.jsx)(AddToWalletButtonNative,Object.assign({},props,{onCompleteAction:function onCompleteAction(value){return onComplete(value.nativeEvent);}}));}
2
2
  //# sourceMappingURL=AddToWalletButton.js.map