@stripe/stripe-react-native 0.42.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 (308) hide show
  1. package/.husky/pre-commit +0 -3
  2. package/CHANGELOG.md +14 -0
  3. package/android/.gradle/8.11.1/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.11.1/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/8.11.1/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/8.11.1/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  10. package/android/.project +0 -11
  11. package/android/.settings/org.eclipse.buildship.core.prefs +3 -3
  12. package/android/build.gradle +7 -1
  13. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  14. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  15. package/android/gradle.properties +4 -1
  16. package/android/gradlew +249 -0
  17. package/android/gradlew.bat +92 -0
  18. package/android/spotless.gradle +19 -0
  19. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +30 -34
  20. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +20 -10
  21. package/android/src/main/java/com/reactnativestripesdk/CardChangedEvent.kt +12 -13
  22. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +242 -105
  23. package/android/src/main/java/com/reactnativestripesdk/CardFieldViewManager.kt +58 -20
  24. package/android/src/main/java/com/reactnativestripesdk/CardFocusEvent.kt +8 -11
  25. package/android/src/main/java/com/reactnativestripesdk/CardFormCompleteEvent.kt +10 -12
  26. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +135 -87
  27. package/android/src/main/java/com/reactnativestripesdk/CardFormViewManager.kt +57 -22
  28. package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +33 -24
  29. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +107 -85
  30. package/android/src/main/java/com/reactnativestripesdk/FormCompleteEvent.kt +9 -11
  31. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +16 -9
  32. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +36 -28
  33. package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +67 -43
  34. package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +21 -16
  35. package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +101 -56
  36. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +244 -166
  37. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +137 -156
  38. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +181 -57
  39. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +402 -258
  40. package/android/src/main/java/com/reactnativestripesdk/StripeContainerManager.kt +11 -4
  41. package/android/src/main/java/com/reactnativestripesdk/StripeContainerView.kt +5 -1
  42. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +654 -299
  43. package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +12 -14
  44. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +42 -37
  45. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +12 -11
  46. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +29 -29
  47. package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +50 -18
  48. package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetFragment.kt +227 -147
  49. package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +15 -18
  50. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +33 -15
  51. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +63 -37
  52. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletCompleteEvent.kt +9 -13
  53. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/EphemeralKeyProvider.kt +15 -17
  54. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +76 -60
  55. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +71 -47
  56. package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +117 -51
  57. package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +4 -3
  58. package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +39 -0
  59. package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +295 -258
  60. package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -11
  61. package/ios/CustomerSheet/CustomerSheetUtils.swift +3 -1
  62. package/ios/FinancialConnections.swift +6 -2
  63. package/ios/StripeSdk+CustomerSheet.swift +2 -1
  64. package/ios/StripeSdk+PaymentSheet.swift +42 -0
  65. package/ios/StripeSdk.m +2 -0
  66. package/ios/StripeSdk.swift +72 -11
  67. package/lib/commonjs/NativeStripeSdk.js +1 -1
  68. package/lib/commonjs/NativeStripeSdk.js.map +1 -1
  69. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  70. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  71. package/lib/commonjs/components/AddressSheet.js +1 -1
  72. package/lib/commonjs/components/AddressSheet.js.map +1 -1
  73. package/lib/commonjs/components/ApplePayButtonNative.js +1 -1
  74. package/lib/commonjs/components/ApplePayButtonNative.js.map +1 -1
  75. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  76. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  77. package/lib/commonjs/components/CardField.js +1 -1
  78. package/lib/commonjs/components/CardField.js.map +1 -1
  79. package/lib/commonjs/components/CardForm.js +1 -1
  80. package/lib/commonjs/components/CardForm.js.map +1 -1
  81. package/lib/commonjs/components/CustomerSheet.js +1 -1
  82. package/lib/commonjs/components/CustomerSheet.js.map +1 -1
  83. package/lib/commonjs/components/GooglePayButtonNative.js +1 -1
  84. package/lib/commonjs/components/GooglePayButtonNative.js.map +1 -1
  85. package/lib/commonjs/components/PlatformPayButton.js +1 -1
  86. package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
  87. package/lib/commonjs/components/StripeContainer.js +1 -1
  88. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  89. package/lib/commonjs/components/StripeProvider.js +1 -1
  90. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  91. package/lib/commonjs/functions.js +1 -1
  92. package/lib/commonjs/functions.js.map +1 -1
  93. package/lib/commonjs/helpers.js +1 -1
  94. package/lib/commonjs/helpers.js.map +1 -1
  95. package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
  96. package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
  97. package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -1
  98. package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
  99. package/lib/commonjs/hooks/usePlatformPay.js.map +1 -1
  100. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  101. package/lib/commonjs/index.js.map +1 -1
  102. package/lib/commonjs/package.json +1 -0
  103. package/lib/commonjs/plugin/withStripe.js +1 -1
  104. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  105. package/lib/commonjs/types/ApplePay.js.map +1 -1
  106. package/lib/commonjs/types/Common.js +1 -1
  107. package/lib/commonjs/types/Common.js.map +1 -1
  108. package/lib/commonjs/types/CustomerSheet.js.map +1 -1
  109. package/lib/commonjs/types/Errors.js +1 -1
  110. package/lib/commonjs/types/Errors.js.map +1 -1
  111. package/lib/commonjs/types/FinancialConnections.js +1 -1
  112. package/lib/commonjs/types/FinancialConnections.js.map +1 -1
  113. package/lib/commonjs/types/NextAction.js.map +1 -1
  114. package/lib/commonjs/types/PaymentIntent.js +1 -1
  115. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  116. package/lib/commonjs/types/PaymentMethod.js.map +1 -1
  117. package/lib/commonjs/types/PaymentSheet.js +1 -1
  118. package/lib/commonjs/types/PaymentSheet.js.map +1 -1
  119. package/lib/commonjs/types/PlatformPay.js +1 -1
  120. package/lib/commonjs/types/PlatformPay.js.map +1 -1
  121. package/lib/commonjs/types/PushProvisioning.js +1 -1
  122. package/lib/commonjs/types/PushProvisioning.js.map +1 -1
  123. package/lib/commonjs/types/SetupIntent.js +1 -1
  124. package/lib/commonjs/types/SetupIntent.js.map +1 -1
  125. package/lib/commonjs/types/ThreeDSecure.js +1 -1
  126. package/lib/commonjs/types/ThreeDSecure.js.map +1 -1
  127. package/lib/commonjs/types/Token.js.map +1 -1
  128. package/lib/commonjs/types/components/ApplePayButtonComponent.js.map +1 -1
  129. package/lib/commonjs/types/components/AuBECSDebitFormComponent.js.map +1 -1
  130. package/lib/commonjs/types/components/CardFieldInput.js +1 -1
  131. package/lib/commonjs/types/components/CardFieldInput.js.map +1 -1
  132. package/lib/commonjs/types/components/CardFormView.js.map +1 -1
  133. package/lib/commonjs/types/components/GooglePayButtonComponent.js.map +1 -1
  134. package/lib/commonjs/types/index.js +1 -1
  135. package/lib/commonjs/types/index.js.map +1 -1
  136. package/lib/module/NativeStripeSdk.js +1 -1
  137. package/lib/module/NativeStripeSdk.js.map +1 -1
  138. package/lib/module/components/AddToWalletButton.js +1 -1
  139. package/lib/module/components/AddToWalletButton.js.map +1 -1
  140. package/lib/module/components/AddressSheet.js +1 -1
  141. package/lib/module/components/AddressSheet.js.map +1 -1
  142. package/lib/module/components/ApplePayButtonNative.js +1 -1
  143. package/lib/module/components/ApplePayButtonNative.js.map +1 -1
  144. package/lib/module/components/AuBECSDebitForm.js +1 -1
  145. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  146. package/lib/module/components/CardField.js +1 -1
  147. package/lib/module/components/CardField.js.map +1 -1
  148. package/lib/module/components/CardForm.js +1 -1
  149. package/lib/module/components/CardForm.js.map +1 -1
  150. package/lib/module/components/CustomerSheet.js +1 -1
  151. package/lib/module/components/CustomerSheet.js.map +1 -1
  152. package/lib/module/components/GooglePayButtonNative.js +1 -1
  153. package/lib/module/components/GooglePayButtonNative.js.map +1 -1
  154. package/lib/module/components/PlatformPayButton.js +1 -1
  155. package/lib/module/components/PlatformPayButton.js.map +1 -1
  156. package/lib/module/components/StripeContainer.js +1 -1
  157. package/lib/module/components/StripeContainer.js.map +1 -1
  158. package/lib/module/components/StripeProvider.js +1 -1
  159. package/lib/module/components/StripeProvider.js.map +1 -1
  160. package/lib/module/functions.js +1 -1
  161. package/lib/module/functions.js.map +1 -1
  162. package/lib/module/helpers.js +1 -1
  163. package/lib/module/helpers.js.map +1 -1
  164. package/lib/module/hooks/useConfirmPayment.js.map +1 -1
  165. package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
  166. package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -1
  167. package/lib/module/hooks/usePaymentSheet.js.map +1 -1
  168. package/lib/module/hooks/usePlatformPay.js.map +1 -1
  169. package/lib/module/hooks/useStripe.js.map +1 -1
  170. package/lib/module/index.js.map +1 -1
  171. package/lib/module/package.json +1 -0
  172. package/lib/module/plugin/withStripe.js +1 -1
  173. package/lib/module/plugin/withStripe.js.map +1 -1
  174. package/lib/module/types/ApplePay.js.map +1 -1
  175. package/lib/module/types/Common.js +1 -1
  176. package/lib/module/types/Common.js.map +1 -1
  177. package/lib/module/types/CustomerSheet.js.map +1 -1
  178. package/lib/module/types/Errors.js +1 -1
  179. package/lib/module/types/Errors.js.map +1 -1
  180. package/lib/module/types/FinancialConnections.js +1 -1
  181. package/lib/module/types/FinancialConnections.js.map +1 -1
  182. package/lib/module/types/NextAction.js.map +1 -1
  183. package/lib/module/types/PaymentIntent.js +1 -1
  184. package/lib/module/types/PaymentIntent.js.map +1 -1
  185. package/lib/module/types/PaymentMethod.js.map +1 -1
  186. package/lib/module/types/PaymentSheet.js +1 -1
  187. package/lib/module/types/PaymentSheet.js.map +1 -1
  188. package/lib/module/types/PlatformPay.js +1 -1
  189. package/lib/module/types/PlatformPay.js.map +1 -1
  190. package/lib/module/types/PushProvisioning.js +1 -1
  191. package/lib/module/types/PushProvisioning.js.map +1 -1
  192. package/lib/module/types/SetupIntent.js +1 -1
  193. package/lib/module/types/SetupIntent.js.map +1 -1
  194. package/lib/module/types/ThreeDSecure.js +1 -1
  195. package/lib/module/types/ThreeDSecure.js.map +1 -1
  196. package/lib/module/types/Token.js.map +1 -1
  197. package/lib/module/types/components/ApplePayButtonComponent.js.map +1 -1
  198. package/lib/module/types/components/AuBECSDebitFormComponent.js.map +1 -1
  199. package/lib/module/types/components/CardFieldInput.js +1 -1
  200. package/lib/module/types/components/CardFieldInput.js.map +1 -1
  201. package/lib/module/types/components/CardFormView.js.map +1 -1
  202. package/lib/module/types/components/GooglePayButtonComponent.js.map +1 -1
  203. package/lib/module/types/index.js +1 -1
  204. package/lib/module/types/index.js.map +1 -1
  205. package/lib/typescript/src/NativeStripeSdk.d.ts +4 -3
  206. package/lib/typescript/src/NativeStripeSdk.d.ts.map +1 -0
  207. package/lib/typescript/src/components/AddToWalletButton.d.ts +3 -1
  208. package/lib/typescript/src/components/AddToWalletButton.d.ts.map +1 -0
  209. package/lib/typescript/src/components/AddressSheet.d.ts +4 -2
  210. package/lib/typescript/src/components/AddressSheet.d.ts.map +1 -0
  211. package/lib/typescript/src/components/ApplePayButtonNative.d.ts +1 -0
  212. package/lib/typescript/src/components/ApplePayButtonNative.d.ts.map +1 -0
  213. package/lib/typescript/src/components/AuBECSDebitForm.d.ts +3 -1
  214. package/lib/typescript/src/components/AuBECSDebitForm.d.ts.map +1 -0
  215. package/lib/typescript/src/components/CardField.d.ts +1 -0
  216. package/lib/typescript/src/components/CardField.d.ts.map +1 -0
  217. package/lib/typescript/src/components/CardForm.d.ts +1 -0
  218. package/lib/typescript/src/components/CardForm.d.ts.map +1 -0
  219. package/lib/typescript/src/components/CustomerSheet.d.ts +2 -1
  220. package/lib/typescript/src/components/CustomerSheet.d.ts.map +1 -0
  221. package/lib/typescript/src/components/GooglePayButtonNative.d.ts +1 -0
  222. package/lib/typescript/src/components/GooglePayButtonNative.d.ts.map +1 -0
  223. package/lib/typescript/src/components/PlatformPayButton.d.ts +3 -1
  224. package/lib/typescript/src/components/PlatformPayButton.d.ts.map +1 -0
  225. package/lib/typescript/src/components/StripeContainer.d.ts +2 -1
  226. package/lib/typescript/src/components/StripeContainer.d.ts.map +1 -0
  227. package/lib/typescript/src/components/StripeProvider.d.ts +3 -2
  228. package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -0
  229. package/lib/typescript/src/functions.d.ts +6 -5
  230. package/lib/typescript/src/functions.d.ts.map +1 -0
  231. package/lib/typescript/src/helpers.d.ts +1 -0
  232. package/lib/typescript/src/helpers.d.ts.map +1 -0
  233. package/lib/typescript/src/hooks/useConfirmPayment.d.ts +2 -1
  234. package/lib/typescript/src/hooks/useConfirmPayment.d.ts.map +1 -0
  235. package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts +1 -0
  236. package/lib/typescript/src/hooks/useConfirmSetupIntent.d.ts.map +1 -0
  237. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +3 -2
  238. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts.map +1 -0
  239. package/lib/typescript/src/hooks/usePaymentSheet.d.ts +2 -1
  240. package/lib/typescript/src/hooks/usePaymentSheet.d.ts.map +1 -0
  241. package/lib/typescript/src/hooks/usePlatformPay.d.ts +4 -3
  242. package/lib/typescript/src/hooks/usePlatformPay.d.ts.map +1 -0
  243. package/lib/typescript/src/hooks/useStripe.d.ts +11 -8
  244. package/lib/typescript/src/hooks/useStripe.d.ts.map +1 -0
  245. package/lib/typescript/src/index.d.ts +1 -0
  246. package/lib/typescript/src/index.d.ts.map +1 -0
  247. package/lib/typescript/src/plugin/withStripe.d.ts +2 -1
  248. package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -0
  249. package/lib/typescript/src/types/ApplePay.d.ts +6 -5
  250. package/lib/typescript/src/types/ApplePay.d.ts.map +1 -0
  251. package/lib/typescript/src/types/Common.d.ts +4 -1
  252. package/lib/typescript/src/types/Common.d.ts.map +1 -0
  253. package/lib/typescript/src/types/CustomerSheet.d.ts +12 -4
  254. package/lib/typescript/src/types/CustomerSheet.d.ts.map +1 -0
  255. package/lib/typescript/src/types/Errors.d.ts +2 -1
  256. package/lib/typescript/src/types/Errors.d.ts.map +1 -0
  257. package/lib/typescript/src/types/FinancialConnections.d.ts +21 -17
  258. package/lib/typescript/src/types/FinancialConnections.d.ts.map +1 -0
  259. package/lib/typescript/src/types/NextAction.d.ts +9 -8
  260. package/lib/typescript/src/types/NextAction.d.ts.map +1 -0
  261. package/lib/typescript/src/types/PaymentIntent.d.ts +16 -15
  262. package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -0
  263. package/lib/typescript/src/types/PaymentMethod.d.ts +21 -16
  264. package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -0
  265. package/lib/typescript/src/types/PaymentSheet.d.ts +72 -22
  266. package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -0
  267. package/lib/typescript/src/types/PlatformPay.d.ts +22 -21
  268. package/lib/typescript/src/types/PlatformPay.d.ts.map +1 -0
  269. package/lib/typescript/src/types/PushProvisioning.d.ts +5 -4
  270. package/lib/typescript/src/types/PushProvisioning.d.ts.map +1 -0
  271. package/lib/typescript/src/types/SetupIntent.d.ts +4 -3
  272. package/lib/typescript/src/types/SetupIntent.d.ts.map +1 -0
  273. package/lib/typescript/src/types/ThreeDSecure.d.ts +1 -0
  274. package/lib/typescript/src/types/ThreeDSecure.d.ts.map +1 -0
  275. package/lib/typescript/src/types/Token.d.ts +10 -9
  276. package/lib/typescript/src/types/Token.d.ts.map +1 -0
  277. package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts +3 -2
  278. package/lib/typescript/src/types/components/ApplePayButtonComponent.d.ts.map +1 -0
  279. package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts +1 -0
  280. package/lib/typescript/src/types/components/AuBECSDebitFormComponent.d.ts.map +1 -0
  281. package/lib/typescript/src/types/components/CardFieldInput.d.ts +8 -5
  282. package/lib/typescript/src/types/components/CardFieldInput.d.ts.map +1 -0
  283. package/lib/typescript/src/types/components/CardFormView.d.ts +9 -6
  284. package/lib/typescript/src/types/components/CardFormView.d.ts.map +1 -0
  285. package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts +1 -0
  286. package/lib/typescript/src/types/components/GooglePayButtonComponent.d.ts.map +1 -0
  287. package/lib/typescript/src/types/index.d.ts +24 -23
  288. package/lib/typescript/src/types/index.d.ts.map +1 -0
  289. package/package.json +32 -40
  290. package/src/NativeStripeSdk.tsx +4 -2
  291. package/src/components/CardField.tsx +1 -1
  292. package/src/components/CardForm.tsx +12 -9
  293. package/src/components/CustomerSheet.tsx +4 -6
  294. package/src/components/StripeProvider.tsx +17 -0
  295. package/src/functions.ts +13 -14
  296. package/src/types/Common.ts +3 -0
  297. package/src/types/CustomerSheet.ts +7 -0
  298. package/src/types/FinancialConnections.ts +3 -0
  299. package/src/types/PaymentMethod.ts +5 -1
  300. package/src/types/PaymentSheet.ts +64 -4
  301. package/src/types/components/CardFieldInput.ts +8 -4
  302. package/src/types/components/CardFormView.ts +8 -4
  303. package/stripe-react-native.podspec +2 -1
  304. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  305. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  306. package/android/.gradle/8.9/gc.properties +0 -0
  307. /package/android/.gradle/{8.9 → 8.11.1}/fileChanges/last-build.bin +0 -0
  308. /package/android/.gradle/{8.9/dependencies-accessors → 8.11.1}/gc.properties +0 -0
