@stripe/stripe-react-native 0.56.0 → 0.57.1
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.
- package/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +24 -20
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +28 -32
- package/android/src/main/java/com/reactnativestripesdk/{CollectBankAccountLauncherFragment.kt → CollectBankAccountLauncherManager.kt} +23 -44
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +4 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +52 -132
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +0 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/{FinancialConnectionsSheetFragment.kt → FinancialConnectionsSheetManager.kt} +43 -92
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +107 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt +37 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/{PaymentLauncherFragment.kt → PaymentLauncherManager.kt} +40 -77
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +11 -20
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +409 -483
- package/android/src/main/java/com/reactnativestripesdk/{PaymentSheetFragment.kt → PaymentSheetManager.kt} +65 -300
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +227 -232
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +78 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +52 -39
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/{CustomerSheetFragment.kt → CustomerSheetManager.kt} +64 -99
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -3
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +87 -11
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +178 -185
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeUIManager.kt +62 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +26 -26
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +212 -75
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -41
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +16 -18
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +31 -26
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +51 -42
- package/ios/StripeSdkImpl.swift +919 -191
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +3 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentIntent.d.ts +1 -9
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +2 -8
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +24 -12
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +22 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentIntent.ts +0 -10
- package/src/types/PaymentMethod.ts +0 -9
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +21 -8
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -703
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -18
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +0 -146
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +0 -68
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +0 -102
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +0 -52
|
@@ -7,6 +7,7 @@ import android.content.Intent
|
|
|
7
7
|
import android.os.Bundle
|
|
8
8
|
import android.util.Log
|
|
9
9
|
import android.view.ViewGroup
|
|
10
|
+
import androidx.browser.customtabs.CustomTabsIntent
|
|
10
11
|
import androidx.fragment.app.FragmentActivity
|
|
11
12
|
import com.facebook.react.ReactActivity
|
|
12
13
|
import com.facebook.react.bridge.Arguments
|
|
@@ -18,23 +19,23 @@ import com.facebook.react.bridge.ReadableArray
|
|
|
18
19
|
import com.facebook.react.bridge.ReadableMap
|
|
19
20
|
import com.facebook.react.bridge.UiThreadUtil
|
|
20
21
|
import com.facebook.react.bridge.WritableMap
|
|
21
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
22
22
|
import com.facebook.react.module.annotations.ReactModule
|
|
23
|
-
import com.reactnativestripesdk.addresssheet.
|
|
24
|
-
import com.reactnativestripesdk.customersheet.
|
|
23
|
+
import com.reactnativestripesdk.addresssheet.AddressLauncherManager
|
|
24
|
+
import com.reactnativestripesdk.customersheet.CustomerSheetManager
|
|
25
25
|
import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
|
|
26
26
|
import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
|
|
27
27
|
import com.reactnativestripesdk.utils.CreateTokenErrorType
|
|
28
28
|
import com.reactnativestripesdk.utils.ErrorType
|
|
29
29
|
import com.reactnativestripesdk.utils.GooglePayErrorType
|
|
30
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
30
31
|
import com.reactnativestripesdk.utils.createCanAddCardResult
|
|
31
32
|
import com.reactnativestripesdk.utils.createError
|
|
32
33
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
33
34
|
import com.reactnativestripesdk.utils.createMissingInitError
|
|
34
35
|
import com.reactnativestripesdk.utils.createResult
|
|
35
36
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
36
|
-
import com.reactnativestripesdk.utils.
|
|
37
|
-
import com.reactnativestripesdk.utils.
|
|
37
|
+
import com.reactnativestripesdk.utils.getIntOrNull
|
|
38
|
+
import com.reactnativestripesdk.utils.getLongOrNull
|
|
38
39
|
import com.reactnativestripesdk.utils.getValOr
|
|
39
40
|
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
40
41
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
@@ -46,8 +47,6 @@ import com.reactnativestripesdk.utils.mapToPaymentMethodType
|
|
|
46
47
|
import com.reactnativestripesdk.utils.mapToReturnURL
|
|
47
48
|
import com.reactnativestripesdk.utils.mapToShippingDetails
|
|
48
49
|
import com.reactnativestripesdk.utils.mapToUICustomization
|
|
49
|
-
import com.reactnativestripesdk.utils.removeFragment
|
|
50
|
-
import com.reactnativestripesdk.utils.toBundleObject
|
|
51
50
|
import com.stripe.android.ApiResultCallback
|
|
52
51
|
import com.stripe.android.GooglePayJsonFactory
|
|
53
52
|
import com.stripe.android.PaymentAuthConfig
|
|
@@ -55,6 +54,7 @@ import com.stripe.android.PaymentConfiguration
|
|
|
55
54
|
import com.stripe.android.Stripe
|
|
56
55
|
import com.stripe.android.core.ApiVersion
|
|
57
56
|
import com.stripe.android.core.AppInfo
|
|
57
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
58
58
|
import com.stripe.android.customersheet.CustomerSheet
|
|
59
59
|
import com.stripe.android.googlepaylauncher.GooglePayLauncher
|
|
60
60
|
import com.stripe.android.model.BankAccountTokenParams
|
|
@@ -66,7 +66,6 @@ import com.stripe.android.model.PaymentMethod
|
|
|
66
66
|
import com.stripe.android.model.SetupIntent
|
|
67
67
|
import com.stripe.android.model.Token
|
|
68
68
|
import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
|
|
69
|
-
import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
|
|
70
69
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
71
70
|
import kotlinx.coroutines.CompletableDeferred
|
|
72
71
|
import kotlinx.coroutines.CoroutineScope
|
|
@@ -75,6 +74,7 @@ import kotlinx.coroutines.launch
|
|
|
75
74
|
import org.json.JSONObject
|
|
76
75
|
|
|
77
76
|
@ReactModule(name = StripeSdkModule.NAME)
|
|
77
|
+
@OptIn(ReactNativeSdkInternal::class)
|
|
78
78
|
class StripeSdkModule(
|
|
79
79
|
reactContext: ReactApplicationContext,
|
|
80
80
|
) : NativeStripeSdkModuleSpec(reactContext) {
|
|
@@ -89,11 +89,15 @@ class StripeSdkModule(
|
|
|
89
89
|
private var createPlatformPayPaymentMethodPromise: Promise? = null
|
|
90
90
|
private var platformPayUsesDeprecatedTokenFlow = false
|
|
91
91
|
|
|
92
|
-
private
|
|
93
|
-
private var
|
|
94
|
-
private var
|
|
92
|
+
private val stripeUIManagers = mutableListOf<StripeUIManager>()
|
|
93
|
+
private var paymentSheetManager: PaymentSheetManager? = null
|
|
94
|
+
private var paymentLauncherManager: PaymentLauncherManager? = null
|
|
95
|
+
private var collectBankAccountLauncherManager: CollectBankAccountLauncherManager? = null
|
|
96
|
+
private var financialConnectionsSheetManager: FinancialConnectionsSheetManager? = null
|
|
97
|
+
private var googlePayLauncherManager: GooglePayLauncherManager? = null
|
|
98
|
+
private var googlePayPaymentMethodLauncherManager: GooglePayPaymentMethodLauncherManager? = null
|
|
95
99
|
|
|
96
|
-
private var
|
|
100
|
+
private var customerSheetManager: CustomerSheetManager? = null
|
|
97
101
|
|
|
98
102
|
internal var embeddedIntentCreationCallback = CompletableDeferred<ReadableMap>()
|
|
99
103
|
internal var embeddedConfirmationTokenCreationCallback = CompletableDeferred<ReadableMap>()
|
|
@@ -104,20 +108,6 @@ class StripeSdkModule(
|
|
|
104
108
|
|
|
105
109
|
val eventEmitter: EventEmitterCompat by lazy { EventEmitterCompat(reactApplicationContext) }
|
|
106
110
|
|
|
107
|
-
// If you create a new Fragment, you must put the tag here, otherwise result callbacks for that
|
|
108
|
-
// Fragment will not work on RN < 0.65
|
|
109
|
-
private val allStripeFragmentTags: List<String>
|
|
110
|
-
get() =
|
|
111
|
-
listOf(
|
|
112
|
-
PaymentSheetFragment.TAG,
|
|
113
|
-
PaymentLauncherFragment.TAG,
|
|
114
|
-
CollectBankAccountLauncherFragment.TAG,
|
|
115
|
-
FinancialConnectionsSheetFragment.TAG,
|
|
116
|
-
AddressLauncherFragment.TAG,
|
|
117
|
-
GooglePayLauncherFragment.TAG,
|
|
118
|
-
CustomerSheetFragment.TAG,
|
|
119
|
-
)
|
|
120
|
-
|
|
121
111
|
private val mActivityEventListener =
|
|
122
112
|
object : BaseActivityEventListener() {
|
|
123
113
|
override fun onActivityResult(
|
|
@@ -145,10 +135,6 @@ class StripeSdkModule(
|
|
|
145
135
|
)
|
|
146
136
|
}
|
|
147
137
|
}
|
|
148
|
-
|
|
149
|
-
else -> {
|
|
150
|
-
dispatchActivityResultsToFragments(requestCode, resultCode, data)
|
|
151
|
-
}
|
|
152
138
|
}
|
|
153
139
|
}
|
|
154
140
|
}
|
|
@@ -158,24 +144,27 @@ class StripeSdkModule(
|
|
|
158
144
|
reactContext.addActivityEventListener(mActivityEventListener)
|
|
159
145
|
}
|
|
160
146
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
147
|
+
override fun invalidate() {
|
|
148
|
+
super.invalidate()
|
|
149
|
+
|
|
150
|
+
stripeUIManagers.forEach { it.destroy() }
|
|
151
|
+
stripeUIManagers.clear()
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private fun registerStripeUIManager(uiManager: StripeUIManager) {
|
|
155
|
+
uiManager.create()
|
|
156
|
+
stripeUIManagers.add(uiManager)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private fun unregisterStripeUIManager(uiManager: StripeUIManager?) {
|
|
160
|
+
val uiManager = uiManager ?: return
|
|
161
|
+
uiManager.destroy()
|
|
162
|
+
stripeUIManagers.remove(uiManager)
|
|
174
163
|
}
|
|
175
164
|
|
|
176
165
|
private fun configure3dSecure(params: ReadableMap) {
|
|
177
166
|
val stripe3dsConfigBuilder = PaymentAuthConfig.Stripe3ds2Config.Builder()
|
|
178
|
-
|
|
167
|
+
params.getIntOrNull("timeout")?.let { stripe3dsConfigBuilder.setTimeout(it) }
|
|
179
168
|
val uiCustomization = mapToUICustomization(params)
|
|
180
169
|
|
|
181
170
|
PaymentAuthConfig.init(
|
|
@@ -205,18 +194,18 @@ class StripeSdkModule(
|
|
|
205
194
|
promise: Promise,
|
|
206
195
|
) {
|
|
207
196
|
val publishableKey = getValOr(params, "publishableKey", null) as String
|
|
208
|
-
val appInfo =
|
|
197
|
+
val appInfo = params.getMap("appInfo") as ReadableMap
|
|
209
198
|
this.stripeAccountId = getValOr(params, "stripeAccountId", null)
|
|
210
199
|
val urlScheme = getValOr(params, "urlScheme", null)
|
|
211
|
-
val setReturnUrlSchemeOnAndroid =
|
|
200
|
+
val setReturnUrlSchemeOnAndroid = params.getBooleanOr("setReturnUrlSchemeOnAndroid", false)
|
|
212
201
|
this.urlScheme = if (setReturnUrlSchemeOnAndroid) urlScheme else null
|
|
213
202
|
|
|
214
|
-
|
|
203
|
+
params.getMap("threeDSecureParams")?.let {
|
|
215
204
|
configure3dSecure(it)
|
|
216
205
|
}
|
|
217
206
|
|
|
218
207
|
this.publishableKey = publishableKey
|
|
219
|
-
|
|
208
|
+
AddressLauncherManager.publishableKey = publishableKey
|
|
220
209
|
|
|
221
210
|
val name = getValOr(appInfo, "name", "") as String
|
|
222
211
|
val partnerId = getValOr(appInfo, "partnerId", "")
|
|
@@ -239,28 +228,11 @@ class StripeSdkModule(
|
|
|
239
228
|
params: ReadableMap,
|
|
240
229
|
promise: Promise,
|
|
241
230
|
) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// Handle custom payment methods separately since toBundleObject cannot handle arrays of objects
|
|
247
|
-
val customPaymentMethodConfig = params.getMap("customPaymentMethodConfiguration")
|
|
248
|
-
if (customPaymentMethodConfig != null) {
|
|
249
|
-
// Store the original ReadableMap for custom payment methods
|
|
250
|
-
bundle.putSerializable("customPaymentMethodConfigurationReadableMap", customPaymentMethodConfig.toHashMap())
|
|
231
|
+
unregisterStripeUIManager(paymentSheetManager)
|
|
232
|
+
paymentSheetManager =
|
|
233
|
+
PaymentSheetManager(reactApplicationContext, params, promise).also {
|
|
234
|
+
registerStripeUIManager(it)
|
|
251
235
|
}
|
|
252
|
-
|
|
253
|
-
paymentSheetFragment =
|
|
254
|
-
PaymentSheetFragment.create(reactApplicationContext, bundle, promise)
|
|
255
|
-
try {
|
|
256
|
-
activity.supportFragmentManager
|
|
257
|
-
.beginTransaction()
|
|
258
|
-
.add(paymentSheetFragment!!, PaymentSheetFragment.TAG)
|
|
259
|
-
.commit()
|
|
260
|
-
} catch (error: IllegalStateException) {
|
|
261
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
236
|
}
|
|
265
237
|
|
|
266
238
|
@ReactMethod
|
|
@@ -268,30 +240,30 @@ class StripeSdkModule(
|
|
|
268
240
|
options: ReadableMap,
|
|
269
241
|
promise: Promise,
|
|
270
242
|
) {
|
|
271
|
-
if (
|
|
272
|
-
promise.resolve(
|
|
243
|
+
if (paymentSheetManager == null) {
|
|
244
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
273
245
|
return
|
|
274
246
|
}
|
|
275
247
|
|
|
276
|
-
val
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
248
|
+
val timeout = options.getLongOrNull("timeout")
|
|
249
|
+
if (timeout != null) {
|
|
250
|
+
paymentSheetManager?.presentWithTimeout(
|
|
251
|
+
timeout,
|
|
280
252
|
promise,
|
|
281
253
|
)
|
|
282
254
|
} else {
|
|
283
|
-
|
|
255
|
+
paymentSheetManager?.present(promise)
|
|
284
256
|
}
|
|
285
257
|
}
|
|
286
258
|
|
|
287
259
|
@ReactMethod
|
|
288
260
|
override fun confirmPaymentSheetPayment(promise: Promise) {
|
|
289
|
-
if (
|
|
290
|
-
promise.resolve(
|
|
261
|
+
if (paymentSheetManager == null) {
|
|
262
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
291
263
|
return
|
|
292
264
|
}
|
|
293
265
|
|
|
294
|
-
|
|
266
|
+
paymentSheetManager?.confirmPayment(promise)
|
|
295
267
|
}
|
|
296
268
|
|
|
297
269
|
@ReactMethod
|
|
@@ -307,12 +279,12 @@ class StripeSdkModule(
|
|
|
307
279
|
) {
|
|
308
280
|
embeddedIntentCreationCallback.complete(params)
|
|
309
281
|
|
|
310
|
-
if (
|
|
311
|
-
promise.resolve(
|
|
282
|
+
if (paymentSheetManager == null) {
|
|
283
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
312
284
|
return
|
|
313
285
|
}
|
|
314
286
|
|
|
315
|
-
|
|
287
|
+
paymentSheetManager?.paymentSheetIntentCreationCallback?.complete(params)
|
|
316
288
|
}
|
|
317
289
|
|
|
318
290
|
@ReactMethod
|
|
@@ -335,12 +307,12 @@ class StripeSdkModule(
|
|
|
335
307
|
embeddedConfirmationTokenCreationCallback.complete(params)
|
|
336
308
|
paymentSheetConfirmationTokenCreationCallback.complete(params)
|
|
337
309
|
|
|
338
|
-
if (
|
|
339
|
-
promise.resolve(
|
|
310
|
+
if (paymentSheetManager == null) {
|
|
311
|
+
promise.resolve(PaymentSheetManager.createMissingInitError())
|
|
340
312
|
return
|
|
341
313
|
}
|
|
342
314
|
|
|
343
|
-
|
|
315
|
+
paymentSheetManager?.paymentSheetConfirmationTokenCreationCallback?.complete(params)
|
|
344
316
|
}
|
|
345
317
|
|
|
346
318
|
@ReactMethod
|
|
@@ -359,7 +331,7 @@ class StripeSdkModule(
|
|
|
359
331
|
)
|
|
360
332
|
return
|
|
361
333
|
}
|
|
362
|
-
val paymentMethodData =
|
|
334
|
+
val paymentMethodData = data.getMap("paymentMethodData")
|
|
363
335
|
val factory =
|
|
364
336
|
PaymentMethodCreateParamsFactory(paymentMethodData, options, cardFieldView, cardFormView)
|
|
365
337
|
try {
|
|
@@ -494,7 +466,7 @@ class StripeSdkModule(
|
|
|
494
466
|
}
|
|
495
467
|
|
|
496
468
|
val cardAddress = cardFieldView?.cardAddress ?: cardFormView?.cardAddress
|
|
497
|
-
val address =
|
|
469
|
+
val address = params.getMap("address")
|
|
498
470
|
val cardParams =
|
|
499
471
|
CardParams(
|
|
500
472
|
number = cardParamsMap["number"] as String,
|
|
@@ -531,7 +503,7 @@ class StripeSdkModule(
|
|
|
531
503
|
object : ApiResultCallback<Token> {
|
|
532
504
|
override fun onSuccess(result: Token) {
|
|
533
505
|
val tokenId = result.id
|
|
534
|
-
val res =
|
|
506
|
+
val res = Arguments.createMap()
|
|
535
507
|
res.putString("tokenId", tokenId)
|
|
536
508
|
promise.resolve(res)
|
|
537
509
|
}
|
|
@@ -549,15 +521,19 @@ class StripeSdkModule(
|
|
|
549
521
|
returnUrl: String?,
|
|
550
522
|
promise: Promise,
|
|
551
523
|
) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
524
|
+
unregisterStripeUIManager(paymentSheetManager)
|
|
525
|
+
paymentLauncherManager =
|
|
526
|
+
PaymentLauncherManager
|
|
527
|
+
.forNextActionPayment(
|
|
528
|
+
context = reactApplicationContext,
|
|
529
|
+
stripe,
|
|
530
|
+
publishableKey,
|
|
531
|
+
stripeAccountId,
|
|
532
|
+
paymentIntentClientSecret,
|
|
533
|
+
).also {
|
|
534
|
+
registerStripeUIManager(it)
|
|
535
|
+
it.present(promise)
|
|
536
|
+
}
|
|
561
537
|
}
|
|
562
538
|
|
|
563
539
|
@ReactMethod
|
|
@@ -566,15 +542,19 @@ class StripeSdkModule(
|
|
|
566
542
|
returnUrl: String?,
|
|
567
543
|
promise: Promise,
|
|
568
544
|
) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
545
|
+
unregisterStripeUIManager(paymentLauncherManager)
|
|
546
|
+
paymentLauncherManager =
|
|
547
|
+
PaymentLauncherManager
|
|
548
|
+
.forNextActionSetup(
|
|
549
|
+
context = reactApplicationContext,
|
|
550
|
+
stripe,
|
|
551
|
+
publishableKey,
|
|
552
|
+
stripeAccountId,
|
|
553
|
+
setupIntentClientSecret,
|
|
554
|
+
).also {
|
|
555
|
+
registerStripeUIManager(it)
|
|
556
|
+
it.present(promise)
|
|
557
|
+
}
|
|
578
558
|
}
|
|
579
559
|
|
|
580
560
|
// TODO: Uncomment when WeChat is re-enabled in stripe-ios
|
|
@@ -603,7 +583,7 @@ class StripeSdkModule(
|
|
|
603
583
|
options: ReadableMap?,
|
|
604
584
|
promise: Promise,
|
|
605
585
|
) {
|
|
606
|
-
val paymentMethodData =
|
|
586
|
+
val paymentMethodData = params?.getMap("paymentMethodData")
|
|
607
587
|
val paymentMethodType =
|
|
608
588
|
if (params != null) {
|
|
609
589
|
mapToPaymentMethodType(params.getString("paymentMethodType")) ?: run {
|
|
@@ -643,17 +623,21 @@ class StripeSdkModule(
|
|
|
643
623
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
644
624
|
}
|
|
645
625
|
confirmParams.shipping =
|
|
646
|
-
mapToShippingDetails(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
626
|
+
mapToShippingDetails(paymentMethodData?.getMap("shippingDetails"))
|
|
627
|
+
unregisterStripeUIManager(paymentLauncherManager)
|
|
628
|
+
paymentLauncherManager =
|
|
629
|
+
PaymentLauncherManager
|
|
630
|
+
.forPayment(
|
|
631
|
+
context = reactApplicationContext,
|
|
632
|
+
stripe,
|
|
633
|
+
publishableKey,
|
|
634
|
+
stripeAccountId,
|
|
635
|
+
paymentIntentClientSecret,
|
|
636
|
+
confirmParams,
|
|
637
|
+
).also {
|
|
638
|
+
registerStripeUIManager(it)
|
|
639
|
+
it.present(promise)
|
|
640
|
+
}
|
|
657
641
|
} catch (error: PaymentMethodCreateParamsException) {
|
|
658
642
|
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
|
|
659
643
|
}
|
|
@@ -701,7 +685,7 @@ class StripeSdkModule(
|
|
|
701
685
|
|
|
702
686
|
val factory =
|
|
703
687
|
PaymentMethodCreateParamsFactory(
|
|
704
|
-
|
|
688
|
+
params.getMap("paymentMethodData"),
|
|
705
689
|
options,
|
|
706
690
|
cardFieldView,
|
|
707
691
|
cardFormView,
|
|
@@ -717,16 +701,20 @@ class StripeSdkModule(
|
|
|
717
701
|
urlScheme?.let {
|
|
718
702
|
confirmParams.returnUrl = mapToReturnURL(urlScheme)
|
|
719
703
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
704
|
+
unregisterStripeUIManager(paymentLauncherManager)
|
|
705
|
+
paymentLauncherManager =
|
|
706
|
+
PaymentLauncherManager
|
|
707
|
+
.forSetup(
|
|
708
|
+
context = reactApplicationContext,
|
|
709
|
+
stripe,
|
|
710
|
+
publishableKey,
|
|
711
|
+
stripeAccountId,
|
|
712
|
+
setupIntentClientSecret,
|
|
713
|
+
confirmParams,
|
|
714
|
+
).also {
|
|
715
|
+
registerStripeUIManager(it)
|
|
716
|
+
it.present(promise)
|
|
717
|
+
}
|
|
730
718
|
} catch (error: PaymentMethodCreateParamsException) {
|
|
731
719
|
promise.resolve(createError(ConfirmPaymentErrorType.Failed.toString(), error))
|
|
732
720
|
}
|
|
@@ -738,24 +726,16 @@ class StripeSdkModule(
|
|
|
738
726
|
promise: Promise,
|
|
739
727
|
) {
|
|
740
728
|
val googlePayParams = params?.getMap("googlePay")
|
|
741
|
-
|
|
742
|
-
|
|
729
|
+
unregisterStripeUIManager(googlePayPaymentMethodLauncherManager)
|
|
730
|
+
googlePayPaymentMethodLauncherManager =
|
|
731
|
+
GooglePayPaymentMethodLauncherManager(
|
|
743
732
|
reactApplicationContext,
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
getCurrentActivityOrResolveWithError(promise)?.let {
|
|
750
|
-
try {
|
|
751
|
-
it.supportFragmentManager
|
|
752
|
-
.beginTransaction()
|
|
753
|
-
.add(fragment, GooglePayPaymentMethodLauncherFragment.TAG)
|
|
754
|
-
.commit()
|
|
755
|
-
} catch (error: IllegalStateException) {
|
|
756
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
733
|
+
googlePayParams?.getBooleanOr("testEnv", false) ?: false,
|
|
734
|
+
googlePayParams?.getBooleanOr("existingPaymentMethodRequired", false) ?: false,
|
|
735
|
+
).also {
|
|
736
|
+
registerStripeUIManager(it)
|
|
737
|
+
it.present(promise)
|
|
757
738
|
}
|
|
758
|
-
}
|
|
759
739
|
}
|
|
760
740
|
|
|
761
741
|
@ReactMethod
|
|
@@ -781,12 +761,13 @@ class StripeSdkModule(
|
|
|
781
761
|
return
|
|
782
762
|
}
|
|
783
763
|
|
|
784
|
-
|
|
785
|
-
|
|
764
|
+
unregisterStripeUIManager(googlePayLauncherManager)
|
|
765
|
+
googlePayLauncherManager =
|
|
766
|
+
GooglePayLauncherManager(
|
|
767
|
+
reactApplicationContext,
|
|
786
768
|
clientSecret,
|
|
787
|
-
if (isPaymentIntent)
|
|
769
|
+
if (isPaymentIntent) GooglePayLauncherManager.Mode.ForPayment else GooglePayLauncherManager.Mode.ForSetup,
|
|
788
770
|
googlePayParams,
|
|
789
|
-
reactApplicationContext,
|
|
790
771
|
) { launcherResult, errorMap ->
|
|
791
772
|
if (errorMap != null) {
|
|
792
773
|
promise.resolve(errorMap)
|
|
@@ -800,7 +781,7 @@ class StripeSdkModule(
|
|
|
800
781
|
expand = listOf("payment_method"),
|
|
801
782
|
object : ApiResultCallback<PaymentIntent> {
|
|
802
783
|
override fun onError(e: Exception) {
|
|
803
|
-
promise.resolve(createResult("paymentIntent",
|
|
784
|
+
promise.resolve(createResult("paymentIntent", Arguments.createMap()))
|
|
804
785
|
}
|
|
805
786
|
|
|
806
787
|
override fun onSuccess(result: PaymentIntent) {
|
|
@@ -820,7 +801,7 @@ class StripeSdkModule(
|
|
|
820
801
|
expand = listOf("payment_method"),
|
|
821
802
|
object : ApiResultCallback<SetupIntent> {
|
|
822
803
|
override fun onError(e: Exception) {
|
|
823
|
-
promise.resolve(createResult("setupIntent",
|
|
804
|
+
promise.resolve(createResult("setupIntent", Arguments.createMap()))
|
|
824
805
|
}
|
|
825
806
|
|
|
826
807
|
override fun onSuccess(result: SetupIntent) {
|
|
@@ -850,8 +831,10 @@ class StripeSdkModule(
|
|
|
850
831
|
}
|
|
851
832
|
}
|
|
852
833
|
}
|
|
834
|
+
}.also {
|
|
835
|
+
registerStripeUIManager(it)
|
|
836
|
+
it.present()
|
|
853
837
|
}
|
|
854
|
-
}
|
|
855
838
|
}
|
|
856
839
|
|
|
857
840
|
@ReactMethod
|
|
@@ -931,7 +914,7 @@ class StripeSdkModule(
|
|
|
931
914
|
PushProvisioningProxy.isCardInWallet(it, last4) { isCardInWallet, token, error ->
|
|
932
915
|
val result: WritableMap =
|
|
933
916
|
error ?: run {
|
|
934
|
-
val map =
|
|
917
|
+
val map = Arguments.createMap()
|
|
935
918
|
map.putBoolean("isInWallet", isCardInWallet)
|
|
936
919
|
map.putMap("token", token)
|
|
937
920
|
map
|
|
@@ -948,7 +931,7 @@ class StripeSdkModule(
|
|
|
948
931
|
params: ReadableMap,
|
|
949
932
|
promise: Promise,
|
|
950
933
|
) {
|
|
951
|
-
val paymentMethodData =
|
|
934
|
+
val paymentMethodData = params.getMap("paymentMethodData")
|
|
952
935
|
val paymentMethodType = mapToPaymentMethodType(getValOr(params, "paymentMethodType", null))
|
|
953
936
|
if (paymentMethodType != PaymentMethod.Type.USBankAccount) {
|
|
954
937
|
promise.resolve(
|
|
@@ -960,7 +943,7 @@ class StripeSdkModule(
|
|
|
960
943
|
return
|
|
961
944
|
}
|
|
962
945
|
|
|
963
|
-
val billingDetails =
|
|
946
|
+
val billingDetails = paymentMethodData?.getMap("billingDetails")
|
|
964
947
|
|
|
965
948
|
val name = billingDetails?.getString("name")
|
|
966
949
|
if (name.isNullOrEmpty()) {
|
|
@@ -979,26 +962,19 @@ class StripeSdkModule(
|
|
|
979
962
|
billingDetails.getString("email"),
|
|
980
963
|
)
|
|
981
964
|
|
|
982
|
-
|
|
983
|
-
|
|
965
|
+
unregisterStripeUIManager(collectBankAccountLauncherManager)
|
|
966
|
+
collectBankAccountLauncherManager =
|
|
967
|
+
CollectBankAccountLauncherManager(
|
|
984
968
|
reactApplicationContext,
|
|
985
969
|
publishableKey,
|
|
986
970
|
stripeAccountId,
|
|
987
971
|
clientSecret,
|
|
988
972
|
isPaymentIntent,
|
|
989
973
|
collectParams,
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
try {
|
|
994
|
-
it.supportFragmentManager
|
|
995
|
-
.beginTransaction()
|
|
996
|
-
.add(collectBankAccountLauncherFragment!!, "collect_bank_account_launcher_fragment")
|
|
997
|
-
.commit()
|
|
998
|
-
} catch (error: IllegalStateException) {
|
|
999
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
974
|
+
).also {
|
|
975
|
+
registerStripeUIManager(it)
|
|
976
|
+
it.present(promise)
|
|
1000
977
|
}
|
|
1001
|
-
}
|
|
1002
978
|
}
|
|
1003
979
|
|
|
1004
980
|
@ReactMethod
|
|
@@ -1096,16 +1072,18 @@ class StripeSdkModule(
|
|
|
1096
1072
|
promise.resolve(createMissingInitError())
|
|
1097
1073
|
return
|
|
1098
1074
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1075
|
+
unregisterStripeUIManager(financialConnectionsSheetManager)
|
|
1076
|
+
financialConnectionsSheetManager =
|
|
1077
|
+
FinancialConnectionsSheetManager(
|
|
1078
|
+
reactApplicationContext,
|
|
1101
1079
|
clientSecret,
|
|
1102
|
-
|
|
1080
|
+
FinancialConnectionsSheetManager.Mode.ForToken,
|
|
1103
1081
|
publishableKey,
|
|
1104
1082
|
stripeAccountId,
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1083
|
+
).also {
|
|
1084
|
+
registerStripeUIManager(it)
|
|
1085
|
+
it.present(promise)
|
|
1086
|
+
}
|
|
1109
1087
|
}
|
|
1110
1088
|
|
|
1111
1089
|
@ReactMethod
|
|
@@ -1118,16 +1096,19 @@ class StripeSdkModule(
|
|
|
1118
1096
|
promise.resolve(createMissingInitError())
|
|
1119
1097
|
return
|
|
1120
1098
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1099
|
+
|
|
1100
|
+
unregisterStripeUIManager(financialConnectionsSheetManager)
|
|
1101
|
+
financialConnectionsSheetManager =
|
|
1102
|
+
FinancialConnectionsSheetManager(
|
|
1103
|
+
reactApplicationContext,
|
|
1123
1104
|
clientSecret,
|
|
1124
|
-
|
|
1105
|
+
FinancialConnectionsSheetManager.Mode.ForSession,
|
|
1125
1106
|
publishableKey,
|
|
1126
1107
|
stripeAccountId,
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1108
|
+
).also {
|
|
1109
|
+
registerStripeUIManager(it)
|
|
1110
|
+
it.present(promise)
|
|
1111
|
+
}
|
|
1131
1112
|
}
|
|
1132
1113
|
|
|
1133
1114
|
@ReactMethod
|
|
@@ -1141,25 +1122,11 @@ class StripeSdkModule(
|
|
|
1141
1122
|
return
|
|
1142
1123
|
}
|
|
1143
1124
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
it.context = reactApplicationContext
|
|
1149
|
-
it.initPromise = promise
|
|
1150
|
-
val bundle = toBundleObject(params)
|
|
1151
|
-
bundle.putBundle("customerAdapter", toBundleObject(customerAdapterOverrides))
|
|
1152
|
-
it.arguments = bundle
|
|
1153
|
-
}
|
|
1154
|
-
try {
|
|
1155
|
-
activity.supportFragmentManager
|
|
1156
|
-
.beginTransaction()
|
|
1157
|
-
.add(customerSheetFragment!!, CustomerSheetFragment.TAG)
|
|
1158
|
-
.commit()
|
|
1159
|
-
} catch (error: IllegalStateException) {
|
|
1160
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
1125
|
+
unregisterStripeUIManager(customerSheetManager)
|
|
1126
|
+
customerSheetManager =
|
|
1127
|
+
CustomerSheetManager(reactApplicationContext, params, customerAdapterOverrides, promise).also {
|
|
1128
|
+
registerStripeUIManager(it)
|
|
1161
1129
|
}
|
|
1162
|
-
}
|
|
1163
1130
|
}
|
|
1164
1131
|
|
|
1165
1132
|
@ReactMethod
|
|
@@ -1167,19 +1134,16 @@ class StripeSdkModule(
|
|
|
1167
1134
|
params: ReadableMap,
|
|
1168
1135
|
promise: Promise,
|
|
1169
1136
|
) {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
}
|
|
1174
|
-
customerSheetFragment?.present(timeout, promise) ?: run {
|
|
1175
|
-
promise.resolve(CustomerSheetFragment.createMissingInitError())
|
|
1137
|
+
val timeout = params.getLongOrNull("timeout")
|
|
1138
|
+
customerSheetManager?.present(promise, timeout) ?: run {
|
|
1139
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1176
1140
|
}
|
|
1177
1141
|
}
|
|
1178
1142
|
|
|
1179
1143
|
@ReactMethod
|
|
1180
1144
|
override fun retrieveCustomerSheetPaymentOptionSelection(promise: Promise) {
|
|
1181
|
-
|
|
1182
|
-
promise.resolve(
|
|
1145
|
+
customerSheetManager?.retrievePaymentOptionSelection(promise) ?: run {
|
|
1146
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1183
1147
|
}
|
|
1184
1148
|
}
|
|
1185
1149
|
|
|
@@ -1188,7 +1152,7 @@ class StripeSdkModule(
|
|
|
1188
1152
|
paymentMethodJsonObjects: ReadableArray,
|
|
1189
1153
|
promise: Promise,
|
|
1190
1154
|
) {
|
|
1191
|
-
|
|
1155
|
+
customerSheetManager?.let { fragment ->
|
|
1192
1156
|
val paymentMethods = mutableListOf<PaymentMethod>()
|
|
1193
1157
|
for (paymentMethodJson in paymentMethodJsonObjects.toArrayList()) {
|
|
1194
1158
|
PaymentMethod.fromJson(JSONObject((paymentMethodJson as HashMap<*, *>)))?.let {
|
|
@@ -1202,7 +1166,7 @@ class StripeSdkModule(
|
|
|
1202
1166
|
}
|
|
1203
1167
|
fragment.customerAdapter?.fetchPaymentMethodsCallback?.complete(paymentMethods)
|
|
1204
1168
|
} ?: run {
|
|
1205
|
-
promise.resolve(
|
|
1169
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1206
1170
|
return
|
|
1207
1171
|
}
|
|
1208
1172
|
}
|
|
@@ -1212,7 +1176,7 @@ class StripeSdkModule(
|
|
|
1212
1176
|
paymentMethodJson: ReadableMap,
|
|
1213
1177
|
promise: Promise,
|
|
1214
1178
|
) {
|
|
1215
|
-
|
|
1179
|
+
customerSheetManager?.let {
|
|
1216
1180
|
val paymentMethod =
|
|
1217
1181
|
PaymentMethod.fromJson(JSONObject(paymentMethodJson.toHashMap() as HashMap<*, *>))
|
|
1218
1182
|
if (paymentMethod == null) {
|
|
@@ -1224,7 +1188,7 @@ class StripeSdkModule(
|
|
|
1224
1188
|
}
|
|
1225
1189
|
it.customerAdapter?.attachPaymentMethodCallback?.complete(paymentMethod)
|
|
1226
1190
|
} ?: run {
|
|
1227
|
-
promise.resolve(
|
|
1191
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1228
1192
|
return
|
|
1229
1193
|
}
|
|
1230
1194
|
}
|
|
@@ -1234,7 +1198,7 @@ class StripeSdkModule(
|
|
|
1234
1198
|
paymentMethodJson: ReadableMap,
|
|
1235
1199
|
promise: Promise,
|
|
1236
1200
|
) {
|
|
1237
|
-
|
|
1201
|
+
customerSheetManager?.let {
|
|
1238
1202
|
val paymentMethod =
|
|
1239
1203
|
PaymentMethod.fromJson(JSONObject(paymentMethodJson.toHashMap() as HashMap<*, *>))
|
|
1240
1204
|
if (paymentMethod == null) {
|
|
@@ -1246,17 +1210,17 @@ class StripeSdkModule(
|
|
|
1246
1210
|
}
|
|
1247
1211
|
it.customerAdapter?.detachPaymentMethodCallback?.complete(paymentMethod)
|
|
1248
1212
|
} ?: run {
|
|
1249
|
-
promise.resolve(
|
|
1213
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1250
1214
|
return
|
|
1251
1215
|
}
|
|
1252
1216
|
}
|
|
1253
1217
|
|
|
1254
1218
|
@ReactMethod
|
|
1255
1219
|
override fun customerAdapterSetSelectedPaymentOptionCallback(promise: Promise) {
|
|
1256
|
-
|
|
1220
|
+
customerSheetManager?.let {
|
|
1257
1221
|
it.customerAdapter?.setSelectedPaymentOptionCallback?.complete(Unit)
|
|
1258
1222
|
} ?: run {
|
|
1259
|
-
promise.resolve(
|
|
1223
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1260
1224
|
return
|
|
1261
1225
|
}
|
|
1262
1226
|
}
|
|
@@ -1266,10 +1230,10 @@ class StripeSdkModule(
|
|
|
1266
1230
|
paymentOption: String?,
|
|
1267
1231
|
promise: Promise,
|
|
1268
1232
|
) {
|
|
1269
|
-
|
|
1233
|
+
customerSheetManager?.let {
|
|
1270
1234
|
it.customerAdapter?.fetchSelectedPaymentOptionCallback?.complete(paymentOption)
|
|
1271
1235
|
} ?: run {
|
|
1272
|
-
promise.resolve(
|
|
1236
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1273
1237
|
return
|
|
1274
1238
|
}
|
|
1275
1239
|
}
|
|
@@ -1279,29 +1243,27 @@ class StripeSdkModule(
|
|
|
1279
1243
|
clientSecret: String,
|
|
1280
1244
|
promise: Promise,
|
|
1281
1245
|
) {
|
|
1282
|
-
|
|
1246
|
+
customerSheetManager?.let {
|
|
1283
1247
|
it.customerAdapter?.setupIntentClientSecretForCustomerAttachCallback?.complete(clientSecret)
|
|
1284
1248
|
} ?: run {
|
|
1285
|
-
promise.resolve(
|
|
1249
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1286
1250
|
return
|
|
1287
1251
|
}
|
|
1288
1252
|
}
|
|
1289
1253
|
|
|
1290
|
-
@OptIn(ExperimentalCustomerSessionApi::class)
|
|
1291
1254
|
@ReactMethod
|
|
1292
1255
|
override fun clientSecretProviderSetupIntentClientSecretCallback(
|
|
1293
1256
|
setupIntentClientSecret: String,
|
|
1294
1257
|
promise: Promise,
|
|
1295
1258
|
) {
|
|
1296
|
-
|
|
1259
|
+
customerSheetManager?.let {
|
|
1297
1260
|
it.customerSessionProvider?.provideSetupIntentClientSecretCallback?.complete(setupIntentClientSecret)
|
|
1298
1261
|
} ?: run {
|
|
1299
|
-
promise.resolve(
|
|
1262
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1300
1263
|
return
|
|
1301
1264
|
}
|
|
1302
1265
|
}
|
|
1303
1266
|
|
|
1304
|
-
@OptIn(ExperimentalCustomerSessionApi::class)
|
|
1305
1267
|
@ReactMethod
|
|
1306
1268
|
override fun clientSecretProviderCustomerSessionClientSecretCallback(
|
|
1307
1269
|
customerSessionClientSecretJson: ReadableMap,
|
|
@@ -1318,15 +1280,15 @@ class StripeSdkModule(
|
|
|
1318
1280
|
return
|
|
1319
1281
|
}
|
|
1320
1282
|
|
|
1321
|
-
|
|
1283
|
+
customerSheetManager?.let {
|
|
1322
1284
|
it.customerSessionProvider?.providesCustomerSessionClientSecretCallback?.complete(
|
|
1323
1285
|
CustomerSheet.CustomerSessionClientSecret.create(
|
|
1324
|
-
customerId = customerId
|
|
1325
|
-
clientSecret = clientSecret
|
|
1286
|
+
customerId = customerId,
|
|
1287
|
+
clientSecret = clientSecret,
|
|
1326
1288
|
),
|
|
1327
1289
|
)
|
|
1328
1290
|
} ?: run {
|
|
1329
|
-
promise.resolve(
|
|
1291
|
+
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1330
1292
|
return
|
|
1331
1293
|
}
|
|
1332
1294
|
}
|
|
@@ -1372,6 +1334,39 @@ class StripeSdkModule(
|
|
|
1372
1334
|
// noop, iOS only
|
|
1373
1335
|
}
|
|
1374
1336
|
|
|
1337
|
+
@ReactMethod
|
|
1338
|
+
override fun openAuthenticatedWebView(
|
|
1339
|
+
id: String,
|
|
1340
|
+
url: String,
|
|
1341
|
+
promise: Promise,
|
|
1342
|
+
) {
|
|
1343
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
1344
|
+
|
|
1345
|
+
UiThreadUtil.runOnUiThread {
|
|
1346
|
+
try {
|
|
1347
|
+
val uri = android.net.Uri.parse(url)
|
|
1348
|
+
val builder =
|
|
1349
|
+
androidx.browser.customtabs.CustomTabsIntent
|
|
1350
|
+
.Builder()
|
|
1351
|
+
|
|
1352
|
+
// Set toolbar color for better UX
|
|
1353
|
+
builder.setShowTitle(true)
|
|
1354
|
+
builder.setUrlBarHidingEnabled(true)
|
|
1355
|
+
|
|
1356
|
+
val customTabsIntent = builder.build()
|
|
1357
|
+
|
|
1358
|
+
// Note: Custom Tabs doesn't have built-in redirect handling like iOS ASWebAuthenticationSession.
|
|
1359
|
+
// The redirect will be handled via deep linking when the auth server redirects to stripe-connect://
|
|
1360
|
+
// The React Native Linking module will capture the deep link and pass it back to the JS layer.
|
|
1361
|
+
customTabsIntent.launchUrl(activity, uri)
|
|
1362
|
+
|
|
1363
|
+
promise.resolve(null)
|
|
1364
|
+
} catch (e: Exception) {
|
|
1365
|
+
promise.resolve(createError("Failed", e))
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1375
1370
|
override fun addListener(eventType: String?) {
|
|
1376
1371
|
// noop, iOS only
|
|
1377
1372
|
}
|
|
@@ -1419,7 +1414,7 @@ class StripeSdkModule(
|
|
|
1419
1414
|
* provided will be resolved with an error message instructing the user to retry the method.
|
|
1420
1415
|
*/
|
|
1421
1416
|
private fun getCurrentActivityOrResolveWithError(promise: Promise?): FragmentActivity? {
|
|
1422
|
-
(currentActivity as? FragmentActivity)?.let {
|
|
1417
|
+
(reactApplicationContext.currentActivity as? FragmentActivity)?.let {
|
|
1423
1418
|
return it
|
|
1424
1419
|
}
|
|
1425
1420
|
promise?.resolve(createMissingActivityError())
|
|
@@ -1473,14 +1468,14 @@ class StripeSdkModule(
|
|
|
1473
1468
|
*/
|
|
1474
1469
|
private fun preventActivityRecreation() {
|
|
1475
1470
|
isRecreatingReactActivity = false
|
|
1476
|
-
currentActivity?.application?.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1477
|
-
currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1471
|
+
reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1472
|
+
reactApplicationContext.currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1478
1473
|
}
|
|
1479
1474
|
|
|
1480
1475
|
private fun setupComposeCompatView() {
|
|
1481
1476
|
UiThreadUtil.runOnUiThread {
|
|
1482
1477
|
composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(context = reactApplicationContext).also {
|
|
1483
|
-
currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
|
|
1478
|
+
reactApplicationContext.currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
|
|
1484
1479
|
it,
|
|
1485
1480
|
)
|
|
1486
1481
|
}
|