@stripe/stripe-react-native 0.14.0 → 0.17.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 (281) hide show
  1. package/.editorconfig +15 -0
  2. package/.husky/pre-commit +4 -0
  3. package/CHANGELOG.md +55 -0
  4. package/android/build.gradle +1 -6
  5. package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +2 -0
  6. package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +27 -6
  7. package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +34 -3
  8. package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +10 -1
  9. package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +284 -0
  10. package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +17 -7
  11. package/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt +8 -0
  12. package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +6 -2
  13. package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +12 -11
  14. package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +213 -367
  15. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +1 -0
  16. package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +45 -28
  17. package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +85 -46
  18. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +1 -1
  19. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxy.kt +2 -2
  20. package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +1 -1
  21. package/android/src/main/java/com/reactnativestripesdk/{Errors.kt → utils/Errors.kt} +5 -1
  22. package/android/src/main/java/com/reactnativestripesdk/{Extensions.kt → utils/Extensions.kt} +12 -1
  23. package/android/src/main/java/com/reactnativestripesdk/{Mappers.kt → utils/Mappers.kt} +8 -5
  24. package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +18 -0
  25. package/android/src/main/res/{drawable-night/googlepay_button_background.xml → drawable/googlepay_button_background_dark.xml} +1 -1
  26. package/android/src/main/res/{drawable-night/googlepay_button_content.xml → drawable/googlepay_button_content_dark.xml} +0 -0
  27. package/android/src/main/res/{drawable-night/googlepay_button_overlay.xml → drawable/googlepay_button_overlay_dark.xml} +0 -0
  28. package/android/src/main/res/{drawable-night/pay_with_googlepay_button_content.xml → drawable/pay_with_googlepay_button_content_dark.xml} +0 -0
  29. package/android/src/main/res/{drawable-ar-night/pay_with_googlepay_button_content.xml → drawable-ar/pay_with_googlepay_button_content_dark.xml} +0 -0
  30. package/android/src/main/res/{drawable-bg-night/pay_with_googlepay_button_content.xml → drawable-bg/pay_with_googlepay_button_content_dark.xml} +0 -0
  31. package/android/src/main/res/{drawable-ca-night/pay_with_googlepay_button_content.xml → drawable-ca/pay_with_googlepay_button_content_dark.xml} +0 -0
  32. package/android/src/main/res/{drawable-cs-night/pay_with_googlepay_button_content.xml → drawable-cs/pay_with_googlepay_button_content_dark.xml} +0 -0
  33. package/android/src/main/res/{drawable-da-night/pay_with_googlepay_button_content.xml → drawable-da/pay_with_googlepay_button_content_dark.xml} +0 -0
  34. package/android/src/main/res/{drawable-de-night/pay_with_googlepay_button_content.xml → drawable-de/pay_with_googlepay_button_content_dark.xml} +0 -0
  35. package/android/src/main/res/{drawable-el-night/pay_with_googlepay_button_content.xml → drawable-el/pay_with_googlepay_button_content_dark.xml} +0 -0
  36. package/android/src/main/res/{drawable-es-night/pay_with_googlepay_button_content.xml → drawable-es/pay_with_googlepay_button_content_dark.xml} +0 -0
  37. package/android/src/main/res/{drawable-et-night/pay_with_googlepay_button_content.xml → drawable-et/pay_with_googlepay_button_content_dark.xml} +0 -0
  38. package/android/src/main/res/{drawable-fi-night/pay_with_googlepay_button_content.xml → drawable-fi/pay_with_googlepay_button_content_dark.xml} +0 -0
  39. package/android/src/main/res/{drawable-fr-night/pay_with_googlepay_button_content.xml → drawable-fr/pay_with_googlepay_button_content_dark.xml} +0 -0
  40. package/android/src/main/res/{drawable-night-hdpi/googlepay_button_background_image.9.png → drawable-hdpi/googlepay_button_background_image_dark.9.png} +0 -0
  41. package/android/src/main/res/{drawable-hr-night/pay_with_googlepay_button_content.xml → drawable-hr/pay_with_googlepay_button_content_dark.xml} +0 -0
  42. package/android/src/main/res/{drawable-id-night/pay_with_googlepay_button_content.xml → drawable-id/pay_with_googlepay_button_content_dark.xml} +0 -0
  43. package/android/src/main/res/{drawable-it-night/pay_with_googlepay_button_content.xml → drawable-it/pay_with_googlepay_button_content_dark.xml} +0 -0
  44. package/android/src/main/res/{drawable-ja-night/pay_with_googlepay_button_content.xml → drawable-ja/pay_with_googlepay_button_content_dark.xml} +0 -0
  45. package/android/src/main/res/{drawable-ko-night/pay_with_googlepay_button_content.xml → drawable-ko/pay_with_googlepay_button_content_dark.xml} +0 -0
  46. package/android/src/main/res/{drawable-night-mdpi/googlepay_button_background_image.9.png → drawable-mdpi/googlepay_button_background_image_dark.9.png} +0 -0
  47. package/android/src/main/res/{drawable-ms-night/pay_with_googlepay_button_content.xml → drawable-ms/pay_with_googlepay_button_content_dark.xml} +0 -0
  48. package/android/src/main/res/{drawable-nl-night/pay_with_googlepay_button_content.xml → drawable-nl/pay_with_googlepay_button_content_dark.xml} +0 -0
  49. package/android/src/main/res/{drawable-no-night/pay_with_googlepay_button_content.xml → drawable-no/pay_with_googlepay_button_content_dark.xml} +0 -0
  50. package/android/src/main/res/{drawable-pl-night/pay_with_googlepay_button_content.xml → drawable-pl/pay_with_googlepay_button_content_dark.xml} +0 -0
  51. package/android/src/main/res/{drawable-pt-night/pay_with_googlepay_button_content.xml → drawable-pt/pay_with_googlepay_button_content_dark.xml} +0 -0
  52. package/android/src/main/res/{drawable-ru-night/pay_with_googlepay_button_content.xml → drawable-ru/pay_with_googlepay_button_content_dark.xml} +0 -0
  53. package/android/src/main/res/{drawable-sk-night/pay_with_googlepay_button_content.xml → drawable-sk/pay_with_googlepay_button_content_dark.xml} +0 -0
  54. package/android/src/main/res/{drawable-sl-night/pay_with_googlepay_button_content.xml → drawable-sl/pay_with_googlepay_button_content_dark.xml} +0 -0
  55. package/android/src/main/res/{drawable-sr-night/pay_with_googlepay_button_content.xml → drawable-sr/pay_with_googlepay_button_content_dark.xml} +0 -0
  56. package/android/src/main/res/{drawable-sv-night/pay_with_googlepay_button_content.xml → drawable-sv/pay_with_googlepay_button_content_dark.xml} +0 -0
  57. package/android/src/main/res/{drawable-th-night/pay_with_googlepay_button_content.xml → drawable-th/pay_with_googlepay_button_content_dark.xml} +0 -0
  58. package/android/src/main/res/{drawable-tr-night/pay_with_googlepay_button_content.xml → drawable-tr/pay_with_googlepay_button_content_dark.xml} +0 -0
  59. package/android/src/main/res/{drawable-uk-night/pay_with_googlepay_button_content.xml → drawable-uk/pay_with_googlepay_button_content_dark.xml} +0 -0
  60. package/android/src/main/res/{drawable-night-v21/googlepay_button_background.xml → drawable-v21/googlepay_button_background_dark.xml} +1 -1
  61. package/android/src/main/res/{drawable-night-xhdpi/googlepay_button_background_image.9.png → drawable-xhdpi/googlepay_button_background_image_dark.9.png} +0 -0
  62. package/android/src/main/res/{drawable-night-xxhdpi/googlepay_button_background_image.9.png → drawable-xxhdpi/googlepay_button_background_image_dark.9.png} +0 -0
  63. package/android/src/main/res/{drawable-night-xxxhdpi/googlepay_button_background_image.9.png → drawable-xxxhdpi/googlepay_button_background_image_dark.9.png} +0 -0
  64. package/android/src/main/res/{layout-night/googlepay_button.xml → layout/googlepay_button_dark.xml} +4 -4
  65. package/android/src/main/res/{layout-night/pay_with_googlepay_button.xml → layout/pay_with_googlepay_button_dark.xml} +4 -4
  66. package/ios/ApplePayUtils.swift +159 -0
  67. package/ios/CardFormView.swift +20 -0
  68. package/ios/Errors.swift +11 -0
  69. package/ios/FinancialConnections.swift +258 -0
  70. package/ios/Mappers.swift +20 -22
  71. package/ios/PaymentMethodFactory.swift +9 -0
  72. package/ios/StripeSdk.m +10 -1
  73. package/ios/StripeSdk.swift +67 -44
  74. package/ios/Tests/ApplePayUtilsTests.swift +214 -0
  75. package/lib/commonjs/NativeStripeSdk.js.map +1 -1
  76. package/lib/commonjs/components/AddToWalletButton.js +1 -1
  77. package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
  78. package/lib/commonjs/components/ApplePayButton.js +1 -1
  79. package/lib/commonjs/components/ApplePayButton.js.map +1 -1
  80. package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
  81. package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
  82. package/lib/commonjs/components/CardField.js +1 -1
  83. package/lib/commonjs/components/CardField.js.map +1 -1
  84. package/lib/commonjs/components/CardForm.js +1 -1
  85. package/lib/commonjs/components/CardForm.js.map +1 -1
  86. package/lib/commonjs/components/GooglePayButton.js +1 -1
  87. package/lib/commonjs/components/GooglePayButton.js.map +1 -1
  88. package/lib/commonjs/components/StripeContainer.js +1 -1
  89. package/lib/commonjs/components/StripeContainer.js.map +1 -1
  90. package/lib/commonjs/components/StripeProvider.js +1 -1
  91. package/lib/commonjs/components/StripeProvider.js.map +1 -1
  92. package/lib/commonjs/functions.js +1 -1
  93. package/lib/commonjs/functions.js.map +1 -1
  94. package/lib/commonjs/hooks/useApplePay.js +1 -1
  95. package/lib/commonjs/hooks/useApplePay.js.map +1 -1
  96. package/lib/commonjs/hooks/useConfirmPayment.js +1 -1
  97. package/lib/commonjs/hooks/useConfirmPayment.js.map +1 -1
  98. package/lib/commonjs/hooks/useConfirmSetupIntent.js +1 -1
  99. package/lib/commonjs/hooks/useConfirmSetupIntent.js.map +1 -1
  100. package/lib/commonjs/hooks/useFinancialConnectionsSheet.js +2 -0
  101. package/lib/commonjs/hooks/useFinancialConnectionsSheet.js.map +1 -0
  102. package/lib/commonjs/hooks/useGooglePay.js +1 -1
  103. package/lib/commonjs/hooks/useGooglePay.js.map +1 -1
  104. package/lib/commonjs/hooks/usePaymentSheet.js +1 -1
  105. package/lib/commonjs/hooks/usePaymentSheet.js.map +1 -1
  106. package/lib/commonjs/hooks/useStripe.js +1 -1
  107. package/lib/commonjs/hooks/useStripe.js.map +1 -1
  108. package/lib/commonjs/index.js +1 -1
  109. package/lib/commonjs/index.js.map +1 -1
  110. package/lib/commonjs/plugin/withStripe.js +1 -1
  111. package/lib/commonjs/plugin/withStripe.js.map +1 -1
  112. package/lib/commonjs/types/FinancialConnections.js +2 -0
  113. package/lib/commonjs/types/FinancialConnections.js.map +1 -0
  114. package/lib/commonjs/types/PaymentIntent.js.map +1 -1
  115. package/lib/commonjs/types/SetupIntent.js.map +1 -1
  116. package/lib/commonjs/types/index.js +1 -1
  117. package/lib/commonjs/types/index.js.map +1 -1
  118. package/lib/module/NativeStripeSdk.js.map +1 -1
  119. package/lib/module/components/AddToWalletButton.js +1 -1
  120. package/lib/module/components/AddToWalletButton.js.map +1 -1
  121. package/lib/module/components/ApplePayButton.js +1 -1
  122. package/lib/module/components/ApplePayButton.js.map +1 -1
  123. package/lib/module/components/AuBECSDebitForm.js +1 -1
  124. package/lib/module/components/AuBECSDebitForm.js.map +1 -1
  125. package/lib/module/components/CardField.js +1 -1
  126. package/lib/module/components/CardField.js.map +1 -1
  127. package/lib/module/components/CardForm.js +1 -1
  128. package/lib/module/components/CardForm.js.map +1 -1
  129. package/lib/module/components/GooglePayButton.js +1 -1
  130. package/lib/module/components/GooglePayButton.js.map +1 -1
  131. package/lib/module/components/StripeContainer.js +1 -1
  132. package/lib/module/components/StripeContainer.js.map +1 -1
  133. package/lib/module/components/StripeProvider.js +1 -1
  134. package/lib/module/components/StripeProvider.js.map +1 -1
  135. package/lib/module/functions.js +1 -1
  136. package/lib/module/functions.js.map +1 -1
  137. package/lib/module/hooks/useApplePay.js +1 -1
  138. package/lib/module/hooks/useApplePay.js.map +1 -1
  139. package/lib/module/hooks/useConfirmPayment.js +1 -1
  140. package/lib/module/hooks/useConfirmPayment.js.map +1 -1
  141. package/lib/module/hooks/useConfirmSetupIntent.js +1 -1
  142. package/lib/module/hooks/useConfirmSetupIntent.js.map +1 -1
  143. package/lib/module/hooks/useFinancialConnectionsSheet.js +2 -0
  144. package/lib/module/hooks/useFinancialConnectionsSheet.js.map +1 -0
  145. package/lib/module/hooks/useGooglePay.js +1 -1
  146. package/lib/module/hooks/useGooglePay.js.map +1 -1
  147. package/lib/module/hooks/usePaymentSheet.js +1 -1
  148. package/lib/module/hooks/usePaymentSheet.js.map +1 -1
  149. package/lib/module/hooks/useStripe.js +1 -1
  150. package/lib/module/hooks/useStripe.js.map +1 -1
  151. package/lib/module/index.js +1 -1
  152. package/lib/module/index.js.map +1 -1
  153. package/lib/module/plugin/withStripe.js +1 -1
  154. package/lib/module/plugin/withStripe.js.map +1 -1
  155. package/lib/module/types/FinancialConnections.js +2 -0
  156. package/lib/module/types/FinancialConnections.js.map +1 -0
  157. package/lib/module/types/PaymentIntent.js.map +1 -1
  158. package/lib/module/types/SetupIntent.js.map +1 -1
  159. package/lib/module/types/index.js +1 -1
  160. package/lib/module/types/index.js.map +1 -1
  161. package/lib/typescript/src/NativeStripeSdk.d.ts +3 -1
  162. package/lib/typescript/src/components/CardForm.d.ts +1 -1
  163. package/lib/typescript/src/components/GooglePayButton.d.ts +2 -2
  164. package/lib/typescript/src/functions.d.ts +15 -1
  165. package/lib/typescript/src/hooks/useFinancialConnectionsSheet.d.ts +11 -0
  166. package/lib/typescript/src/hooks/useStripe.d.ts +3 -1
  167. package/lib/typescript/src/index.d.ts +1 -0
  168. package/lib/typescript/src/types/ApplePay.d.ts +31 -5
  169. package/lib/typescript/src/types/FinancialConnections.d.ts +100 -0
  170. package/lib/typescript/src/types/PaymentIntent.d.ts +1 -0
  171. package/lib/typescript/src/types/PaymentMethod.d.ts +9 -1
  172. package/lib/typescript/src/types/PaymentSheet.d.ts +17 -15
  173. package/lib/typescript/src/types/SetupIntent.d.ts +1 -0
  174. package/lib/typescript/src/types/Token.d.ts +18 -7
  175. package/lib/typescript/src/types/index.d.ts +2 -1
  176. package/package.json +11 -23
  177. package/src/NativeStripeSdk.tsx +7 -0
  178. package/src/components/CardForm.tsx +2 -2
  179. package/src/components/GooglePayButton.tsx +8 -2
  180. package/src/functions.ts +58 -0
  181. package/src/hooks/useFinancialConnectionsSheet.tsx +34 -0
  182. package/src/hooks/useStripe.tsx +21 -0
  183. package/src/index.tsx +1 -0
  184. package/src/types/ApplePay.ts +39 -6
  185. package/src/types/FinancialConnections.ts +126 -0
  186. package/src/types/PaymentIntent.ts +1 -0
  187. package/src/types/PaymentMethod.ts +11 -1
  188. package/src/types/PaymentSheet.ts +34 -36
  189. package/src/types/SetupIntent.ts +1 -0
  190. package/src/types/Token.ts +24 -7
  191. package/src/types/index.ts +2 -0
  192. package/android/.DS_Store +0 -0
  193. package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  194. package/android/.gradle/7.1/dependencies-accessors/gc.properties +0 -0
  195. package/android/.gradle/7.1/fileChanges/last-build.bin +0 -0
  196. package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
  197. package/android/.gradle/7.1/gc.properties +0 -0
  198. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  199. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  200. package/android/.gradle/checksums/checksums.lock +0 -0
  201. package/android/.gradle/vcs-1/gc.properties +0 -0
  202. package/android/.idea/.gitignore +0 -3
  203. package/android/.idea/gradle.xml +0 -13
  204. package/android/.idea/misc.xml +0 -9
  205. package/android/.idea/modules/android.iml +0 -18
  206. package/android/.idea/modules.xml +0 -8
  207. package/android/.idea/vcs.xml +0 -6
  208. package/android/.idea/workspace.xml +0 -52
  209. package/android/local.properties +0 -8
  210. package/android/src/.DS_Store +0 -0
  211. package/android/src/androidTest/.DS_Store +0 -0
  212. package/android/src/androidTest/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +0 -35
  213. package/android/src/main/res/drawable-night/googlepay_button_no_shadow_background.xml +0 -6
  214. package/android/src/main/res/drawable-night-hdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
  215. package/android/src/main/res/drawable-night-mdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
  216. package/android/src/main/res/drawable-night-v21/googlepay_button_no_shadow_background.xml +0 -7
  217. package/android/src/main/res/drawable-night-xhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
  218. package/android/src/main/res/drawable-night-xxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
  219. package/android/src/main/res/drawable-night-xxxhdpi/googlepay_button_no_shadow_background_image.9.png +0 -0
  220. package/android/src/main/res/values-night/googlepay_strings.xml +0 -12
  221. package/ios/.DS_Store +0 -0
  222. package/ios/StripeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  223. package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  224. package/ios/StripeSdk.xcodeproj/project.xcworkspace/xcuserdata/charliecruzan.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  225. package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -22
  226. package/ios/StripeSdk.xcodeproj/xcuserdata/charliecruzan.xcuserdatad/xcschemes/xcschememanagement.plist +0 -27
  227. package/lib/typescript/e2e/buyNowPayLater.test.d.ts +0 -1
  228. package/lib/typescript/e2e/helpers.d.ts +0 -5
  229. package/lib/typescript/e2e/payments.test.d.ts +0 -1
  230. package/lib/typescript/e2e/paymentsWithRedirects.test.d.ts +0 -1
  231. package/lib/typescript/e2e/screenObject/BasicPaymentScreen.d.ts +0 -16
  232. package/lib/typescript/e2e/screenObject/HomeScreen.d.ts +0 -6
  233. package/lib/typescript/e2e/screenObject/components/BECSForm.d.ts +0 -8
  234. package/lib/typescript/e2e/screenObject/components/CardField.d.ts +0 -10
  235. package/lib/typescript/example/server/index.d.ts +0 -1
  236. package/lib/typescript/example/server/utils.d.ts +0 -11
  237. package/lib/typescript/example/src/App.d.ts +0 -45
  238. package/lib/typescript/example/src/Config.d.ts +0 -2
  239. package/lib/typescript/example/src/colors.d.ts +0 -8
  240. package/lib/typescript/example/src/components/Button.d.ts +0 -11
  241. package/lib/typescript/example/src/components/Collapse.d.ts +0 -6
  242. package/lib/typescript/example/src/components/PaymentScreen.d.ts +0 -7
  243. package/lib/typescript/example/src/helpers.d.ts +0 -1
  244. package/lib/typescript/example/src/screens/ACHPaymentScreen.d.ts +0 -1
  245. package/lib/typescript/example/src/screens/ACHSetupScreen.d.ts +0 -1
  246. package/lib/typescript/example/src/screens/AfterpayClearpayPaymentScreen.d.ts +0 -1
  247. package/lib/typescript/example/src/screens/AlipayPaymentScreen.d.ts +0 -1
  248. package/lib/typescript/example/src/screens/ApplePayScreen.d.ts +0 -1
  249. package/lib/typescript/example/src/screens/AuBECSDebitPaymentScreen.d.ts +0 -1
  250. package/lib/typescript/example/src/screens/AuBECSDebitSetupPaymentScreen.d.ts +0 -1
  251. package/lib/typescript/example/src/screens/BancontactPaymentScreen.d.ts +0 -1
  252. package/lib/typescript/example/src/screens/BancontactSetupFuturePaymentScreen.d.ts +0 -1
  253. package/lib/typescript/example/src/screens/CVCReCollectionScreen.d.ts +0 -1
  254. package/lib/typescript/example/src/screens/CreateTokenScreen.d.ts +0 -1
  255. package/lib/typescript/example/src/screens/EPSPaymentScreen.d.ts +0 -1
  256. package/lib/typescript/example/src/screens/FPXPaymentScreen.d.ts +0 -1
  257. package/lib/typescript/example/src/screens/GiropayPaymentScreen.d.ts +0 -1
  258. package/lib/typescript/example/src/screens/GooglePayScreen.d.ts +0 -1
  259. package/lib/typescript/example/src/screens/GrabPayPaymentScreen.d.ts +0 -1
  260. package/lib/typescript/example/src/screens/HomeScreen.d.ts +0 -1
  261. package/lib/typescript/example/src/screens/IdealPaymentScreen.d.ts +0 -1
  262. package/lib/typescript/example/src/screens/IdealSetupFuturePaymentScreen.d.ts +0 -1
  263. package/lib/typescript/example/src/screens/KlarnaPaymentScreen.d.ts +0 -1
  264. package/lib/typescript/example/src/screens/MultilineWebhookPaymentScreen.d.ts +0 -1
  265. package/lib/typescript/example/src/screens/NoWebhookPaymentScreen.d.ts +0 -1
  266. package/lib/typescript/example/src/screens/OxxoPaymentScreen.d.ts +0 -1
  267. package/lib/typescript/example/src/screens/P24PaymentScreen.d.ts +0 -1
  268. package/lib/typescript/example/src/screens/PayPalScreen.d.ts +0 -1
  269. package/lib/typescript/example/src/screens/PaymentResultScreen.d.ts +0 -8
  270. package/lib/typescript/example/src/screens/PaymentSheetAppearance.d.ts +0 -3
  271. package/lib/typescript/example/src/screens/PaymentsUICompleteScreen.d.ts +0 -1
  272. package/lib/typescript/example/src/screens/PaymentsUICustomScreen.d.ts +0 -1
  273. package/lib/typescript/example/src/screens/SepaPaymentScreen.d.ts +0 -1
  274. package/lib/typescript/example/src/screens/SepaSetupFuturePaymentScreen.d.ts +0 -1
  275. package/lib/typescript/example/src/screens/SetupFuturePaymentScreen.d.ts +0 -1
  276. package/lib/typescript/example/src/screens/SofortPaymentScreen.d.ts +0 -1
  277. package/lib/typescript/example/src/screens/SofortSetupFuturePaymentScreen.d.ts +0 -1
  278. package/lib/typescript/example/src/screens/WebhookPaymentScreen.d.ts +0 -1
  279. package/lib/typescript/src/plugin/__tests__/withStripe-test.d.ts +0 -1
  280. package/src/plugin/__tests__/fixtures/sample-AndroidManifest.xml +0 -24
  281. package/src/plugin/__tests__/withStripe-test.ts +0 -111
