@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
@@ -7,19 +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
22
+ import com.stripe.android.financialconnections.FinancialConnections
15
23
  import com.stripe.android.financialconnections.FinancialConnectionsSheet
16
24
  import com.stripe.android.financialconnections.FinancialConnectionsSheetForTokenResult
17
25
  import com.stripe.android.financialconnections.FinancialConnectionsSheetResult
18
- 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
19
31
 
20
32
  class FinancialConnectionsSheetFragment : Fragment() {
21
33
  enum class Mode {
22
- ForToken, ForSession
34
+ ForToken,
35
+ ForSession,
23
36
  }
24
37
 
25
38
  private lateinit var promise: Promise
@@ -27,104 +40,132 @@ class FinancialConnectionsSheetFragment : Fragment() {
27
40
  private lateinit var configuration: FinancialConnectionsSheet.Configuration
28
41
  private lateinit var mode: Mode
29
42
 
30
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
31
- savedInstanceState: Bundle?): View {
32
- return FrameLayout(requireActivity()).also {
33
- it.visibility = View.GONE
43
+ override fun onCreate(savedInstanceState: Bundle?) {
44
+ super.onCreate(savedInstanceState)
45
+
46
+ val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
47
+ if (stripeSdkModule != null && stripeSdkModule.eventListenerCount > 0) {
48
+ FinancialConnections.setEventListener { event ->
49
+ val params = mapFromFinancialConnectionsEvent(event)
50
+ stripeSdkModule.sendEvent(context, "onFinancialConnectionsEvent", params)
51
+ }
34
52
  }
35
53
  }
36
54
 
37
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
55
+ override fun onCreateView(
56
+ inflater: LayoutInflater,
57
+ container: ViewGroup?,
58
+ savedInstanceState: Bundle?,
59
+ ): View = FrameLayout(requireActivity()).also { it.visibility = View.GONE }
60
+
61
+ override fun onViewCreated(
62
+ view: View,
63
+ savedInstanceState: Bundle?,
64
+ ) {
38
65
  when (mode) {
39
66
  Mode.ForToken -> {
40
- FinancialConnectionsSheet.createForBankAccountToken(
41
- this,
42
- ::onFinancialConnectionsSheetForTokenResult
43
- ).present(
44
- configuration = configuration
45
- )
67
+ FinancialConnectionsSheet
68
+ .createForBankAccountToken(
69
+ this,
70
+ ::onFinancialConnectionsSheetForTokenResult,
71
+ ).present(configuration = configuration)
46
72
  }
47
73
  Mode.ForSession -> {
48
- FinancialConnectionsSheet.create(
49
- this,
50
- ::onFinancialConnectionsSheetForDataResult
51
- ).present(
52
- configuration = configuration
53
- )
74
+ FinancialConnectionsSheet
75
+ .create(this, ::onFinancialConnectionsSheetForDataResult)
76
+ .present(configuration = configuration)
54
77
  }
55
78
  }
56
79
  }
57
80
 
81
+ override fun onDestroy() {
82
+ super.onDestroy()
83
+
84
+ // Remove any event listener that might be set
85
+ FinancialConnections.clearEventListener()
86
+ }
87
+
58
88
  private fun onFinancialConnectionsSheetForTokenResult(result: FinancialConnectionsSheetForTokenResult) {
59
- when(result) {
89
+ when (result) {
60
90
  is FinancialConnectionsSheetForTokenResult.Canceled -> {
61
- promise.resolve(
62
- createError(ErrorType.Canceled.toString(), "The flow has been canceled")
63
- )
91
+ promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
64
92
  }
65
93
  is FinancialConnectionsSheetForTokenResult.Failed -> {
66
- promise.resolve(
67
- createError(ErrorType.Failed.toString(), result.error)
68
- )
94
+ promise.resolve(createError(ErrorType.Failed.toString(), result.error))
69
95
  }
70
96
  is FinancialConnectionsSheetForTokenResult.Completed -> {
71
97
  promise.resolve(createTokenResult(result))
72
- (context.currentActivity as? FragmentActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
98
+ (context.currentActivity as? FragmentActivity)
99
+ ?.supportFragmentManager
100
+ ?.beginTransaction()
101
+ ?.remove(this)
102
+ ?.commitAllowingStateLoss()
73
103
  }
74
104
  }
75
105
  }
76
106
 
77
107
  private fun onFinancialConnectionsSheetForDataResult(result: FinancialConnectionsSheetResult) {
78
- when(result) {
108
+ when (result) {
79
109
  is FinancialConnectionsSheetResult.Canceled -> {
80
- promise.resolve(
81
- createError(ErrorType.Canceled.toString(), "The flow has been canceled")
82
- )
110
+ promise.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
83
111
  }
84
112
  is FinancialConnectionsSheetResult.Failed -> {
85
- promise.resolve(
86
- createError(ErrorType.Failed.toString(), result.error)
87
- )
113
+ promise.resolve(createError(ErrorType.Failed.toString(), result.error))
88
114
  }
89
115
  is FinancialConnectionsSheetResult.Completed -> {
90
116
  promise.resolve(
91
- WritableNativeMap().also {
92
- it.putMap("session", mapFromSession(result.financialConnectionsSession))
93
- }
117
+ WritableNativeMap().also {
118
+ it.putMap("session", mapFromSession(result.financialConnectionsSession))
119
+ },
94
120
  )
95
- (context.currentActivity as? FragmentActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
121
+ (context.currentActivity as? FragmentActivity)
122
+ ?.supportFragmentManager
123
+ ?.beginTransaction()
124
+ ?.remove(this)
125
+ ?.commitAllowingStateLoss()
96
126
  }
97
127
  }
98
128
  }
99
129
 
100
- 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
+ ) {
101
138
  this.promise = promise
102
139
  this.context = context
103
140
  this.mode = mode
104
- this.configuration = FinancialConnectionsSheet.Configuration(
105
- financialConnectionsSessionClientSecret = clientSecret,
106
- publishableKey = publishableKey,
107
- stripeAccountId = stripeAccountId,
108
- )
141
+ this.configuration =
142
+ FinancialConnectionsSheet.Configuration(
143
+ financialConnectionsSessionClientSecret = clientSecret,
144
+ publishableKey = publishableKey,
145
+ stripeAccountId = stripeAccountId,
146
+ )
109
147
 
110
148
  (context.currentActivity as? FragmentActivity)?.let {
111
149
  attemptToCleanupPreviousFragment(it)
112
150
  commitFragmentAndStartFlow(it)
113
- } ?: run {
114
- promise.resolve(createMissingActivityError())
115
- return
116
151
  }
152
+ ?: run {
153
+ promise.resolve(createMissingActivityError())
154
+ return
155
+ }
117
156
  }
118
157
 
119
158
  private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
120
- currentActivity.supportFragmentManager.beginTransaction()
159
+ currentActivity.supportFragmentManager
160
+ .beginTransaction()
121
161
  .remove(this)
122
162
  .commitAllowingStateLoss()
123
163
  }
124
164
 
125
165
  private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
126
166
  try {
127
- currentActivity.supportFragmentManager.beginTransaction()
167
+ currentActivity.supportFragmentManager
168
+ .beginTransaction()
128
169
  .add(this, TAG)
129
170
  .commit()
130
171
  } catch (error: IllegalStateException) {
@@ -135,12 +176,11 @@ class FinancialConnectionsSheetFragment : Fragment() {
135
176
  companion object {
136
177
  internal const val TAG = "financial_connections_sheet_launch_fragment"
137
178
 
138
- private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap {
139
- return WritableNativeMap().also {
179
+ private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap =
180
+ WritableNativeMap().also {
140
181
  it.putMap("session", mapFromSession(result.financialConnectionsSession))
141
182
  it.putMap("token", mapFromToken(result.token))
142
183
  }
143
- }
144
184
 
145
185
  private fun mapFromSession(financialConnectionsSession: FinancialConnectionsSession): WritableMap {
146
186
  val session = WritableNativeMap()
@@ -166,8 +206,19 @@ class FinancialConnectionsSheetFragment : Fragment() {
166
206
  map.putMap("balanceRefresh", mapFromAccountBalanceRefresh(account.balanceRefresh))
167
207
  map.putString("category", mapFromCategory(account.category))
168
208
  map.putString("subcategory", mapFromSubcategory(account.subcategory))
169
- map.putArray("permissions", (account.permissions?.map { permission -> mapFromPermission(permission) })?.toReadableArray())
170
- 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
+ )
171
222
  results.pushMap(map)
172
223
  }
173
224
  return results
@@ -192,8 +243,8 @@ class FinancialConnectionsSheetFragment : Fragment() {
192
243
  return map
193
244
  }
194
245
 
195
- private fun mapFromCashAvailable(balance: Balance): WritableNativeMap {
196
- return WritableNativeMap().also { cashMap ->
246
+ private fun mapFromCashAvailable(balance: Balance): WritableNativeMap =
247
+ WritableNativeMap().also { cashMap ->
197
248
  WritableNativeMap().also { availableMap ->
198
249
  balance.cash?.available?.entries?.let { entries ->
199
250
  for (entry in entries) {
@@ -203,10 +254,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
203
254
  cashMap.putMap("available", availableMap)
204
255
  }
205
256
  }
206
- }
207
257
 
208
- private fun mapFromCreditUsed(balance: Balance): WritableNativeMap {
209
- return WritableNativeMap().also { creditMap ->
258
+ private fun mapFromCreditUsed(balance: Balance): WritableNativeMap =
259
+ WritableNativeMap().also { creditMap ->
210
260
  WritableNativeMap().also { usedMap ->
211
261
  balance.credit?.used?.entries?.let { entries ->
212
262
  for (entry in entries) {
@@ -216,7 +266,6 @@ class FinancialConnectionsSheetFragment : Fragment() {
216
266
  creditMap.putMap("used", usedMap)
217
267
  }
218
268
  }
219
- }
220
269
 
221
270
  private fun mapFromAccountBalanceRefresh(balanceRefresh: BalanceRefresh?): WritableMap? {
222
271
  if (balanceRefresh == null) {
@@ -228,27 +277,25 @@ class FinancialConnectionsSheetFragment : Fragment() {
228
277
  return map
229
278
  }
230
279
 
231
- private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String {
232
- return when (status) {
280
+ private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String =
281
+ when (status) {
233
282
  FinancialConnectionsAccount.Status.ACTIVE -> "active"
234
283
  FinancialConnectionsAccount.Status.DISCONNECTED -> "disconnected"
235
284
  FinancialConnectionsAccount.Status.INACTIVE -> "inactive"
236
285
  FinancialConnectionsAccount.Status.UNKNOWN -> "unparsable"
237
286
  }
238
- }
239
287
 
240
- private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String {
241
- return when (category) {
288
+ private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String =
289
+ when (category) {
242
290
  FinancialConnectionsAccount.Category.CASH -> "cash"
243
291
  FinancialConnectionsAccount.Category.CREDIT -> "credit"
244
292
  FinancialConnectionsAccount.Category.INVESTMENT -> "investment"
245
293
  FinancialConnectionsAccount.Category.OTHER -> "other"
246
294
  FinancialConnectionsAccount.Category.UNKNOWN -> "unparsable"
247
295
  }
248
- }
249
296
 
250
- private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String {
251
- return when (subcategory) {
297
+ private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String =
298
+ when (subcategory) {
252
299
  FinancialConnectionsAccount.Subcategory.CHECKING -> "checking"
253
300
  FinancialConnectionsAccount.Subcategory.CREDIT_CARD -> "creditCard"
254
301
  FinancialConnectionsAccount.Subcategory.LINE_OF_CREDIT -> "lineOfCredit"
@@ -257,10 +304,9 @@ class FinancialConnectionsSheetFragment : Fragment() {
257
304
  FinancialConnectionsAccount.Subcategory.SAVINGS -> "savings"
258
305
  FinancialConnectionsAccount.Subcategory.UNKNOWN -> "unparsable"
259
306
  }
260
- }
261
307
 
262
- private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String {
263
- return when (permission) {
308
+ private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String =
309
+ when (permission) {
264
310
  FinancialConnectionsAccount.Permissions.PAYMENT_METHOD -> "paymentMethod"
265
311
  FinancialConnectionsAccount.Permissions.BALANCES -> "balances"
266
312
  FinancialConnectionsAccount.Permissions.OWNERSHIP -> "ownership"
@@ -269,33 +315,29 @@ class FinancialConnectionsSheetFragment : Fragment() {
269
315
  FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
270
316
  FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
271
317
  }
272
- }
273
318
 
274
- private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String {
275
- return when (type) {
319
+ private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String =
320
+ when (type) {
276
321
  FinancialConnectionsAccount.SupportedPaymentMethodTypes.US_BANK_ACCOUNT -> "usBankAccount"
277
322
  FinancialConnectionsAccount.SupportedPaymentMethodTypes.LINK -> "link"
278
323
  FinancialConnectionsAccount.SupportedPaymentMethodTypes.UNKNOWN -> "unparsable"
279
324
  }
280
- }
281
325
 
282
- private fun mapFromBalanceType(type: Balance.Type): String {
283
- return when (type) {
326
+ private fun mapFromBalanceType(type: Balance.Type): String =
327
+ when (type) {
284
328
  Balance.Type.CASH -> "cash"
285
329
  Balance.Type.CREDIT -> "credit"
286
330
  Balance.Type.UNKNOWN -> "unparsable"
287
331
  }
288
- }
289
332
 
290
- private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String {
291
- return when (status) {
333
+ private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String =
334
+ when (status) {
292
335
  BalanceRefresh.BalanceRefreshStatus.SUCCEEDED -> "succeeded"
293
336
  BalanceRefresh.BalanceRefreshStatus.FAILED -> "failed"
294
337
  BalanceRefresh.BalanceRefreshStatus.PENDING -> "pending"
295
338
  BalanceRefresh.BalanceRefreshStatus.UNKNOWN -> "unparsable"
296
339
  null -> "null"
297
340
  }
298
- }
299
341
  }
300
342
  }
301
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