@@ -7,20 +7,32 @@ import android.view.ViewGroup
7
7
  import android.widget.FrameLayout
8
8
  import androidx.fragment.app.Fragment
9
9
  import androidx.fragment.app.FragmentActivity
10
- import com.facebook.react.bridge.*
11
- import com.reactnativestripesdk.utils.*
10
+ import com.facebook.react.bridge.Arguments
11
+ import com.facebook.react.bridge.Promise
12
+ import com.facebook.react.bridge.ReactApplicationContext
13
+ import com.facebook.react.bridge.ReadableArray
14
+ import com.facebook.react.bridge.WritableArray
15
+ import com.facebook.react.bridge.WritableMap
16
+ import com.facebook.react.bridge.WritableNativeMap
17
+ import com.reactnativestripesdk.utils.ErrorType
12
18
  import com.reactnativestripesdk.utils.createError
13
19
  import com.reactnativestripesdk.utils.createMissingActivityError
20
+ import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
14
21
  import com.reactnativestripesdk.utils.mapFromToken
15
22
  import com.stripe.android.financialconnections.FinancialConnections
16
23
  import com.stripe.android.financialconnections.FinancialConnectionsSheet
17
24
  import com.stripe.android.financialconnections.FinancialConnectionsSheetForTokenResult
18
25
  import com.stripe.android.financialconnections.FinancialConnectionsSheetResult
