@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
@@ -5,22 +5,21 @@ import android.util.Log
5
5
  import com.facebook.react.bridge.ReadableMap
6
6
  import com.facebook.react.bridge.WritableMap
7
7
  import com.facebook.react.bridge.WritableNativeMap
8
- import com.reactnativestripesdk.utils.createError
9
8
  import com.google.android.gms.tasks.Task
9
+ import com.reactnativestripesdk.utils.createError
10
10
 
11
- typealias TokenCheckHandler = (isCardInWallet: Boolean, token: WritableMap?, error: WritableMap?) -> Unit
11
+ typealias TokenCheckHandler =
12
+ (isCardInWallet: Boolean, token: WritableMap?, error: WritableMap?) -> Unit
12
13
 
13
14
  object TapAndPayProxy {
14
15
  private const val TAG = "StripeTapAndPay"
15
16
  private var tapAndPayClient: Any? = null
16
17
  const val REQUEST_CODE_TOKENIZE = 90909
17
18
 
18
- private fun getTapandPayTokens(activity: Activity): Task<List<Any>>? {
19
- return try {
19
+ private fun getTapandPayTokens(activity: Activity): Task<List<Any>>? =
20
+ try {
20
21
  val tapAndPayClass = Class.forName("com.google.android.gms.tapandpay.TapAndPay")
21
- val getClientMethod = tapAndPayClass.getMethod(
22
- "getClient",
23
- Activity::class.java)
22
+ val getClientMethod = tapAndPayClass.getMethod("getClient", Activity::class.java)
24
23
  val client = getClientMethod.invoke(null, activity)
25
24
 
26
25
  val tapAndPayClientClass = Class.forName("com.google.android.gms.tapandpay.TapAndPayClient")
@@ -31,21 +30,28 @@ object TapAndPayProxy {
31
30
  Log.e(TAG, "There was a problem listing tokens with Google TapAndPay: " + e.message)
32
31
  null
33
32
  }
34
- }
35
33
 
36
- internal fun isTokenInWallet(token: Any, newLastFour: String): Boolean {
37
- return try {
38
- val getFpanLastFourMethod = Class.forName("com.google.android.gms.tapandpay.issuer.TokenInfo").getMethod("getFpanLastFour")
34
+ internal fun isTokenInWallet(
35
+ token: Any,
36
+ newLastFour: String,
37
+ ): Boolean =
38
+ try {
39
+ val getFpanLastFourMethod =
40
+ Class
41
+ .forName("com.google.android.gms.tapandpay.issuer.TokenInfo")
42
+ .getMethod("getFpanLastFour")
39
43
  val existingFpanLastFour = getFpanLastFourMethod.invoke(token) as String
40
44
  existingFpanLastFour == newLastFour
41
45
  } catch (e: Exception) {
42
46
  Log.e(TAG, "There was a problem getting the FPAN with Google TapAndPay: " + e.message)
43
47
  false
44
48
  }
45
- }
46
49
 
47
-
48
- fun findExistingToken(activity: Activity, newCardLastFour: String, callback: TokenCheckHandler) {
50
+ fun findExistingToken(
51
+ activity: Activity,
52
+ newCardLastFour: String,
53
+ callback: TokenCheckHandler,
54
+ ) {
49
55
  val tokens = getTapandPayTokens(activity)
50
56
  if (tokens == null) {
51
57
  callback(false, null, createError("Failed", "Google TapAndPay dependency not found."))
@@ -56,7 +62,7 @@ object TapAndPayProxy {
56
62
  if (task.isSuccessful) {
57
63
  for (token in task.result) {
58
64
  if (isTokenInWallet(token, newCardLastFour)) {
59
- callback(true, mapFromTokenInfo(token), null)
65
+ callback(true, mapFromTokenInfo(token), null)
60
66
  return@addOnCompleteListener
61
67
  }
62
68
  }
@@ -67,17 +73,35 @@ object TapAndPayProxy {
67
73
  }
68
74
  }
69
75
 
70
- fun tokenize(activity: Activity, tokenReferenceId: String, token: ReadableMap, cardDescription: String) {
76
+ fun tokenize(
77
+ activity: Activity,
78
+ tokenReferenceId: String,
79
+ token: ReadableMap,
80
+ cardDescription: String,
81
+ ) {
71
82
  try {
72
83
  val tapAndPayClientClass = Class.forName("com.google.android.gms.tapandpay.TapAndPayClient")
73
- val tokenizeMethod = tapAndPayClientClass::class.java.getMethod("tokenize", Activity::class.java, String::class.java, Int::class.java, String::class.java, Int::class.java, Int::class.java)
74
- tokenizeMethod.invoke(tapAndPayClient,
75
- activity,
76
- tokenReferenceId,
77
- token.getInt("serviceProvider"),
78
- cardDescription,
79
- token.getInt("network"),
80
- REQUEST_CODE_TOKENIZE)
84
+ val tokenizeMethod =
85
+ tapAndPayClientClass::class
86
+ .java
87
+ .getMethod(
88
+ "tokenize",
89
+ Activity::class.java,
90
+ String::class.java,
91
+ Int::class.java,
92
+ String::class.java,
93
+ Int::class.java,
94
+ Int::class.java,
95
+ )
96
+ tokenizeMethod.invoke(
97
+ tapAndPayClient,
98
+ activity,
99
+ tokenReferenceId,
100
+ token.getInt("serviceProvider"),
101
+ cardDescription,
102
+ token.getInt("network"),
103
+ REQUEST_CODE_TOKENIZE,
104
+ )
81
105
  } catch (e: Exception) {
82
106
  Log.e(TAG, "There was a problem tokenizing with Google TapAndPay: " + e.message)
83
107
  }
@@ -88,33 +112,29 @@ object TapAndPayProxy {
88
112
  token?.let {
89
113
  try {
90
114
  val tokenInfoClass = Class.forName("com.google.android.gms.tapandpay.issuer.TokenInfo")
91
- result.putString(
92
- "id",
93
- tokenInfoClass.getMethod("getIssuerTokenId").invoke(it) as String)
115
+ result.putString("id", tokenInfoClass.getMethod("getIssuerTokenId").invoke(it) as String)
94
116
  val fpan = tokenInfoClass.getMethod("getFpanLastFour").invoke(it) as String
95
- result.putString(
96
- "cardLastFour",
97
- fpan)
98
- result.putString(
99
- "fpanLastFour",
100
- fpan)
117
+ result.putString("cardLastFour", fpan)
118
+ result.putString("fpanLastFour", fpan)
101
119
  result.putString(
102
120
  "dpanLastFour",
103
- tokenInfoClass.getMethod("getDpanLastFour").invoke(it) as String)
104
- result.putString(
105
- "issuer",
106
- tokenInfoClass.getMethod("getIssuerName").invoke(it) as String)
121
+ tokenInfoClass.getMethod("getDpanLastFour").invoke(it) as String,
122
+ )
123
+ result.putString("issuer", tokenInfoClass.getMethod("getIssuerName").invoke(it) as String)
107
124
  result.putString(
108
125
  "status",
109
- mapFromTokenState(tokenInfoClass.getMethod("getTokenState").invoke(it) as Int))
110
- result.putInt(
111
- "network",
112
- tokenInfoClass.getMethod("getNetwork").invoke(it) as Int)
126
+ mapFromTokenState(tokenInfoClass.getMethod("getTokenState").invoke(it) as Int),
127
+ )
128
+ result.putInt("network", tokenInfoClass.getMethod("getNetwork").invoke(it) as Int)
113
129
  result.putInt(
114
130
  "serviceProvider",
115
- tokenInfoClass.getMethod("getTokenServiceProvider").invoke(it) as Int)
131
+ tokenInfoClass.getMethod("getTokenServiceProvider").invoke(it) as Int,
132
+ )
116
133
  } catch (e: Exception) {
117
- Log.e(TAG, "There was a problem mapping the token information with Google TapAndPay: " + e.message)
134
+ Log.e(
135
+ TAG,
136
+ "There was a problem mapping the token information with Google TapAndPay: " + e.message,
137
+ )
118
138
  }
119
139
  }
120
140
  return result
@@ -124,12 +144,16 @@ object TapAndPayProxy {
124
144
  try {
125
145
  val tapAndPayClass = Class.forName("com.google.android.gms.tapandpay.TapAndPay")
126
146
  return when (status) {
127
- tapAndPayClass.getField("TOKEN_STATE_NEEDS_IDENTITY_VERIFICATION").get(tapAndPayClass) -> "TOKEN_STATE_NEEDS_IDENTITY_VERIFICATION"
147
+ tapAndPayClass.getField("TOKEN_STATE_NEEDS_IDENTITY_VERIFICATION").get(tapAndPayClass) ->
148
+ "TOKEN_STATE_NEEDS_IDENTITY_VERIFICATION"
128
149
  tapAndPayClass.getField("TOKEN_STATE_PENDING").get(tapAndPayClass) -> "TOKEN_STATE_PENDING"
129
- tapAndPayClass.getField("TOKEN_STATE_SUSPENDED").get(tapAndPayClass) -> "TOKEN_STATE_SUSPENDED"
150
+ tapAndPayClass.getField("TOKEN_STATE_SUSPENDED").get(tapAndPayClass) ->
151
+ "TOKEN_STATE_SUSPENDED"
130
152
  tapAndPayClass.getField("TOKEN_STATE_ACTIVE").get(tapAndPayClass) -> "TOKEN_STATE_ACTIVE"
131
- tapAndPayClass.getField("TOKEN_STATE_FELICA_PENDING_PROVISIONING").get(tapAndPayClass) -> "TOKEN_STATE_FELICA_PENDING_PROVISIONING"
132
- tapAndPayClass.getField("TOKEN_STATE_UNTOKENIZED").get(tapAndPayClass) -> "TOKEN_STATE_UNTOKENIZED"
153
+ tapAndPayClass.getField("TOKEN_STATE_FELICA_PENDING_PROVISIONING").get(tapAndPayClass) ->
154
+ "TOKEN_STATE_FELICA_PENDING_PROVISIONING"
155
+ tapAndPayClass.getField("TOKEN_STATE_UNTOKENIZED").get(tapAndPayClass) ->
156
+ "TOKEN_STATE_UNTOKENIZED"
133
157
  else -> "UNKNOWN"
134
158
  }
135
159
  } catch (e: Exception) {
@@ -10,42 +10,62 @@ import com.stripe.android.model.PaymentIntent
10
10
  import com.stripe.android.model.SetupIntent
11
11
 
12
12
  enum class ErrorType {
13
- Failed, Canceled, Unknown
13
+ Failed,
14
+ Canceled,
15
+ Unknown,
14
16
  }
15
17
 
16
18
  enum class ConfirmPaymentErrorType {
17
- Failed, Canceled, Unknown
19
+ Failed,
20
+ Canceled,
21
+ Unknown,
18
22
  }
19
23
 
20
24
  enum class CreateTokenErrorType {
21
- Failed
25
+ Failed,
22
26
  }
23
27
 
24
28
  enum class ConfirmSetupIntentErrorType {
25
- Failed, Canceled, Unknown
29
+ Failed,
30
+ Canceled,
31
+ Unknown,
26
32
  }
27
33
 
28
34
  enum class RetrievePaymentIntentErrorType {
29
- Unknown
35
+ Unknown,
30
36
  }
31
37
 
32
38
  enum class RetrieveSetupIntentErrorType {
33
- Unknown
39
+ Unknown,
34
40
  }
35
41
 
36
42
  enum class PaymentSheetErrorType {
37
- Failed, Canceled, Timeout
43
+ Failed,
44
+ Canceled,
45
+ Timeout,
38
46
  }
39
47
 
40
48
  enum class GooglePayErrorType {
41
- Failed, Canceled
42
- }
43
-
44
- class PaymentSheetAppearanceException(message: String) : Exception(message)
45
-
46
- class PaymentSheetException(message: String) : Exception(message)
47
-
48
- internal fun mapError(code: String, message: String?, localizedMessage: String?, declineCode: String?, type: String?, stripeErrorCode: String?): WritableMap {
49
+ Failed,
50
+ Canceled,
51
+ }
52
+
53
+ class PaymentSheetAppearanceException(
54
+ message: String,
55
+ ) : Exception(message)
56
+
57
+ class PaymentSheetException(
58
+ message: String,
59
+ ) : Exception(message)
60
+
61
+ internal fun mapError(
62
+ code: String,
63
+ message: String?,
64
+ localizedMessage: String?,
65
+ declineCode: String?,
66
+ type: String?,
67
+ stripeErrorCode: String?,
68
+ ): WritableMap {
49
69
  val map: WritableMap = WritableNativeMap()
50
70
  val details: WritableMap = WritableNativeMap()
51
71
  details.putString("code", code)
@@ -59,61 +79,107 @@ internal fun mapError(code: String, message: String?, localizedMessage: String?,
59
79
  return map
60
80
  }
61
81
 
62
- internal fun createError(code: String, message: String?): WritableMap {
63
- return mapError(code, message, message, null, null, null)
64
- }
82
+ internal fun createError(
83
+ code: String,
84
+ message: String?,
85
+ ): WritableMap = mapError(code, message, message, null, null, null)
65
86
 
66
- internal fun createMissingActivityError(): WritableMap {
67
- return mapError(
87
+ internal fun createMissingActivityError(): WritableMap =
88
+ mapError(
68
89
  "Failed",
69
90
  "Activity doesn't exist yet. You can safely retry this method.",
70
91
  null,
71
92
  null,
72
93
  null,
73
- null)
74
- }
75
-
76
- internal fun createError(code: String, error: PaymentIntent.Error?): WritableMap {
77
- return mapError(code, error?.message, error?.message, error?.declineCode, error?.type?.code, error?.code)
78
- }
79
-
80
- internal fun createError(code: String, error: SetupIntent.Error?): WritableMap {
81
- return mapError(code, error?.message, error?.message, error?.declineCode, error?.type?.code, error?.code)
82
- }
94
+ null,
95
+ )
83
96
 
84
- internal fun createError(code: String, error: Exception): WritableMap {
85
- return when (error) {
97
+ internal fun createError(
98
+ code: String,
99
+ error: PaymentIntent.Error?,
100
+ ): WritableMap =
101
+ mapError(
102
+ code,
103
+ error?.message,
104
+ error?.message,
105
+ error?.declineCode,
106
+ error?.type?.code,
107
+ error?.code,
108
+ )
109
+
110
+ internal fun createError(
111
+ code: String,
112
+ error: SetupIntent.Error?,
113
+ ): WritableMap =
114
+ mapError(
115
+ code,
116
+ error?.message,
117
+ error?.message,
118
+ error?.declineCode,
119
+ error?.type?.code,
120
+ error?.code,
121
+ )
122
+
123
+ internal fun createError(
124
+ code: String,
125
+ error: Exception,
126
+ ): WritableMap =
127
+ when (error) {
86
128
  is CardException -> {
87
- mapError(code, error.message, error.localizedMessage, error.declineCode, error.stripeError?.type, error.stripeError?.code)
129
+ mapError(
130
+ code,
131
+ error.message,
132
+ error.localizedMessage,
133
+ error.declineCode,
134
+ error.stripeError?.type,
135
+ error.stripeError?.code,
136
+ )
88
137
  }
89
138
  is InvalidRequestException -> {
90
- mapError(code, error.message, error.localizedMessage, error.stripeError?.declineCode, error.stripeError?.type, error.stripeError?.code)
139
+ mapError(
140
+ code,
141
+ error.message,
142
+ error.localizedMessage,
143
+ error.stripeError?.declineCode,
144
+ error.stripeError?.type,
145
+ error.stripeError?.code,
146
+ )
91
147
  }
92
148
  is AuthenticationException -> {
93
- mapError(code, error.message, error.localizedMessage, error.stripeError?.declineCode, error.stripeError?.type, error.stripeError?.code)
149
+ mapError(
150
+ code,
151
+ error.message,
152
+ error.localizedMessage,
153
+ error.stripeError?.declineCode,
154
+ error.stripeError?.type,
155
+ error.stripeError?.code,
156
+ )
94
157
  }
95
158
  is APIException -> {
96
- mapError(code, error.message, error.localizedMessage, error.stripeError?.declineCode, error.stripeError?.type, error.stripeError?.code)
159
+ mapError(
160
+ code,
161
+ error.message,
162
+ error.localizedMessage,
163
+ error.stripeError?.declineCode,
164
+ error.stripeError?.type,
165
+ error.stripeError?.code,
166
+ )
97
167
  }
98
168
  else -> mapError(code, error.message, error.localizedMessage.orEmpty(), null, null, null)
99
169
  }
100
- }
101
170
 
102
- internal fun createError(code: String, error: Throwable): WritableMap {
171
+ internal fun createError(
172
+ code: String,
173
+ error: Throwable,
174
+ ): WritableMap {
103
175
  (error as? Exception)?.let {
104
- return createError(
105
- code,
106
- it)
176
+ return createError(code, it)
107
177
  }
108
- return mapError(
109
- code,
110
- error.message,
111
- error.localizedMessage,
112
- null,
113
- null,
114
- null)
178
+ return mapError(code, error.message, error.localizedMessage, null, null, null)
115
179
  }
116
180
 
117
- internal fun createMissingInitError(): WritableMap {
118
- return createError(ErrorType.Failed.toString(), "Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.")
119
- }
181
+ internal fun createMissingInitError(): WritableMap =
182
+ createError(
183
+ ErrorType.Failed.toString(),
184
+ "Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
185
+ )
@@ -32,6 +32,7 @@ fun Fragment.removeFragment(context: ReactApplicationContext) {
32
32
  }
33
33
  }
34
34
 
35
- fun ReadableMap.getBooleanOr(key: String, default: Boolean): Boolean {
36
- return if (this.hasKey(key)) this.getBoolean(key) else default
37
- }
35
+ fun ReadableMap.getBooleanOr(
36
+ key: String,
37
+ default: Boolean,
38
+ ): Boolean = if (this.hasKey(key)) this.getBoolean(key) else default
@@ -0,0 +1,39 @@
1
+ package com.reactnativestripesdk.utils
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.facebook.react.bridge.ReactContext
5
+ import com.facebook.react.bridge.UiThreadUtil
6
+ import com.facebook.react.jstasks.HeadlessJsTaskConfig
7
+ import com.facebook.react.jstasks.HeadlessJsTaskContext
8
+
9
+ /**
10
+ * When Stripe UI is presented, React Native pauses timers. This will cause issues if we need
11
+ * to run JS while UI is presented. This starts a HeadlessJsTask to prevent React Native from
12
+ * pausing timers.
13
+ */
14
+ internal class KeepJsAwakeTask(
15
+ private val context: ReactContext,
16
+ ) {
17
+ private var taskId: Int? = null
18
+
19
+ fun start() {
20
+ val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(context)
21
+ UiThreadUtil.runOnUiThread {
22
+ val taskConfig =
23
+ HeadlessJsTaskConfig(
24
+ "StripeKeepJsAwakeTask",
25
+ Arguments.createMap(),
26
+ 0,
27
+ true,
28
+ )
29
+ taskId = headlessJsTaskContext.startTask(taskConfig)
30
+ }
31
+ }
32
+
33
+ fun stop() {
34
+ val taskId = taskId ?: return
35
+ val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(context)
36
+ headlessJsTaskContext.finishTask(taskId)
37
+ this.taskId = null
38
+ }
39
+ }