package/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+ [*]
8
+
9
+ indent_style = space
10
+ indent_size = 2
11
+
12
+ end_of_line = lf
13
+ charset = utf-8
14
+ trim_trailing_whitespace = true
15
+ insert_final_newline = true
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ yarn lint && yarn typescript
package/CHANGELOG.md CHANGED
@@ -2,6 +2,61 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.17.0 - 2022-08-11
6
+
7
+ ### Breaking changes
8
+
9
+ ### New features
10
+
11
+ - Added the [`collectBankAccountToken`](https://stripe.com/docs/financial-connections/connect-payouts?platform=react-native) & [`collectFinancialConnectionsAccounts`](https://stripe.com/docs/financial-connections/other-data-powered-products?platform=react-native) functions.
12
+
13
+ ### Fixes
14
+
15
+ - Fixed an issue where `collectBankAccountForPayment` and `collectBankAccountForSetup` would fail on Android when using React Native 0.65.x or under. [#1059](https://github.com/stripe/stripe-react-native/pull/1059)
16
+ - Fixed an issue where Android apps could crash with the error `IllegalStateException: Cannot remove Fragment attached to a different FragmentManager`. [#1054](https://github.com/stripe/stripe-react-native/pull/1054)
17
+ - Bumped Gradle from 4.2.2 to 7.1.1. [#1058](https://github.com/stripe/stripe-react-native/pull/1058)
18
+
19
+ ## 0.16.0 - 2022-07-22
20
+
21
+ ### Breaking changes
22
+
23
+ - The `<GooglePayButton />` component no longer overrides the `type` to use the dark mode version when the device is in Dark Mode. If you set the `type` value, it will always be respected. If you don't set the `type` value, it will match the system's theme (`standard_shadow` when in Light Mode, and `standard_dark` when in Dark Mode). [#1051](https://github.com/stripe/stripe-react-native/pull/1051)
24
+
25
+ ### New features
26
+
27
+ - Added support for `pay_dark` and `standard_dark` to the `<GooglePayButton />` component's `type` prop. This allows you to display the [dark Google Pay button](https://developers.google.com/pay/api/android/guides/brand-guidelines). [#1051](https://github.com/stripe/stripe-react-native/pull/1051)
28
+ - Added support for `borderColor`, `borderRadius`, and `cursorColor` to `CardForm`'s `cardStyle` prop on iOS (already exists on Android). [#1048](https://github.com/stripe/stripe-react-native/pull/1048)
29
+
30
+ ### Fixes
31
+
32
+ - Reduced the size of the `@stripe/stripe-react-native` by preventing unnecessary files from being published. [#1043](https://github.com/stripe/stripe-react-native/pull/1043)
33
+
34
+ ## 0.15.0 - 2022-07-14
35
+
36
+ ### Breaking changes
37
+
38
+ - [#1020](https://github.com/stripe/stripe-react-native/pull/1020) Changed some of fields for the `params` object that is supplied to `initPaymentSheet(params)`:
39
+ - **Changed the `applePay` field**. Previously this field accepted a boolean, now it accepts an object of type `ApplePayParams`, which includes the `merchantCountryCode` field, and a new `paymentSummaryItems` field (see "New features" below).
40
+ - **Changed the `googlePay` field**. Previously this field accepted a boolean, now it accepts an object of type `GooglePayParams`, which includes the `merchantCountryCode`, `currencyCode`, and `testEnv` fields.
41
+ - Since the `merchantCountryCode` field now lives under the `applePay` and `googlePay` objects, it has been removed from the base `params` object.
42
+ - Similarly, since the `currencyCode` and `testEnv` fields now live under the `googlePay` object, they have been removed from the base `params` object .
43
+ - [#1020](https://github.com/stripe/stripe-react-native/pull/1020) In `ApplePay.CartSummaryItem`:
44
+ - Renamed `type` to `isPending`- (if you had `type: 'pending'`, replace it with `isPending: true`. if `type: 'final'`, either remove it or set `isPending: false`).
45
+ - The same change was made to `ApplePay.ShippingMethod`: renamed `type` to `isPending`.
46
+ - Added a **new** `paymentType` field. This field is **required**, and in all pre-existing cases where you created a `CartSummaryItem`, should be set to `paymentType: 'Immediate'` (support for types `Deferred` and `Recurring` wasn't available until this release).
47
+
48
+ ### New features
49
+
50
+ - Added support for iOS 15 `paymentSummaryItems`: `PKDeferredPaymentSummaryItem` and `PKRecurringPaymentSummaryItem`.
51
+ - You can now specify Apple Pay line items to be displayed when paying with Apple Pay in PaymentSheet by providing `applePay.paymentSummaryItems` to the `initPaymentSheet` method. [#1020](https://github.com/stripe/stripe-react-native/pull/1020)
52
+ - Added support for Affirm (previously, Affirm was only available in the Payment Sheet). [1036](https://github.com/stripe/stripe-react-native/pull/1036)
53
+
54
+ ### Fixes
55
+
56
+ - Fixed behavior of `CardField` and `CardForm` on Android to match that on iOS; postal code input no longer accepts characters that are never present in postal codes (anything besides 0-9, a-z, A-Z, hyphens, and whitespace). [#1027](https://github.com/stripe/stripe-react-native/pull/1027).
57
+ - Fixed an issue on older version of React Native where calling `collectBankAccountForSetup` or `collectBankAccountForPayment` and getting a `Canceled` result could cause a crash. [#1037](https://github.com/stripe/stripe-react-native/pull/1037)
58
+ - Fixed an issue where some Android builds would fail on the `lintVitalRelease` step. [#1038](https://github.com/stripe/stripe-react-native/pull/1038)
59
+
5
60
  ## 0.14.0 - 2022-06-30
6
61
 
7
62
  ### Breaking changes
@@ -8,7 +8,7 @@ buildscript {
8
8
  }
9
9
 
10
10
  dependencies {
11
- classpath 'com.android.tools.build:gradle:4.2.2'
11
+ classpath 'com.android.tools.build:gradle:7.1.1'
12
12
  // noinspection DifferentKotlinGradleVersion
13
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
14
  }
@@ -153,8 +153,3 @@ dependencies {
153
153
  androidTestImplementation 'androidx.test:runner:1.1.0'
154
154
  androidTestImplementation "org.mockito:mockito-core:3.+"
155
155
  }
156
-
157
- configurations {
158
- // We want to include all of our compileOnly libraries in our tests
159
- androidTestImplementation.extendsFrom compileOnly
160
- }
@@ -10,6 +10,8 @@ import com.facebook.react.uimanager.events.EventDispatcher
10
10
  import com.google.android.material.shape.CornerFamily
11
11
  import com.google.android.material.shape.MaterialShapeDrawable
12
12
  import com.google.android.material.shape.ShapeAppearanceModel
13
+ import com.reactnativestripesdk.utils.getIntOrNull
14
+ import com.reactnativestripesdk.utils.getValOr
13
15
  import com.stripe.android.databinding.BecsDebitWidgetBinding
14
16
  import com.stripe.android.model.PaymentMethodCreateParams
15
17
  import com.stripe.android.view.BecsDebitWidget
@@ -5,6 +5,7 @@ import android.graphics.Color
5
5
  import android.graphics.Typeface
6
6
  import android.os.Build
7
7
  import android.text.Editable
8
+ import android.text.InputFilter
8
9
  import android.text.TextWatcher
9
10
  import android.util.Log
10
11
  import android.widget.FrameLayout
@@ -16,6 +17,8 @@ import com.facebook.react.uimanager.events.EventDispatcher
16
17
  import com.google.android.material.shape.CornerFamily
17
18
  import com.google.android.material.shape.MaterialShapeDrawable
18
19
  import com.google.android.material.shape.ShapeAppearanceModel
20
+ import com.reactnativestripesdk.utils.*
21
+ import com.reactnativestripesdk.utils.mapCardBrand
19
22
  import com.stripe.android.core.model.CountryCode
20
23
  import com.stripe.android.core.model.CountryUtils
21
24
  import com.stripe.android.databinding.CardInputWidgetBinding
@@ -25,7 +28,6 @@ import com.stripe.android.view.CardInputListener
25
28
  import com.stripe.android.view.CardInputWidget
26
29
  import com.stripe.android.view.CardValidCallback
27
30
  import com.stripe.android.view.StripeEditText
28
- import java.lang.Exception
29
31
 
30
32
  class CardFieldView(context: ThemedReactContext) : FrameLayout(context) {
31
33
  private var mCardWidget: CardInputWidget = CardInputWidget(context)
@@ -205,12 +207,11 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) {
205
207
  * We can reliable assume that setPostalCodeEnabled is called before
206
208
  * setCountryCode because of the order of the props in CardField.tsx
207
209
  */
208
- fun setCountryCode(countryCode: String?) {
210
+ fun setCountryCode(countryString: String?) {
209
211
  if (mCardWidget.postalCodeEnabled) {
210
- val doesCountryUsePostalCode = CountryUtils.doesCountryUsePostalCode(
211
- CountryCode.create(value = countryCode ?: LocaleListCompat.getAdjustedDefault()[0].country)
212
- )
213
- mCardWidget.postalCodeRequired = doesCountryUsePostalCode
212
+ val countryCode = CountryCode.create(value = countryString ?: LocaleListCompat.getAdjustedDefault()[0].country)
213
+ mCardWidget.postalCodeRequired = CountryUtils.doesCountryUsePostalCode(countryCode)
214
+ setPostalCodeFilter(countryCode)
214
215
  }
215
216
  }
216
217
 
@@ -336,6 +337,26 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) {
336
337
  })
337
338
  }
338
339
 
340
+ private fun setPostalCodeFilter(countryCode: CountryCode) {
341
+ cardInputWidgetBinding.postalCodeEditText.filters = arrayOf(
342
+ *cardInputWidgetBinding.postalCodeEditText.filters,
343
+ createPostalCodeInputFilter(countryCode)
344
+ )
345
+ }
346
+
347
+ private fun createPostalCodeInputFilter(countryCode: CountryCode): InputFilter {
348
+ return InputFilter { charSequence, start, end, _, _, _ ->
349
+ for (i in start until end) {
350
+ val isValidCharacter = (countryCode == CountryCode.US && PostalCodeUtilities.isValidUsPostalCodeCharacter(charSequence[i])) ||
351
+ (countryCode != CountryCode.US && PostalCodeUtilities.isValidGlobalPostalCodeCharacter(charSequence[i]))
352
+ if (!isValidCharacter) {
353
+ return@InputFilter ""
354
+ }
355
+ }
356
+ return@InputFilter null
357
+ }
358
+ }
359
+
339
360
  override fun requestLayout() {
340
361
  super.requestLayout()
341
362
  post(mLayoutRunnable)
@@ -4,6 +4,7 @@ import android.content.res.ColorStateList
4
4
  import android.graphics.Color
5
5
  import android.graphics.Typeface
6
6
  import android.os.Build
7
+ import android.text.InputFilter
7
8
  import android.view.View
8
9
  import android.view.View.OnFocusChangeListener
9
10
  import android.widget.FrameLayout
@@ -14,6 +15,8 @@ import com.facebook.react.uimanager.events.EventDispatcher
14
15
  import com.google.android.material.shape.CornerFamily
15
16
  import com.google.android.material.shape.MaterialShapeDrawable
16
17
  import com.google.android.material.shape.ShapeAppearanceModel
18
+ import com.reactnativestripesdk.utils.*
19
+ import com.reactnativestripesdk.utils.mapCardBrand
17
20
  import com.stripe.android.core.model.CountryCode
18
21
  import com.stripe.android.databinding.CardMultilineWidgetBinding
19
22
  import com.stripe.android.databinding.StripeCardFormViewBinding
@@ -50,10 +53,15 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
50
53
  }
51
54
 
52
55
  fun setDefaultValues(defaults: ReadableMap) {
53
- defaults.getString("countryCode")?.let {
54
- cardFormViewBinding.countryLayout.setSelectedCountryCode(CountryCode(it))
55
- cardFormViewBinding.countryLayout.updateUiForCountryEntered(CountryCode(it))
56
+ setCountry(defaults.getString("countryCode"))
57
+ }
58
+
59
+ private fun setCountry(countryString: String?) {
60
+ if (countryString != null) {
61
+ cardFormViewBinding.countryLayout.setSelectedCountryCode(CountryCode(countryString))
62
+ cardFormViewBinding.countryLayout.updateUiForCountryEntered(CountryCode(countryString))
56
63
  }
64
+ setPostalCodeFilter()
57
65
  }
58
66
 
59
67
  fun setPlaceHolders(value: ReadableMap) {
@@ -254,6 +262,29 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) {
254
262
  }
255
263
  }
256
264
 
265
+ private fun setPostalCodeFilter() {
266
+ cardFormViewBinding.postalCode.filters = arrayOf(
267
+ *cardFormViewBinding.postalCode.filters,
268
+ createPostalCodeInputFilter()
269
+ )
270
+ }
271
+
272
+ private fun createPostalCodeInputFilter(): InputFilter {
273
+ return InputFilter { charSequence, start, end, _, _, _ ->
274
+ if (cardFormViewBinding.countryLayout.getSelectedCountryCode() == CountryCode.US) {
275
+ // Rely on CardFormView's built-in US postal code filter
276
+ return@InputFilter null
277
+ }
278
+
279
+ for (i in start until end) {
280
+ if (!PostalCodeUtilities.isValidGlobalPostalCodeCharacter(charSequence[i])) {
281
+ return@InputFilter ""
282
+ }
283
+ }
284
+ return@InputFilter null
285
+ }
286
+ }
287
+
257
288
  override fun requestLayout() {
258
289
  super.requestLayout()
259
290
  post(mLayoutRunnable)
@@ -9,6 +9,11 @@ import androidx.appcompat.app.AppCompatActivity
9
9
  import androidx.fragment.app.Fragment
10
10
  import com.facebook.react.bridge.Promise
11
11
  import com.facebook.react.bridge.ReactApplicationContext
12
+ import com.reactnativestripesdk.utils.*
13
+ import com.reactnativestripesdk.utils.createError
14
+ import com.reactnativestripesdk.utils.createResult
15
+ import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
16
+ import com.reactnativestripesdk.utils.mapFromSetupIntentResult
12
17
  import com.stripe.android.model.PaymentIntent
13
18
  import com.stripe.android.model.SetupIntent
14
19
  import com.stripe.android.model.StripeIntent
@@ -78,7 +83,11 @@ class CollectBankAccountLauncherFragment(
78
83
  promise.resolve(createError(ErrorType.Failed.toString(), result.error))
79
84
  }
80
85
  }
81
- (context.currentActivity as? AppCompatActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
86
+ removeFragment(context)
82
87
  }
83
88
  }
89
+
90
+ companion object {
91
+ const val TAG = "collect_bank_account_launcher_fragment"
92
+ }
84
93
  }
@@ -0,0 +1,284 @@
1
+ package com.reactnativestripesdk
2
+
3
+ import android.os.Bundle
4
+ import android.view.LayoutInflater
5
+ import android.view.View
6
+ import android.view.ViewGroup
7
+ import android.widget.FrameLayout
8
+ import androidx.appcompat.app.AppCompatActivity
9
+ import androidx.fragment.app.Fragment
10
+ import com.facebook.react.bridge.*
11
+ import com.reactnativestripesdk.utils.*
12
+ import com.reactnativestripesdk.utils.createError
13
+ import com.reactnativestripesdk.utils.createMissingActivityError
14
+ import com.reactnativestripesdk.utils.createResult
15
+ import com.reactnativestripesdk.utils.mapFromToken
16
+ import com.stripe.android.financialconnections.FinancialConnectionsSheet
17
+ import com.stripe.android.financialconnections.FinancialConnectionsSheetForTokenResult
18
+ import com.stripe.android.financialconnections.FinancialConnectionsSheetResult
19
+ import com.stripe.android.financialconnections.FinancialConnectionsSheetResultCallback
20
+ import com.stripe.android.financialconnections.model.*
21
+
22
+ class FinancialConnectionsSheetFragment : Fragment() {
23
+ enum class Mode {
24
+ ForToken, ForSession
25
+ }
26
+
27
+ private lateinit var promise: Promise
28
+ private lateinit var context: ReactApplicationContext
29
+ private lateinit var clientSecret: String
30
+ private lateinit var publishableKey: String
31
+ private lateinit var mode: Mode
32
+
33
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
34
+ savedInstanceState: Bundle?): View {
35
+ return FrameLayout(requireActivity()).also {
36
+ it.visibility = View.GONE
37
+ }
38
+ }
39
+
40
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
41
+ when (mode) {
42
+ Mode.ForToken -> {
43
+ FinancialConnectionsSheet.createForBankAccountToken(
44
+ this,
45
+ ::onFinancialConnectionsSheetForTokenResult
46
+ ).present(
47
+ configuration = FinancialConnectionsSheet.Configuration(
48
+ financialConnectionsSessionClientSecret = clientSecret,
49
+ publishableKey = publishableKey
50
+ )
51
+ )
52
+ }
53
+ Mode.ForSession -> {
54
+ FinancialConnectionsSheet.create(
55
+ this,
56
+ ::onFinancialConnectionsSheetForDataResult
57
+ ).present(
58
+ configuration = FinancialConnectionsSheet.Configuration(
59
+ financialConnectionsSessionClientSecret = clientSecret,
60
+ publishableKey = publishableKey
61
+ )
62
+ )
63
+ }
64
+ }
65
+ }
66
+
67
+ private fun onFinancialConnectionsSheetForTokenResult(result: FinancialConnectionsSheetForTokenResult) {
68
+ when(result) {
69
+ is FinancialConnectionsSheetForTokenResult.Canceled -> {
70
+ promise.resolve(
71
+ createError(ErrorType.Canceled.toString(), "The flow has been canceled")
72
+ )
73
+ }
74
+ is FinancialConnectionsSheetForTokenResult.Failed -> {
75
+ promise.resolve(
76
+ createError(ErrorType.Failed.toString(), result.error)
77
+ )
78
+ }
79
+ is FinancialConnectionsSheetForTokenResult.Completed -> {
80
+ promise.resolve(createTokenResult(result))
81
+ (context.currentActivity as? AppCompatActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
82
+ }
83
+ }
84
+ }
85
+
86
+ private fun onFinancialConnectionsSheetForDataResult(result: FinancialConnectionsSheetResult) {
87
+ when(result) {
88
+ is FinancialConnectionsSheetResult.Canceled -> {
89
+ promise.resolve(
90
+ createError(ErrorType.Canceled.toString(), "The flow has been canceled")
91
+ )
92
+ }
93
+ is FinancialConnectionsSheetResult.Failed -> {
94
+ promise.resolve(
95
+ createError(ErrorType.Failed.toString(), result.error)
96
+ )
97
+ }
98
+ is FinancialConnectionsSheetResult.Completed -> {
99
+ promise.resolve(
100
+ WritableNativeMap().also {
101
+ it.putMap("session", mapFromSession(result.financialConnectionsSession))
102
+ }
103
+ )
104
+ (context.currentActivity as? AppCompatActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
105
+ }
106
+ }
107
+ }
108
+
109
+ fun presentFinancialConnectionsSheet(clientSecret: String, mode: Mode, publishableKey: String, promise: Promise, context: ReactApplicationContext) {
110
+ this.promise = promise
111
+ this.context = context
112
+ this.clientSecret = clientSecret
113
+ this.publishableKey = publishableKey
114
+ this.mode = mode
115
+
116
+ (context.currentActivity as? AppCompatActivity)?.let {
117
+ attemptToCleanupPreviousFragment(it)
118
+ commitFragmentAndStartFlow(it)
119
+ } ?: run {
120
+ promise.resolve(createMissingActivityError())
121
+ return
122
+ }
123
+ }
124
+
125
+ private fun attemptToCleanupPreviousFragment(currentActivity: AppCompatActivity) {
126
+ currentActivity.supportFragmentManager.beginTransaction()
127
+ .remove(this)
128
+ .commitAllowingStateLoss()
129
+ }
130
+
131
+ private fun commitFragmentAndStartFlow(currentActivity: AppCompatActivity) {
132
+ try {
133
+ currentActivity.supportFragmentManager.beginTransaction()
134
+ .add(this, "financial_connections_sheet_launch_fragment")
135
+ .commit()
136
+ } catch (error: IllegalStateException) {
137
+ promise.resolve(createError(ErrorType.Failed.toString(), error.message))
138
+ }
139
+ }
140
+
141
+ companion object {
142
+ private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap {
143
+ return WritableNativeMap().also {
144
+ it.putMap("session", mapFromSession(result.financialConnectionsSession))
145
+ it.putMap("token", mapFromToken(result.token))
146
+ }
147
+ }
148
+
149
+ private fun mapFromSession(financialConnectionsSession: FinancialConnectionsSession): WritableMap {
150
+ val session = WritableNativeMap()
151
+ session.putString("id", financialConnectionsSession.id)
152
+ session.putString("clientSecret", financialConnectionsSession.clientSecret)
153
+ session.putBoolean("livemode", financialConnectionsSession.livemode)
154
+ session.putArray("accounts", mapFromAccountsList(financialConnectionsSession.accounts))
155
+ return session
156
+ }
157
+
158
+ private fun mapFromAccountsList(accounts: FinancialConnectionsAccountList): ReadableArray {
159
+ val results: WritableArray = Arguments.createArray()
160
+ for (account in accounts.data) {
161
+ val map = WritableNativeMap()
162
+ map.putString("id", account.id)
163
+ map.putBoolean("livemode", account.livemode)
164
+ map.putString("displayName", account.displayName)
165
+ map.putString("status", mapFromStatus(account.status))
166
+ map.putString("institutionName", account.institutionName)
167
+ map.putString("last4", account.last4)
168
+ map.putDouble("created", account.created * 1000.0)
169
+ map.putMap("balance", mapFromAccountBalance(account.balance))
170
+ map.putMap("balanceRefresh", mapFromAccountBalanceRefresh(account.balanceRefresh))
171
+ map.putString("category", mapFromCategory(account.category))
172
+ map.putString("subcategory", mapFromSubcategory(account.subcategory))
173
+ map.putArray("permissions", (account.permissions?.map { permission -> mapFromPermission(permission) })?.toReadableArray())
174
+ map.putArray("supportedPaymentMethodTypes", (account.supportedPaymentMethodTypes.map { type -> mapFromSupportedPaymentMethodTypes(type) }).toReadableArray())
175
+ results.pushMap(map)
176
+ }
177
+ return results
178
+ }
179
+
180
+ private fun mapFromAccountBalance(balance: Balance?): WritableMap? {
181
+ if (balance == null) {
182
+ return null
183
+ }
184
+ val map = WritableNativeMap()
185
+ map.putDouble("asOf", balance.asOf * 1000.0)
186
+ map.putString("type", mapFromBalanceType(balance.type))
187
+ map.putMap("current", balance.current as ReadableMap)
188
+ WritableNativeMap().also {
189
+ it.putMap("available", balance.cash?.available as ReadableMap)
190
+ map.putMap("cash", it)
191
+ }
192
+ WritableNativeMap().also {
193
+ it.putMap("used", balance.credit?.used as ReadableMap)
194
+ map.putMap("credit", it)
195
+ }
196
+ return map
197
+ }
198
+
199
+ private fun mapFromAccountBalanceRefresh(balanceRefresh: BalanceRefresh?): WritableMap? {
200
+ if (balanceRefresh == null) {
201
+ return null
202
+ }
203
+ val map = WritableNativeMap()
204
+ map.putString("status", mapFromBalanceRefreshStatus(balanceRefresh.status))
205
+ map.putDouble("lastAttemptedAt", balanceRefresh.lastAttemptedAt * 1000.0)
206
+ return map
207
+ }
208
+
209
+ private fun mapFromStatus(status: FinancialConnectionsAccount.Status): String {
210
+ return when (status) {
211
+ FinancialConnectionsAccount.Status.ACTIVE -> "active"
212
+ FinancialConnectionsAccount.Status.DISCONNECTED -> "disconnected"
213
+ FinancialConnectionsAccount.Status.INACTIVE -> "inactive"
214
+ FinancialConnectionsAccount.Status.UNKNOWN -> "unparsable"
215
+ }
216
+ }
217
+
218
+ private fun mapFromCategory(category: FinancialConnectionsAccount.Category): String {
219
+ return when (category) {
220
+ FinancialConnectionsAccount.Category.CASH -> "cash"
221
+ FinancialConnectionsAccount.Category.CREDIT -> "credit"
222
+ FinancialConnectionsAccount.Category.INVESTMENT -> "investment"
223
+ FinancialConnectionsAccount.Category.OTHER -> "other"
224
+ FinancialConnectionsAccount.Category.UNKNOWN -> "unparsable"
225
+ }
226
+ }
227
+
228
+ private fun mapFromSubcategory(subcategory: FinancialConnectionsAccount.Subcategory): String {
229
+ return when (subcategory) {
230
+ FinancialConnectionsAccount.Subcategory.CHECKING -> "checking"
231
+ FinancialConnectionsAccount.Subcategory.CREDIT_CARD -> "creditCard"
232
+ FinancialConnectionsAccount.Subcategory.LINE_OF_CREDIT -> "lineOfCredit"
233
+ FinancialConnectionsAccount.Subcategory.MORTGAGE -> "mortgage"
234
+ FinancialConnectionsAccount.Subcategory.OTHER -> "other"
235
+ FinancialConnectionsAccount.Subcategory.SAVINGS -> "savings"
236
+ FinancialConnectionsAccount.Subcategory.UNKNOWN -> "unparsable"
237
+ }
238
+ }
239
+
240
+ private fun mapFromPermission(permission: FinancialConnectionsAccount.Permissions): String {
241
+ return when (permission) {
242
+ FinancialConnectionsAccount.Permissions.PAYMENT_METHOD -> "paymentMethod"
243
+ FinancialConnectionsAccount.Permissions.BALANCES -> "balances"
244
+ FinancialConnectionsAccount.Permissions.OWNERSHIP -> "ownership"
245
+ FinancialConnectionsAccount.Permissions.TRANSACTIONS -> "transactions"
246
+ FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
247
+ }
248
+ }
249
+
250
+ private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String {
251
+ return when (type) {
252
+ FinancialConnectionsAccount.SupportedPaymentMethodTypes.US_BANK_ACCOUNT -> "usBankAccount"
253
+ FinancialConnectionsAccount.SupportedPaymentMethodTypes.LINK -> "link"
254
+ FinancialConnectionsAccount.SupportedPaymentMethodTypes.UNKNOWN -> "unparsable"
255
+ }
256
+ }
257
+
258
+ private fun mapFromBalanceType(type: Balance.Type): String {
259
+ return when (type) {
260
+ Balance.Type.CASH -> "cash"
261
+ Balance.Type.CREDIT -> "credit"
262
+ Balance.Type.UNKNOWN -> "unparsable"
263
+ }
264
+ }
265
+
266
+ private fun mapFromBalanceRefreshStatus(status: BalanceRefresh.BalanceRefreshStatus?): String {
267
+ return when (status) {
268
+ BalanceRefresh.BalanceRefreshStatus.SUCCEEDED -> "succeeded"
269
+ BalanceRefresh.BalanceRefreshStatus.FAILED -> "failed"
270
+ BalanceRefresh.BalanceRefreshStatus.PENDING -> "pending"
271
+ BalanceRefresh.BalanceRefreshStatus.UNKNOWN -> "unparsable"
272
+ null -> "null"
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ fun List<String>.toReadableArray(): ReadableArray {
279
+ val results: WritableArray = Arguments.createArray()
280
+ for (s in this) {
281
+ results.pushString(s)
282
+ }
283
+ return results
284
+ }
@@ -1,5 +1,6 @@
1
1
  package com.reactnativestripesdk
2
2
 
3
+ import android.content.res.Configuration
3
4
  import android.view.LayoutInflater
4
5
  import android.widget.FrameLayout
5
6
  import com.facebook.react.uimanager.ThemedReactContext
@@ -8,13 +9,17 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
8
9
  private var buttonType: String? = null
9
10
 
10
11
  fun initialize() {
11
- val type = when (buttonType) {
12
- "pay" -> R.layout.pay_with_googlepay_button_no_shadow
13
- "pay_shadow" -> R.layout.pay_with_googlepay_button
14
- "standard_shadow" -> R.layout.googlepay_button
15
- "standard" -> R.layout.googlepay_button_no_shadow
16
- else -> R.layout.googlepay_button
17
- }
12
+ val type =
13
+ when (buttonType) {
14
+ "pay" -> R.layout.pay_with_googlepay_button_no_shadow
15
+ "pay_dark" -> R.layout.pay_with_googlepay_button_dark
16
+ "pay_shadow" -> R.layout.pay_with_googlepay_button
17
+ "standard" -> R.layout.googlepay_button_no_shadow
18
+ "standard_dark" -> R.layout.googlepay_button_dark
19
+ "standard_shadow" -> R.layout.googlepay_button
20
+ else -> if (isNightMode()) R.layout.googlepay_button_dark else R.layout.googlepay_button
21
+ }
22
+
18
23
  val button = LayoutInflater.from(context).inflate(
19
24
  type, null
20
25
  )
@@ -25,4 +30,9 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout
25
30
  fun setType(type: String) {
26
31
  buttonType = type
27
32
  }
33
+
34
+ private fun isNightMode(): Boolean {
35
+ val nightModeFlags: Int = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
36
+ return nightModeFlags == Configuration.UI_MODE_NIGHT_YES
37
+ }
28
38
  }
@@ -8,6 +8,10 @@ import android.widget.FrameLayout
8
8
  import androidx.fragment.app.Fragment
9
9
  import com.facebook.react.bridge.Promise
10
10
  import com.facebook.react.bridge.WritableNativeMap
11
+ import com.reactnativestripesdk.utils.GooglePayErrorType
12
+ import com.reactnativestripesdk.utils.createError
13
+ import com.reactnativestripesdk.utils.createResult
14
+ import com.reactnativestripesdk.utils.mapFromPaymentMethod
11
15
  import com.stripe.android.googlepaylauncher.GooglePayEnvironment
12
16
  import com.stripe.android.googlepaylauncher.GooglePayLauncher
13
17
  import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
@@ -200,4 +204,8 @@ class GooglePayFragment(private val initPromise: Promise) : Fragment() {
200
204
  isPhoneNumberRequired = isPhoneNumberRequired
201
205
  )
202
206
  }
207
+
208
+ companion object {
209
+ const val TAG = "google_pay_launch_fragment"
210
+ }
203
211
  }
@@ -5,10 +5,10 @@ import android.view.LayoutInflater
5
5
  import android.view.View
6
6
  import android.view.ViewGroup
7
7
  import android.widget.FrameLayout
8
- import androidx.appcompat.app.AppCompatActivity
9
8
  import androidx.fragment.app.Fragment
10
9
  import com.facebook.react.bridge.Promise
11
10
  import com.facebook.react.bridge.ReactApplicationContext
11
+ import com.reactnativestripesdk.utils.removeFragment
12
12
  import com.stripe.android.googlepaylauncher.GooglePayEnvironment
13
13
  import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
14
14
 
@@ -37,9 +37,13 @@ class GooglePayPaymentMethodLauncherFragment(
37
37
  ),
38
38
  readyCallback = {
39
39
  promise.resolve(it)
40
- (context.currentActivity as? AppCompatActivity)?.supportFragmentManager?.beginTransaction()?.remove(this)?.commitAllowingStateLoss()
40
+ removeFragment(context)
41
41
  },
42
42
  resultCallback = {}
43
43
  )
44
44
  }
45
+
46
+ companion object {
47
+ const val TAG = "google_pay_support_fragment"
48
+ }
45
49
  }