19
- import com.stripe.android.financialconnections.model.*
26
+ import com.stripe.android.financialconnections.model.Balance
27
+ import com.stripe.android.financialconnections.model.BalanceRefresh
28
+ import com.stripe.android.financialconnections.model.FinancialConnectionsAccount
29
+ import com.stripe.android.financialconnections.model.FinancialConnectionsAccountList
30
+ import com.stripe.android.financialconnections.model.FinancialConnectionsSession
20
31
 
21
32
  class FinancialConnectionsSheetFragment : Fragment() {
22
33
  enum class Mode {
23
- ForToken, ForSession
34
+ ForToken,
35
+ ForSession,
24
36
  }
25
37
 
26
38
  private lateinit var promise: Promise
@@ -40,30 +52,28 @@ class FinancialConnectionsSheetFragment : Fragment() {
40
52
  }
41
53
  }
42
54
 
43
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
44
- savedInstanceState: Bundle?): View {
45
- return FrameLayout(requireActivity()).also {
46
- it.visibility = View.GONE
47
- }
48
- }
55
+ override fun onCreateView(
56
+ inflater: LayoutInflater,
57
+ container: ViewGroup?,
58
+ savedInstanceState: Bundle?,
59
+ ): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
49
60
 
50
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
61
+ override fun onViewCreated(
62
+ view: View,
63
+ savedInstanceState: Bundle?,
64
+ ) {
51
65
  when (mode) {
52
66
  Mode.ForToken -> {
53
- FinancialConnectionsSheet.createForBankAccountToken(
54
- this,
55
- ::onFinancialConnectionsSheetForTokenResult
56
- ).present(
57
- configuration = configuration
58
- )
67
+ FinancialConnectionsSheet
68
+ .createForBankAccountToken(
69
+ this,
70
+ ::onFinancialConnectionsSheetForTokenResult,
71
+ ).present(configuration = configuration)
59
72
  }
60
73
  Mode.ForSession -> {
61
- FinancialConnectionsSheet.create(
62
- this,
63
- ::onFinancialConnectionsSheetForDataResult
64
- ).present(
65
- configuration = configuration
66
- )
74
+ FinancialConnectionsSheet
75
+ .create(this, ::onFinancialConnectionsSheetForDataResult)
76
+ .present(configuration = configuration)
67
77
  }
68
78
  }
69
79
  }
