@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
8
|
+
import com.reactnativestripesdk.utils.createFailedError
|
|
9
|
+
|
|
10
|
+
@ReactModule(name = NativeOnrampSdkModuleSpec.NAME)
|
|
11
|
+
class FakeOnrampSdkModule(
|
|
12
|
+
reactContext: ReactApplicationContext,
|
|
13
|
+
) : NativeOnrampSdkModuleSpec(reactContext) {
|
|
14
|
+
@ReactMethod
|
|
15
|
+
override fun initialise(
|
|
16
|
+
params: ReadableMap?,
|
|
17
|
+
promise: Promise?,
|
|
18
|
+
) {
|
|
19
|
+
promise?.resolve(null)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@ReactMethod
|
|
23
|
+
override fun configureOnramp(
|
|
24
|
+
config: ReadableMap?,
|
|
25
|
+
promise: Promise?,
|
|
26
|
+
) {
|
|
27
|
+
promise?.resolveNotImplemented()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@ReactMethod
|
|
31
|
+
override fun hasLinkAccount(
|
|
32
|
+
email: String?,
|
|
33
|
+
promise: Promise?,
|
|
34
|
+
) {
|
|
35
|
+
promise?.resolveNotImplemented()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@ReactMethod
|
|
39
|
+
override fun registerLinkUser(
|
|
40
|
+
info: ReadableMap?,
|
|
41
|
+
promise: Promise?,
|
|
42
|
+
) {
|
|
43
|
+
promise?.resolveNotImplemented()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@ReactMethod
|
|
47
|
+
override fun registerWalletAddress(
|
|
48
|
+
walletAddress: String?,
|
|
49
|
+
network: String?,
|
|
50
|
+
promise: Promise?,
|
|
51
|
+
) {
|
|
52
|
+
promise?.resolveNotImplemented()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
override fun attachKycInfo(
|
|
57
|
+
kycInfo: ReadableMap?,
|
|
58
|
+
promise: Promise?,
|
|
59
|
+
) {
|
|
60
|
+
promise?.resolveNotImplemented()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
override fun updatePhoneNumber(
|
|
65
|
+
phone: String?,
|
|
66
|
+
promise: Promise?,
|
|
67
|
+
) {
|
|
68
|
+
promise?.resolveNotImplemented()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@ReactMethod
|
|
72
|
+
override fun authenticateUser(promise: Promise?) {
|
|
73
|
+
promise?.resolveNotImplemented()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@ReactMethod
|
|
77
|
+
override fun verifyIdentity(promise: Promise?) {
|
|
78
|
+
promise?.resolveNotImplemented()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@ReactMethod
|
|
82
|
+
override fun presentKycInfoVerification(
|
|
83
|
+
updatedAddress: ReadableMap?,
|
|
84
|
+
promise: Promise,
|
|
85
|
+
) {
|
|
86
|
+
promise?.resolveNotImplemented()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod
|
|
90
|
+
override fun collectPaymentMethod(
|
|
91
|
+
paymentMethod: String?,
|
|
92
|
+
platformPayParams: ReadableMap?,
|
|
93
|
+
promise: Promise?,
|
|
94
|
+
) {
|
|
95
|
+
promise?.resolveNotImplemented()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@ReactMethod
|
|
99
|
+
override fun provideCheckoutClientSecret(clientSecret: String?) {
|
|
100
|
+
// No-op
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@ReactMethod
|
|
104
|
+
override fun createCryptoPaymentToken(promise: Promise?) {
|
|
105
|
+
promise?.resolveNotImplemented()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@ReactMethod
|
|
109
|
+
override fun performCheckout(
|
|
110
|
+
onrampSessionId: String?,
|
|
111
|
+
promise: Promise?,
|
|
112
|
+
) {
|
|
113
|
+
promise?.resolveNotImplemented()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactMethod
|
|
117
|
+
override fun onrampAuthorize(
|
|
118
|
+
linkAuthIntentId: String?,
|
|
119
|
+
promise: Promise?,
|
|
120
|
+
) {
|
|
121
|
+
promise?.resolveNotImplemented()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@ReactMethod
|
|
125
|
+
override fun logout(promise: Promise?) {
|
|
126
|
+
promise?.resolveNotImplemented()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@ReactMethod
|
|
130
|
+
override fun getCryptoTokenDisplayData(
|
|
131
|
+
token: ReadableMap,
|
|
132
|
+
promise: Promise,
|
|
133
|
+
) {
|
|
134
|
+
promise?.resolveNotImplemented()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@ReactMethod
|
|
138
|
+
override fun authenticateUserWithToken(
|
|
139
|
+
token: String,
|
|
140
|
+
promise: Promise,
|
|
141
|
+
) {
|
|
142
|
+
promise.resolveNotImplemented()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private fun Promise.resolveNotImplemented() {
|
|
146
|
+
this.resolve(
|
|
147
|
+
createFailedError(
|
|
148
|
+
NotImplementedError(
|
|
149
|
+
"To enable Onramp, add 'StripeSdk_includeOnramp=true' to gradle.properties.",
|
|
150
|
+
),
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
4
|
import com.facebook.react.bridge.Arguments
|
|
5
|
-
import com.facebook.react.bridge.Promise
|
|
6
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
6
|
import com.facebook.react.bridge.ReadableArray
|
|
8
7
|
import com.facebook.react.bridge.WritableArray
|
|
9
8
|
import com.facebook.react.bridge.WritableMap
|
|
10
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
11
9
|
import com.reactnativestripesdk.utils.ErrorType
|
|
12
|
-
import com.reactnativestripesdk.utils.
|
|
10
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
13
11
|
import com.reactnativestripesdk.utils.createError
|
|
14
|
-
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
15
12
|
import com.reactnativestripesdk.utils.mapFromFinancialConnectionsEvent
|
|
16
13
|
import com.reactnativestripesdk.utils.mapFromToken
|
|
14
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
17
15
|
import com.stripe.android.financialconnections.FinancialConnections
|
|
18
16
|
import com.stripe.android.financialconnections.FinancialConnectionsSheet
|
|
19
17
|
import com.stripe.android.financialconnections.FinancialConnectionsSheetForTokenResult
|
|
@@ -24,18 +22,28 @@ import com.stripe.android.financialconnections.model.FinancialConnectionsAccount
|
|
|
24
22
|
import com.stripe.android.financialconnections.model.FinancialConnectionsAccountList
|
|
25
23
|
import com.stripe.android.financialconnections.model.FinancialConnectionsSession
|
|
26
24
|
|
|
27
|
-
class
|
|
25
|
+
@OptIn(ReactNativeSdkInternal::class)
|
|
26
|
+
class FinancialConnectionsSheetManager(
|
|
27
|
+
context: ReactApplicationContext,
|
|
28
|
+
clientSecret: String,
|
|
29
|
+
private var mode: Mode,
|
|
30
|
+
publishableKey: String,
|
|
31
|
+
stripeAccountId: String?,
|
|
32
|
+
) : StripeUIManager(context) {
|
|
28
33
|
enum class Mode {
|
|
29
34
|
ForToken,
|
|
30
35
|
ForSession,
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
private var configuration =
|
|
39
|
+
FinancialConnectionsSheet.Configuration(
|
|
40
|
+
financialConnectionsSessionClientSecret = clientSecret,
|
|
41
|
+
publishableKey = publishableKey,
|
|
42
|
+
stripeAccountId = stripeAccountId,
|
|
43
|
+
)
|
|
37
44
|
|
|
38
|
-
override fun
|
|
45
|
+
override fun onPresent() {
|
|
46
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
39
47
|
val stripeSdkModule: StripeSdkModule? = context.getNativeModule(StripeSdkModule::class.java)
|
|
40
48
|
FinancialConnections.setEventListener { event ->
|
|
41
49
|
val params = mapFromFinancialConnectionsEvent(event)
|
|
@@ -44,16 +52,19 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
44
52
|
|
|
45
53
|
when (mode) {
|
|
46
54
|
Mode.ForToken -> {
|
|
55
|
+
@SuppressLint("RestrictedApi")
|
|
47
56
|
FinancialConnectionsSheet
|
|
48
57
|
.createForBankAccountToken(
|
|
49
|
-
|
|
58
|
+
activity,
|
|
59
|
+
signal,
|
|
50
60
|
::onFinancialConnectionsSheetForTokenResult,
|
|
51
61
|
).present(configuration = configuration)
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
Mode.ForSession -> {
|
|
65
|
+
@SuppressLint("RestrictedApi")
|
|
55
66
|
FinancialConnectionsSheet
|
|
56
|
-
.create(
|
|
67
|
+
.create(activity, signal, ::onFinancialConnectionsSheetForDataResult)
|
|
57
68
|
.present(configuration = configuration)
|
|
58
69
|
}
|
|
59
70
|
}
|
|
@@ -61,7 +72,6 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
61
72
|
|
|
62
73
|
override fun onDestroy() {
|
|
63
74
|
super.onDestroy()
|
|
64
|
-
|
|
65
75
|
// Remove any event listener that might be set
|
|
66
76
|
FinancialConnections.clearEventListener()
|
|
67
77
|
}
|
|
@@ -69,20 +79,15 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
69
79
|
private fun onFinancialConnectionsSheetForTokenResult(result: FinancialConnectionsSheetForTokenResult) {
|
|
70
80
|
when (result) {
|
|
71
81
|
is FinancialConnectionsSheetForTokenResult.Canceled -> {
|
|
72
|
-
promise
|
|
82
|
+
promise?.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
is FinancialConnectionsSheetForTokenResult.Failed -> {
|
|
76
|
-
promise
|
|
86
|
+
promise?.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
is FinancialConnectionsSheetForTokenResult.Completed -> {
|
|
80
|
-
promise
|
|
81
|
-
(context.currentActivity as? FragmentActivity)
|
|
82
|
-
?.supportFragmentManager
|
|
83
|
-
?.beginTransaction()
|
|
84
|
-
?.remove(this)
|
|
85
|
-
?.commitAllowingStateLoss()
|
|
90
|
+
promise?.resolve(createTokenResult(result))
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
}
|
|
@@ -90,85 +95,32 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
90
95
|
private fun onFinancialConnectionsSheetForDataResult(result: FinancialConnectionsSheetResult) {
|
|
91
96
|
when (result) {
|
|
92
97
|
is FinancialConnectionsSheetResult.Canceled -> {
|
|
93
|
-
promise
|
|
98
|
+
promise?.resolve(createError(ErrorType.Canceled.toString(), "The flow has been canceled"))
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
is FinancialConnectionsSheetResult.Failed -> {
|
|
97
|
-
promise
|
|
102
|
+
promise?.resolve(createError(ErrorType.Failed.toString(), result.error))
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
is FinancialConnectionsSheetResult.Completed -> {
|
|
101
|
-
promise
|
|
102
|
-
|
|
106
|
+
promise?.resolve(
|
|
107
|
+
Arguments.createMap().also {
|
|
103
108
|
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
104
109
|
},
|
|
105
110
|
)
|
|
106
|
-
(context.currentActivity as? FragmentActivity)
|
|
107
|
-
?.supportFragmentManager
|
|
108
|
-
?.beginTransaction()
|
|
109
|
-
?.remove(this)
|
|
110
|
-
?.commitAllowingStateLoss()
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
fun presentFinancialConnectionsSheet(
|
|
116
|
-
clientSecret: String,
|
|
117
|
-
mode: Mode,
|
|
118
|
-
publishableKey: String,
|
|
119
|
-
stripeAccountId: String?,
|
|
120
|
-
promise: Promise,
|
|
121
|
-
context: ReactApplicationContext,
|
|
122
|
-
) {
|
|
123
|
-
this.promise = promise
|
|
124
|
-
this.context = context
|
|
125
|
-
this.mode = mode
|
|
126
|
-
this.configuration =
|
|
127
|
-
FinancialConnectionsSheet.Configuration(
|
|
128
|
-
financialConnectionsSessionClientSecret = clientSecret,
|
|
129
|
-
publishableKey = publishableKey,
|
|
130
|
-
stripeAccountId = stripeAccountId,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
(context.currentActivity as? FragmentActivity)?.let {
|
|
134
|
-
attemptToCleanupPreviousFragment(it)
|
|
135
|
-
commitFragmentAndStartFlow(it)
|
|
136
|
-
}
|
|
137
|
-
?: run {
|
|
138
|
-
promise.resolve(createMissingActivityError())
|
|
139
|
-
return
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private fun attemptToCleanupPreviousFragment(currentActivity: FragmentActivity) {
|
|
144
|
-
currentActivity.supportFragmentManager
|
|
145
|
-
.beginTransaction()
|
|
146
|
-
.remove(this)
|
|
147
|
-
.commitAllowingStateLoss()
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private fun commitFragmentAndStartFlow(currentActivity: FragmentActivity) {
|
|
151
|
-
try {
|
|
152
|
-
currentActivity.supportFragmentManager
|
|
153
|
-
.beginTransaction()
|
|
154
|
-
.add(this, TAG)
|
|
155
|
-
.commit()
|
|
156
|
-
} catch (error: IllegalStateException) {
|
|
157
|
-
promise.resolve(createError(ErrorType.Failed.toString(), error.message))
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
115
|
companion object {
|
|
162
|
-
internal const val TAG = "financial_connections_sheet_launch_fragment"
|
|
163
|
-
|
|
164
116
|
private fun createTokenResult(result: FinancialConnectionsSheetForTokenResult.Completed): WritableMap =
|
|
165
|
-
|
|
117
|
+
Arguments.createMap().also {
|
|
166
118
|
it.putMap("session", mapFromSession(result.financialConnectionsSession))
|
|
167
119
|
it.putMap("token", mapFromToken(result.token))
|
|
168
120
|
}
|
|
169
121
|
|
|
170
122
|
private fun mapFromSession(financialConnectionsSession: FinancialConnectionsSession): WritableMap {
|
|
171
|
-
val session =
|
|
123
|
+
val session = Arguments.createMap()
|
|
172
124
|
session.putString("id", financialConnectionsSession.id)
|
|
173
125
|
session.putString("clientSecret", financialConnectionsSession.clientSecret)
|
|
174
126
|
session.putBoolean("livemode", financialConnectionsSession.livemode)
|
|
@@ -179,7 +131,7 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
179
131
|
private fun mapFromAccountsList(accounts: FinancialConnectionsAccountList): ReadableArray {
|
|
180
132
|
val results: WritableArray = Arguments.createArray()
|
|
181
133
|
for (account in accounts.data) {
|
|
182
|
-
val map =
|
|
134
|
+
val map = Arguments.createMap()
|
|
183
135
|
map.putString("id", account.id)
|
|
184
136
|
map.putBoolean("livemode", account.livemode)
|
|
185
137
|
map.putString("displayName", account.displayName)
|
|
@@ -213,10 +165,10 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
213
165
|
if (balance == null) {
|
|
214
166
|
return null
|
|
215
167
|
}
|
|
216
|
-
val map =
|
|
168
|
+
val map = Arguments.createMap()
|
|
217
169
|
map.putDouble("asOf", balance.asOf * 1000.0)
|
|
218
170
|
map.putString("type", mapFromBalanceType(balance.type))
|
|
219
|
-
|
|
171
|
+
Arguments.createMap().also {
|
|
220
172
|
for (entry in balance.current.entries) {
|
|
221
173
|
it.putInt(entry.key, entry.value)
|
|
222
174
|
}
|
|
@@ -228,9 +180,9 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
228
180
|
return map
|
|
229
181
|
}
|
|
230
182
|
|
|
231
|
-
private fun mapFromCashAvailable(balance: Balance):
|
|
232
|
-
|
|
233
|
-
|
|
183
|
+
private fun mapFromCashAvailable(balance: Balance): WritableMap =
|
|
184
|
+
Arguments.createMap().also { cashMap ->
|
|
185
|
+
Arguments.createMap().also { availableMap ->
|
|
234
186
|
balance.cash?.available?.entries?.let { entries ->
|
|
235
187
|
for (entry in entries) {
|
|
236
188
|
availableMap.putInt(entry.key, entry.value)
|
|
@@ -240,9 +192,9 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
240
192
|
}
|
|
241
193
|
}
|
|
242
194
|
|
|
243
|
-
private fun mapFromCreditUsed(balance: Balance):
|
|
244
|
-
|
|
245
|
-
|
|
195
|
+
private fun mapFromCreditUsed(balance: Balance): WritableMap =
|
|
196
|
+
Arguments.createMap().also { creditMap ->
|
|
197
|
+
Arguments.createMap().also { usedMap ->
|
|
246
198
|
balance.credit?.used?.entries?.let { entries ->
|
|
247
199
|
for (entry in entries) {
|
|
248
200
|
usedMap.putInt(entry.key, entry.value)
|
|
@@ -256,7 +208,7 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
256
208
|
if (balanceRefresh == null) {
|
|
257
209
|
return null
|
|
258
210
|
}
|
|
259
|
-
val map =
|
|
211
|
+
val map = Arguments.createMap()
|
|
260
212
|
map.putString("status", mapFromBalanceRefreshStatus(balanceRefresh.status))
|
|
261
213
|
map.putDouble("lastAttemptedAt", balanceRefresh.lastAttemptedAt * 1000.0)
|
|
262
214
|
return map
|
|
@@ -298,7 +250,6 @@ class FinancialConnectionsSheetFragment : StripeFragment() {
|
|
|
298
250
|
FinancialConnectionsAccount.Permissions.TRANSACTIONS -> "transactions"
|
|
299
251
|
FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
|
|
300
252
|
FinancialConnectionsAccount.Permissions.UNKNOWN -> "unparsable"
|
|
301
|
-
FinancialConnectionsAccount.Permissions.ACCOUNT_NUMBERS -> "accountNumbers"
|
|
302
253
|
}
|
|
303
254
|
|
|
304
255
|
private fun mapFromSupportedPaymentMethodTypes(type: FinancialConnectionsAccount.SupportedPaymentMethodTypes): String =
|
|
@@ -108,7 +108,7 @@ class GooglePayButtonView(
|
|
|
108
108
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
109
109
|
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
|
|
110
110
|
)
|
|
111
|
-
|
|
111
|
+
layout(left, top, right, bottom)
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
fun setType(type: Int) {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.bridge.WritableMap
|
|
7
|
+
import com.reactnativestripesdk.utils.GooglePayErrorType
|
|
8
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
9
|
+
import com.reactnativestripesdk.utils.createError
|
|
10
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
11
|
+
import com.reactnativestripesdk.utils.getIntOrNull
|
|
12
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
13
|
+
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
14
|
+
import com.stripe.android.googlepaylauncher.GooglePayLauncher
|
|
15
|
+
|
|
16
|
+
@OptIn(ReactNativeSdkInternal::class)
|
|
17
|
+
class GooglePayLauncherManager(
|
|
18
|
+
context: ReactApplicationContext,
|
|
19
|
+
private val clientSecret: String,
|
|
20
|
+
private val mode: Mode,
|
|
21
|
+
googlePayParams: ReadableMap,
|
|
22
|
+
private val callback: (GooglePayLauncher.Result?, error: WritableMap?) -> Unit,
|
|
23
|
+
) : StripeUIManager(context) {
|
|
24
|
+
enum class Mode {
|
|
25
|
+
ForSetup,
|
|
26
|
+
ForPayment,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private var launcher: GooglePayLauncher? = null
|
|
30
|
+
private var configuration =
|
|
31
|
+
GooglePayLauncher.Config(
|
|
32
|
+
environment =
|
|
33
|
+
if (googlePayParams.getBooleanOr("testEnv", false)) {
|
|
34
|
+
GooglePayEnvironment.Test
|
|
35
|
+
} else {
|
|
36
|
+
GooglePayEnvironment.Production
|
|
37
|
+
},
|
|
38
|
+
merchantCountryCode = googlePayParams.getString("merchantCountryCode").orEmpty(),
|
|
39
|
+
merchantName = googlePayParams.getString("merchantName").orEmpty(),
|
|
40
|
+
isEmailRequired = googlePayParams.getBooleanOr("isEmailRequired", false),
|
|
41
|
+
billingAddressConfig =
|
|
42
|
+
buildBillingAddressParameters(googlePayParams.getMap("billingAddressConfig")),
|
|
43
|
+
existingPaymentMethodRequired =
|
|
44
|
+
googlePayParams.getBooleanOr("existingPaymentMethodRequired", false),
|
|
45
|
+
allowCreditCards = googlePayParams.getBooleanOr("allowCreditCards", true),
|
|
46
|
+
)
|
|
47
|
+
private var currencyCode = googlePayParams.getString("currencyCode") ?: "USD"
|
|
48
|
+
private var amount = googlePayParams.getIntOrNull("amount")
|
|
49
|
+
private var label = googlePayParams.getString("label")
|
|
50
|
+
|
|
51
|
+
override fun onPresent() {
|
|
52
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
53
|
+
@SuppressLint("RestrictedApi")
|
|
54
|
+
launcher =
|
|
55
|
+
GooglePayLauncher(
|
|
56
|
+
activity = activity,
|
|
57
|
+
signal = signal,
|
|
58
|
+
config = configuration,
|
|
59
|
+
readyCallback = ::onGooglePayReady,
|
|
60
|
+
resultCallback = ::onGooglePayResult,
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private fun onGooglePayReady(isReady: Boolean) {
|
|
65
|
+
if (isReady) {
|
|
66
|
+
when (mode) {
|
|
67
|
+
Mode.ForSetup -> {
|
|
68
|
+
launcher?.presentForSetupIntent(clientSecret, currencyCode, amount?.toLong(), label)
|
|
69
|
+
}
|
|
70
|
+
Mode.ForPayment -> {
|
|
71
|
+
launcher?.presentForPaymentIntent(clientSecret, label)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
callback(
|
|
76
|
+
null,
|
|
77
|
+
createError(
|
|
78
|
+
GooglePayErrorType.Failed.toString(),
|
|
79
|
+
"Google Pay is not available on this device. You can use isPlatformPaySupported to preemptively check for Google Pay support.",
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private fun onGooglePayResult(result: GooglePayLauncher.Result) {
|
|
86
|
+
callback(result, null)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
companion object {
|
|
90
|
+
private fun buildBillingAddressParameters(params: ReadableMap?): GooglePayLauncher.BillingAddressConfig {
|
|
91
|
+
val isRequired = params?.getBooleanOr("isRequired", false)
|
|
92
|
+
val isPhoneNumberRequired = params?.getBooleanOr("isPhoneNumberRequired", false)
|
|
93
|
+
val format =
|
|
94
|
+
when (params?.getString("format").orEmpty()) {
|
|
95
|
+
"FULL" -> GooglePayLauncher.BillingAddressConfig.Format.Full
|
|
96
|
+
"MIN" -> GooglePayLauncher.BillingAddressConfig.Format.Min
|
|
97
|
+
else -> GooglePayLauncher.BillingAddressConfig.Format.Min
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return GooglePayLauncher.BillingAddressConfig(
|
|
101
|
+
isRequired = isRequired ?: false,
|
|
102
|
+
format = format,
|
|
103
|
+
isPhoneNumberRequired = isPhoneNumberRequired ?: false,
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
6
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
7
|
+
import com.stripe.android.googlepaylauncher.GooglePayEnvironment
|
|
8
|
+
import com.stripe.android.googlepaylauncher.GooglePayPaymentMethodLauncher
|
|
9
|
+
|
|
10
|
+
@ReactNativeSdkInternal
|
|
11
|
+
class GooglePayPaymentMethodLauncherManager(
|
|
12
|
+
context: ReactApplicationContext,
|
|
13
|
+
private val isTestEnv: Boolean,
|
|
14
|
+
private val paymentMethodRequired: Boolean,
|
|
15
|
+
) : StripeUIManager(context) {
|
|
16
|
+
override fun onPresent() {
|
|
17
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
18
|
+
@SuppressLint("RestrictedApi")
|
|
19
|
+
GooglePayPaymentMethodLauncher(
|
|
20
|
+
activity = activity,
|
|
21
|
+
signal = signal,
|
|
22
|
+
config =
|
|
23
|
+
GooglePayPaymentMethodLauncher.Config(
|
|
24
|
+
environment =
|
|
25
|
+
if (isTestEnv) GooglePayEnvironment.Test else GooglePayEnvironment.Production,
|
|
26
|
+
existingPaymentMethodRequired = paymentMethodRequired,
|
|
27
|
+
merchantCountryCode =
|
|
28
|
+
"", // Unnecessary since all we are checking for is Google Pay availability
|
|
29
|
+
merchantName = "", // Same as above
|
|
30
|
+
),
|
|
31
|
+
readyCallback = {
|
|
32
|
+
promise?.resolve(it)
|
|
33
|
+
},
|
|
34
|
+
resultCallback = {},
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -3,9 +3,9 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import androidx.fragment.app.FragmentActivity
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
6
7
|
import com.facebook.react.bridge.Promise
|
|
7
8
|
import com.facebook.react.bridge.ReadableMap
|
|
8
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
9
9
|
import com.google.android.gms.tasks.Task
|
|
10
10
|
import com.google.android.gms.wallet.AutoResolveHelper
|
|
11
11
|
import com.google.android.gms.wallet.PaymentData
|
|
@@ -15,6 +15,7 @@ import com.google.android.gms.wallet.WalletConstants
|
|
|
15
15
|
import com.reactnativestripesdk.utils.ErrorType
|
|
16
16
|
import com.reactnativestripesdk.utils.createError
|
|
17
17
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
18
|
+
import com.reactnativestripesdk.utils.getIntOr
|
|
18
19
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
19
20
|
import com.reactnativestripesdk.utils.mapFromShippingContact
|
|
20
21
|
import com.reactnativestripesdk.utils.mapFromToken
|
|
@@ -58,7 +59,7 @@ class GooglePayRequestHelper {
|
|
|
58
59
|
Wallet.WalletOptions
|
|
59
60
|
.Builder()
|
|
60
61
|
.setEnvironment(
|
|
61
|
-
if (googlePayParams.
|
|
62
|
+
if (googlePayParams.getBooleanOr("testEnv", false)) {
|
|
62
63
|
WalletConstants.ENVIRONMENT_TEST
|
|
63
64
|
} else {
|
|
64
65
|
WalletConstants.ENVIRONMENT_PRODUCTION
|
|
@@ -107,7 +108,7 @@ class GooglePayRequestHelper {
|
|
|
107
108
|
private fun buildTransactionInfo(params: ReadableMap): GooglePayJsonFactory.TransactionInfo {
|
|
108
109
|
val countryCode = params.getString("merchantCountryCode").orEmpty()
|
|
109
110
|
val currencyCode = params.getString("currencyCode") ?: "USD"
|
|
110
|
-
val amount = params.
|
|
111
|
+
val amount = params.getIntOr("amount", 0)
|
|
111
112
|
val label = params.getString("label")
|
|
112
113
|
|
|
113
114
|
return GooglePayJsonFactory.TransactionInfo(
|
|
@@ -124,6 +125,7 @@ class GooglePayRequestHelper {
|
|
|
124
125
|
request: Task<PaymentData>,
|
|
125
126
|
activity: FragmentActivity,
|
|
126
127
|
) {
|
|
128
|
+
@Suppress("DEPRECATION")
|
|
127
129
|
AutoResolveHelper.resolveTask(request, activity, LOAD_PAYMENT_DATA_REQUEST_CODE)
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -165,7 +167,7 @@ class GooglePayRequestHelper {
|
|
|
165
167
|
promise: Promise,
|
|
166
168
|
) {
|
|
167
169
|
val paymentInformation = JSONObject(paymentData.toJson())
|
|
168
|
-
val promiseResult =
|
|
170
|
+
val promiseResult = Arguments.createMap()
|
|
169
171
|
stripe.createPaymentMethod(
|
|
170
172
|
PaymentMethodCreateParams.createFromGooglePay(paymentInformation),
|
|
171
173
|
callback =
|
|
@@ -193,7 +195,7 @@ class GooglePayRequestHelper {
|
|
|
193
195
|
) {
|
|
194
196
|
val paymentInformation = JSONObject(paymentData.toJson())
|
|
195
197
|
val googlePayResult = GooglePayResult.fromJson(paymentInformation)
|
|
196
|
-
val promiseResult =
|
|
198
|
+
val promiseResult = Arguments.createMap()
|
|
197
199
|
googlePayResult.token?.let {
|
|
198
200
|
promiseResult.putMap("token", mapFromToken(it))
|
|
199
201
|
if (googlePayResult.shippingInformation != null) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.reactnativestripesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
4
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
7
|
+
|
|
8
|
+
@ReactModule(name = NavigationBarManager.REACT_CLASS)
|
|
9
|
+
class NavigationBarManager : SimpleViewManager<NavigationBarView>() {
|
|
10
|
+
override fun getName() = REACT_CLASS
|
|
11
|
+
|
|
12
|
+
override fun getExportedCustomDirectEventTypeConstants() =
|
|
13
|
+
mutableMapOf(
|
|
14
|
+
EVENT_ON_CLOSE_BUTTON_PRESS to mutableMapOf("registrationName" to EVENT_ON_CLOSE_BUTTON_PRESS),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
@ReactProp(name = "title")
|
|
18
|
+
fun setTitle(
|
|
19
|
+
view: NavigationBarView,
|
|
20
|
+
title: String?,
|
|
21
|
+
) {
|
|
22
|
+
view.setTitle(title)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun createViewInstance(reactContext: ThemedReactContext): NavigationBarView = NavigationBarView(reactContext)
|
|
26
|
+
|
|
27
|
+
companion object {
|
|
28
|
+
const val REACT_CLASS = "NavigationBar"
|
|
29
|
+
private const val EVENT_ON_CLOSE_BUTTON_PRESS = "onCloseButtonPress"
|
|
30
|
+
}
|
|
31
|
+
}
|