@@ -76,75 +86,86 @@ class FinancialConnectionsSheetFragment : Fragment() {
76
86
  }
77
87
 
78
88
  private fun onFinancialConnectionsSheetForTokenResult(result: FinancialConnectionsSheetForTokenResult) {
79
- when(result) {
89
+ when (result) {
80
90
  is FinancialConnectionsSheetForTokenResult.Canceled -> {
81
- promise.resolve(
82
- createError(ErrorType.Canceled.toString(), "The flow has been canceled")
83
- )
91
+ promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
84
92
  }
85
93
  is FinancialConnectionsSheetForTokenResult.Failed -> {
86
- promise.resolve(
87
- createError(ErrorType.Failed.toString(), result.error)
88
- )
94
+ promise.resolve(createError(ErrorType.Failed.toString(), result.error))
89
95
  }
90
96
  is FinancialConnectionsSheetForTokenResult.Completed -> {
91
97
  promise.resolve(createTokenResult(result))
92
- (context.currentActivity as? FragmentActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
98
+ (context.currentActivity as? FragmentActivity)
99
+ ?.supportFragmentManager
100
+ ?.beginTransaction()
101
+ ?.remove(this)
102
+ ?.commitAllowingStateLoss()
93
103
  }
94
104
  }
95
105
  }
96
106
 
97
107
  private fun onFinancialConnectionsSheetForDataResult(result: FinancialConnectionsSheetResult) {
98
- when(result) {
108
+ when (result) {
99
109
  is FinancialConnectionsSheetResult.Canceled -> {
100
- promise.resolve(
101
- createError(ErrorType.Canceled.toString(), "The flow has been canceled")
102
- )
110
+ promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
103
111
  }
104
112
  is FinancialConnectionsSheetResult.Failed -> {
105
- promise.resolve(
106
- createError(ErrorType.Failed.toString(), result.error)
107
- )
113
+ promise.resolve(createError(ErrorType.Failed.toString(), result.error))
108
114
  }
109
115
  is FinancialConnectionsSheetResult.Completed -> {
110
116
  promise.resolve(
111
- WritableNativeMap().also {
112
- it.putMap("session", mapFromSession(result.financialConnectionsSession))
113
- }
117
+ WritableNativeMap().also {
118
+ it.putMap("session", mapFromSession(result.financialConnectionsSession))
119
+ },
114
120
  )
115
- (context.currentActivity as? FragmentActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
121
+ (context.currentActivity as? FragmentActivity)
122
+ ?.supportFragmentManager
123
+ ?.beginTransaction()
124
+ ?.remove(this)
125
+ ?.commitAllowingStateLoss()
116
126
  }
117
127
  }
118
128
  }
119
129
 
120
- fun presentFinancialConnectionsSheet(clientSecret: String, mode: Mode, publishableKey: String, stripeAccountId: String?, promise: Promise, context: ReactApplicationContext) {
130
+ fun presentFinancialConnectionsSheet(
131
+ clientSecret: String,
132
+ mode: Mode,
133
+ publishableKey: String,
134
+ stripeAccountId: String?,
135
+ promise: Promise,
136
+ context: ReactApplicationContext,
137
+ ) {
121
138
  this.promise = promise
122
139
  this.context = context
123
140
  this.mode = mode
124
- this.configuration = FinancialConnectionsSheet.Configuration(
125
- financialConnectionsSessionClientSecret = clientSecret,
126
- publishableKey = publishableKey,
127
- stripeAccountId = stripeAccountId,
128
- )
141
+ this.configuration =
142
+ FinancialConnectionsSheet.Configuration(
143
+ financialConnectionsSessionClientSecret = clientSecret,
144
+ publishableKey = publishableKey,
145
+ stripeAccountId = stripeAccountId,
146
+ )
129
147
 
130
148
  (context.currentActivity as? FragmentActivity)?.let {
131
149
  attemptToCleanupPreviousFragment(it)
132
150
  commitFragmentAndStartFlow(it)
133
- } ?: run {
134
- promise.resolve(createMissingActivityError())
135
- return
136
151
  }
152
+ ?: run {
153
+ promise.resolve(createMissingActivityError())
154
+ return
155
+ }
137
156
  }
138
157
 
139
158
  private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
140
- currentActivity.supportFragmentManager.beginTransaction()
159
+ currentActivity.supportFragmentManager
160
+ .beginTransaction()
141
161
  .remove(this)
142
162
  .commitAllowingStateLoss()
143
163
  }
144
164
 
145
165
  private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
146
166
  try {
147
- currentActivity.supportFragmentManager.beginTransaction()
167
+ currentActivity.supportFragmentManager
168
+ .beginTransaction()
148
169
  .add(this, TAG)
149
170
  .commit()
150
171
  } catch (error: IllegalStateException) {
@@ -155,12 +176,11 @@ class FinancialConnectionsSheetFragment : Fragment() {
155
176
  companion object {
156
177
  internal const val TAG = "financial_connections_sheet_launch_fragment"
157
178
 
158
- private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap {
159
- return WritableNativeMap().also {
179
+ private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap =
180
+ WritableNativeMap().also {
160
181
  it.putMap("session", mapFromSession(result.financialConnectionsSession))
161
182
  it.putMap("token", mapFromToken(result.token))
162
183
  }
163
- }
164
184
 
165
185
  private fun mapFromSession(financialConnectionsSession: FinancialConnectionsSession): WritableMap {
166
186
  val session = WritableNativeMap()
@@ -186,8 +206,19 @@ class FinancialConnectionsSheetFragment : Fragment() {
186
206
  map.putMap("balanceRefresh", mapFromAccountBalanceRefresh(account.balanceRefresh))
187
207
  map.putString("category", mapFromCategory(account.category))
188
208
  map.putString("subcategory", mapFromSubcategory(account.subcategory))
189
- map.putArray("permissions", (account.permissions?.map { permission -> mapFromPermission(permission) })?.toReadableArray())
190
- map.putArray("supportedPaymentMethodTypes", (account.supportedPaymentMethodTypes.map { type -> mapFromSupportedPaymentMethodTypes(type) }).toReadableArray())
209
+ map.putArray(
210
+ "permissions",
211
+ (account.permissions?.map { permission -> mapFromPermission(permission) })
212
+ ?.toReadableArray(),
213
+ )
214
+ map.putArray(
215
+ "supportedPaymentMethodTypes",
216
+ (
217
+ account.supportedPaymentMethodTypes.map { type ->
218
+ mapFromSupportedPaymentMethodTypes(type)
219
+ }
220
+ ).toReadableArray(),
221
+ )
191
222
  results.pushMap(map)
192
223
  }
193
224
  return results
@@ -212,8 +243,8 @@ class FinancialConnectionsSheetFragment : Fragment() {
212
243
  return map
213
244
  }
214
245
 
215
- private fun mapFromCashAvailable(balance: Balance): WritableNativeMap {
216
- return WritableNativeMap().also { cashMap ->
246
+ private fun mapFromCashAvailable(balance: Balance): WritableNativeMap =
247
+ WritableNativeMap().also { cashMap ->
217
248
  WritableNativeMap().also { availableMap ->
218
249
  balance.cash?.available?.entries?.let { entries ->
219
250
  for (entry in entries) {
@@ -223,10 +254,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
223
254
  cashMap.putMap("available", availableMap)
224
255
  }
225
256
  }
226
- }
227
257
 
228
- private fun mapFromCreditUsed(balance: Balance): WritableNativeMap {
229
- return WritableNativeMap().also { creditMap ->
258
+ private fun mapFromCreditUsed(balance: Balance): WritableNativeMap =
259
+ WritableNativeMap().also { creditMap ->
230
260
  WritableNativeMap().also { usedMap ->
231
261
  balance.credit?.used?.entries?.let { entries ->
232
262
  for (entry in entries) {
@@ -236,7 +266,6 @@ class FinancialConnectionsSheetFragment : Fragment() {
236
266
  creditMap.putMap("used", usedMap)
237
267
  }
238
268
  }
239
- }
240
269
 
241
270
  private fun mapFromAccountBalanceRefresh(balanceRefresh: BalanceRefresh?): WritableMap? {
242
271
  if (balanceRefresh == null) {
@@ -248,27 +277,25 @@ class FinancialConnectionsSheetFragment : Fragment() {
248
277
  return map
249
278
  }
250
279
 
251
- private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String {
252
- return when (status) {
280
+ private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String =
281
+ when (status) {
253
282
  FinancialConnectionsAccount.Status.ACTIVE -> "active"
254
283
  FinancialConnectionsAccount.Status.DISCONNECTED -> "disconnected"
255
284
  FinancialConnectionsAccount.Status.INACTIVE -> "inactive"
256
285
  FinancialConnectionsAccount.Status.UNKNOWN -> "unparsable"
257
286
  }
258
- }
259
287
 
260
- private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String {
261
- return when (category) {
288
+ private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String =
289
+ when (category) {
262
290
  FinancialConnectionsAccount.Category.CASH -> "cash"
263
291
  FinancialConnectionsAccount.Category.CREDIT -> "credit"
264
292
  FinancialConnectionsAccount.Category.INVESTMENT -> "investment"
265
293
  FinancialConnectionsAccount.Category.OTHER -> "other"
266
294
  FinancialConnectionsAccount.Category.UNKNOWN -> "unparsable"
267
295
  }
268
- }
269
296
 
270
- private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String {
271
- return when (subcategory) {
297
+ private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String =
298
+ when (subcategory) {
272
299
  FinancialConnectionsAccount.Subcategory.CHECKING -> "checking"
273
300
  FinancialConnectionsAccount.Subcategory.CREDIT_CARD -> "creditCard"
274
301
  FinancialConnectionsAccount.Subcategory.LINE_OF_CREDIT -> "lineOfCredit"
@@ -277,10 +304,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
277
304
  FinancialConnectionsAccount.Subcategory.SAVINGS -> "savings"
278
305
  FinancialConnectionsAccount.Subcategory.UNKNOWN -> "unparsable"
279
306
  }
280
- }
281
307
 
282
- private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String {
283
- return when (permission) {
308
+ private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String =
309
+ when (permission) {
284
310
  FinancialConnectionsAccount.Permissions.PAYMENT_METHOD -> "paymentMethod"
285
311
  FinancialConnectionsAccount.Permissions.BALANCES -> "balances"
286
312
  FinancialConnectionsAccount.Permissions.OWNERSHIP -> "ownership"
@@ -289,33 +315,29 @@ class FinancialConnectionsSheetFragment : Fragment() {
289
315
  FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
290
316
  FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
291
317
  }
292
- }
293
318
 
294
- private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String {
295
- return when (type) {
319
+ private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String =
320
+ when (type) {
296
321
  FinancialConnectionsAccount.SupportedPaymentMethodTypes.US_BANK_ACCOUNT -> "usBankAccount"
297
322
  FinancialConnectionsAccount.SupportedPaymentMethodTypes.LINK -> "link"
298
323
  FinancialConnectionsAccount.SupportedPaymentMethodTypes.UNKNOWN -> "unparsable"
299
324
  }
300
- }
301
325
 
302
- private fun mapFromBalanceType(type: Balance.Type): String {
303
- return when (type) {
326
+ private fun mapFromBalanceType(type: Balance.Type): String =
327
+ when (type) {
304
328
  Balance.Type.CASH -> "cash"
305
329
  Balance.Type.CREDIT -> "credit"
306
330
  Balance.Type.UNKNOWN -> "unparsable"
307
331
  }
308
- }
309
332
 
310
- private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String {
311
- return when (status) {
333
+ private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String =
334
+ when (status) {
312
335
  BalanceRefresh.BalanceRefreshStatus.SUCCEEDED -> "succeeded"
313
336
  BalanceRefresh.BalanceRefreshStatus.FAILED -> "failed"
314
337
  BalanceRefresh.BalanceRefreshStatus.PENDING -> "pending"
315
338
  BalanceRefresh.BalanceRefreshStatus.UNKNOWN -> "unparsable"
316
339
  null -> "null"
317
340
  }
318
- }
319
341
  }
320
342
  }
321
343
 
@@ -1,19 +1,17 @@
1
1
  package com.reactnativestripesdk
2
+
2
3
  import com.facebook.react.bridge.Arguments
3
4
  import com.facebook.react.bridge.WritableMap
4
5
  import com.facebook.react.uimanager.events.Event
5
- import com.facebook.react.uimanager.events.RCTEventEmitter
6
-
7
- internal class FormCompleteEvent constructor(viewTag: Int, private val formDetails: MutableMap<String, Any>) : Event<FormCompleteEvent>(viewTag) {
8
- override fun getEventName(): String {
9
- return EVENT_NAME
10
- }
11
6
 
12
- override fun dispatch(rctEventEmitter: RCTEventEmitter) {
13
- rctEventEmitter.receiveEvent(viewTag, eventName, serializeEventData())
14
- }
7
+ internal class FormCompleteEvent(
8
+ surfaceId: Int,
9
+ viewTag: Int,
10
+ private val formDetails: MutableMap<String, Any>,
11
+ ) : Event<FormCompleteEvent>(surfaceId, viewTag) {
12
+ override fun getEventName() = EVENT_NAME
15
13
 
16
- private fun serializeEventData(): WritableMap {
14
+ override fun getEventData(): WritableMap? {
17
15
  val eventData = Arguments.createMap()
18
16
  eventData.putString("accountNumber", formDetails["accountNumber"].toString())
19
17
  eventData.putString("bsbNumber", formDetails["bsbNumber"].toString())
@@ -24,6 +22,6 @@ internal class FormCompleteEvent constructor(viewTag: Int, private val formDetai
24
22
  }
25
23
 
26
24
  companion object {
27
- const val EVENT_NAME = "onCompleteAction"
25
+ const val EVENT_NAME = "topCompleteAction"
28
26
  }
29
27
  }
@@ -1,13 +1,13 @@
1
1
  package com.reactnativestripesdk
2
2
 
3
+ import com.facebook.react.module.annotations.ReactModule
3
4
  import com.facebook.react.uimanager.SimpleViewManager
4
5
  import com.facebook.react.uimanager.ThemedReactContext
5
6
  import com.facebook.react.uimanager.annotations.ReactProp
6
7
 
8
+ @ReactModule(name = GooglePayButtonManager.REACT_CLASS)
7
9
  class GooglePayButtonManager : SimpleViewManager<GooglePayButtonView>() {
8
- override fun getName(): String {
9
- return REACT_CLASS
10
- }
10
+ override fun getName() = REACT_CLASS
11
11
 
12
12
  override fun onAfterUpdateTransaction(view: GooglePayButtonView) {
13
13
  super.onAfterUpdateTransaction(view)
@@ -16,23 +16,30 @@ class GooglePayButtonManager : SimpleViewManager<GooglePayButtonView>() {
16
16
  }
17
17
 
18
18
  @ReactProp(name = "type")
19
- fun type(view: GooglePayButtonView, buttonType: Int) {
19
+ fun type(
20
+ view: GooglePayButtonView,
21
+ buttonType: Int,
22
+ ) {
20
23
  view.setType(buttonType)
21
24
  }
22
25
 
23
26
  @ReactProp(name = "appearance")
24
- fun appearance(view: GooglePayButtonView, appearance: Int) {
27
+ fun appearance(
28
+ view: GooglePayButtonView,
29
+ appearance: Int,
30
+ ) {
25
31
  view.setAppearance(appearance)
26
32
  }
27
33
 
28
34
  @ReactProp(name = "borderRadius")
29
- fun borderRadius(view: GooglePayButtonView, borderRadius: Int) {
35
+ fun borderRadius(
36
+ view: GooglePayButtonView,
37
+ borderRadius: Int,
38
+ ) {
30
39
  view.setBorderRadius(borderRadius)
31
40
  }
32
41
 
33
- override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView {
34
- return GooglePayButtonView(reactContext)
35
- }
42
+ override fun createViewInstance(reactContext: ThemedReactContext): GooglePayButtonView = GooglePayButtonView(reactContext)
36
43
 
37
44
  companion object {
38
45
  const val REACT_CLASS = "GooglePayButton"
@@ -13,7 +13,10 @@ import com.google.android.gms.wallet.button.PayButton
13
13
  import com.stripe.android.GooglePayJsonFactory
14
14
  import org.json.JSONArray
15
15
 
16
- class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout(context) {
16
+ @SuppressLint("ViewConstructor")
17
+ class GooglePayButtonView(
18
+ private val context: ThemedReactContext,
19
+ ) : FrameLayout(context) {
17
20
  private var type: Int? = null
18
21
  private var appearance: Int? = null
19
22
  private var borderRadius: Int = 4 // Matches the default on iOS's ApplePayButton
@@ -29,30 +32,35 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
29
32
  }
30
33
 
31
34
  private fun configureGooglePayButton(): PayButton {
32
- val googlePayButton = PayButton(
33
- context
34
- )
35
+ val googlePayButton =
36
+ PayButton(
37
+ context,
38
+ )
35
39
  googlePayButton.initialize(buildButtonOptions())
36
40
  googlePayButton.setOnClickListener { _ ->
37
41
  // Call the Javascript TouchableOpacity parent where the onClick handler is set
38
42
  (this.parent as? View)?.performClick() ?: run {
39
43
  Log.e("StripeReactNative", "Unable to find parent of GooglePayButtonView.")
40
44
  }
41
- };
45
+ }
42
46
  return googlePayButton
43
47
  }
44
48
 
45
49
  @SuppressLint("RestrictedApi")
46
50
  private fun buildButtonOptions(): ButtonOptions {
47
- val allowedPaymentMethods = JSONArray().put(
48
- GooglePayJsonFactory(context).createCardPaymentMethod(
49
- billingAddressParameters = null,
50
- allowCreditCards = null
51
- )
52
- ).toString()
53
-
54
- val options = ButtonOptions.newBuilder()
55
- .setAllowedPaymentMethods(allowedPaymentMethods)
51
+ val allowedPaymentMethods =
52
+ JSONArray()
53
+ .put(
54
+ GooglePayJsonFactory(context).createCardPaymentMethod(
55
+ billingAddressParameters = null,
56
+ allowCreditCards = null,
57
+ ),
58
+ ).toString()
59
+
60
+ val options =
61
+ ButtonOptions
62
+ .newBuilder()
63
+ .setAllowedPaymentMethods(allowedPaymentMethods)
56
64
 
57
65
  getButtonType()?.let {
58
66
  options.setButtonType(it)
@@ -67,10 +75,11 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
67
75
  return options.build()
68
76
  }
69
77
 
70
- private fun getButtonType(): Int? {
71
- return when (this.type) {
78
+ private fun getButtonType(): Int? =
79
+ when (this.type) {
72
80
  0,
73
- 1 -> ButtonType.BUY
81
+ 1,
82
+ -> ButtonType.BUY
74
83
  6 -> ButtonType.BOOK
75
84
  5 -> ButtonType.CHECKOUT
76
85
  4 -> ButtonType.DONATE
@@ -80,28 +89,27 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
80
89
  1001 -> ButtonType.PLAIN
81
90
  else -> null
82
91
  }
83
- }
84
92
 
85
- private fun getButtonTheme(): Int? {
86
- return when (this.appearance) {
93
+ private fun getButtonTheme(): Int? =
94
+ when (this.appearance) {
87
95
  0, 1 -> ButtonTheme.LIGHT
88
96
  2 -> ButtonTheme.DARK
89
97
  else -> null
90
98
  }
91
- }
92
99
 
93
100
  override fun requestLayout() {
94
101
  super.requestLayout()
95
102
  post(mLayoutRunnable)
96
103
  }
97
104
 
98
- private val mLayoutRunnable = Runnable {
99
- measure(
100
- MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
101
- MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))
102
- button?.layout(left, top, right, bottom)
103
-
104
- }
105
+ private val mLayoutRunnable =
106
+ Runnable {
107
+ measure(
108
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
109
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
110
+ )
111
+ button?.layout(left, top, right, bottom)
112
+ }
105
113
 
106
114
  fun setType(type: Int) {
107
115
  this.type = type