@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
|
@@ -19,11 +19,20 @@ class StripeSdkPackage : BaseReactPackage() {
|
|
|
19
19
|
): NativeModule? =
|
|
20
20
|
when (name) {
|
|
21
21
|
StripeSdkModule.NAME -> StripeSdkModule(reactContext)
|
|
22
|
+
NativeOnrampSdkModuleSpec.NAME -> {
|
|
23
|
+
val onrampModuleClass = getOnrampModuleClass()
|
|
24
|
+
val constructor = onrampModuleClass.getConstructor(ReactApplicationContext::class.java)
|
|
25
|
+
constructor.newInstance(reactContext) as NativeModule
|
|
26
|
+
}
|
|
22
27
|
else -> null
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
26
|
-
val moduleList: Array<Class<out NativeModule?>> =
|
|
31
|
+
val moduleList: Array<Class<out NativeModule?>> =
|
|
32
|
+
arrayOf(
|
|
33
|
+
StripeSdkModule::class.java,
|
|
34
|
+
getOnrampModuleClass(),
|
|
35
|
+
)
|
|
27
36
|
val reactModuleInfoMap: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
28
37
|
for (moduleClass in moduleList) {
|
|
29
38
|
val reactModule = moduleClass.getAnnotation(ReactModule::class.java) ?: continue
|
|
@@ -47,8 +56,18 @@ class StripeSdkPackage : BaseReactPackage() {
|
|
|
47
56
|
StripeContainerManager(),
|
|
48
57
|
CardFormViewManager(),
|
|
49
58
|
GooglePayButtonManager(),
|
|
50
|
-
AddToWalletButtonManager(
|
|
59
|
+
AddToWalletButtonManager(),
|
|
51
60
|
AddressSheetViewManager(),
|
|
52
61
|
EmbeddedPaymentElementViewManager(),
|
|
62
|
+
NavigationBarManager(),
|
|
53
63
|
)
|
|
64
|
+
|
|
65
|
+
private fun getOnrampModuleClass(): Class<out NativeModule?> {
|
|
66
|
+
if (BuildConfig.IS_ONRAMP_INCLUDED) {
|
|
67
|
+
@Suppress("UNCHECKED_CAST")
|
|
68
|
+
return Class.forName("com.reactnativestripesdk.OnrampSdkModule") as Class<out NativeModule?>
|
|
69
|
+
} else {
|
|
70
|
+
return FakeOnrampSdkModule::class.java
|
|
71
|
+
}
|
|
72
|
+
}
|
|
54
73
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
package com.reactnativestripesdk.addresssheet
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.WritableMap
|
|
6
|
+
import com.reactnativestripesdk.utils.ErrorType
|
|
7
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
8
|
+
import com.reactnativestripesdk.utils.createError
|
|
9
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
10
|
+
import com.stripe.android.paymentsheet.PaymentSheet
|
|
11
|
+
import com.stripe.android.paymentsheet.addresselement.AddressDetails
|
|
12
|
+
import com.stripe.android.paymentsheet.addresselement.AddressLauncher
|
|
13
|
+
import com.stripe.android.paymentsheet.addresselement.AddressLauncherResult
|
|
14
|
+
|
|
15
|
+
@OptIn(ReactNativeSdkInternal::class)
|
|
16
|
+
class AddressLauncherManager(
|
|
17
|
+
context: ReactApplicationContext,
|
|
18
|
+
appearance: PaymentSheet.Appearance,
|
|
19
|
+
defaultAddress: AddressDetails?,
|
|
20
|
+
allowedCountries: Set<String>,
|
|
21
|
+
buttonTitle: String?,
|
|
22
|
+
title: String?,
|
|
23
|
+
googlePlacesApiKey: String?,
|
|
24
|
+
autocompleteCountries: Set<String>,
|
|
25
|
+
additionalFields: AddressLauncher.AdditionalFieldsConfiguration?,
|
|
26
|
+
private var callback: ((error: WritableMap?, address: AddressDetails?) -> Unit),
|
|
27
|
+
) : StripeUIManager(context) {
|
|
28
|
+
companion object {
|
|
29
|
+
internal var publishableKey: String? = null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private lateinit var addressLauncher: AddressLauncher
|
|
33
|
+
private var configuration =
|
|
34
|
+
AddressLauncher.Configuration(
|
|
35
|
+
appearance = appearance,
|
|
36
|
+
address = defaultAddress,
|
|
37
|
+
allowedCountries = allowedCountries,
|
|
38
|
+
buttonTitle = buttonTitle,
|
|
39
|
+
additionalFields = additionalFields,
|
|
40
|
+
title = title,
|
|
41
|
+
googlePlacesApiKey = googlePlacesApiKey,
|
|
42
|
+
autocompleteCountries = autocompleteCountries,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
override fun onPresent() {
|
|
46
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
47
|
+
publishableKey?.let { publishableKey ->
|
|
48
|
+
@SuppressLint("RestrictedApi")
|
|
49
|
+
addressLauncher =
|
|
50
|
+
AddressLauncher(activity, signal, ::onAddressLauncherResult).also {
|
|
51
|
+
it.present(publishableKey = publishableKey, configuration = configuration)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
?: run {
|
|
55
|
+
callback.invoke(
|
|
56
|
+
createError(
|
|
57
|
+
ErrorType.Failed.toString(),
|
|
58
|
+
"No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the StripeProvider component or the initStripe method.",
|
|
59
|
+
),
|
|
60
|
+
null,
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private fun onAddressLauncherResult(result: AddressLauncherResult) {
|
|
66
|
+
when (result) {
|
|
67
|
+
is AddressLauncherResult.Canceled -> {
|
|
68
|
+
callback.invoke(
|
|
69
|
+
createError(ErrorType.Canceled.toString(), "The flow has been canceled."),
|
|
70
|
+
null,
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
is AddressLauncherResult.Succeeded -> {
|
|
74
|
+
callback.invoke(null, result.address)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
package com.reactnativestripesdk.addresssheet
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
|
-
import android.os.Bundle
|
|
5
4
|
import android.util.Log
|
|
6
5
|
import android.widget.FrameLayout
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
7
7
|
import com.facebook.react.bridge.ReadableMap
|
|
8
8
|
import com.facebook.react.bridge.WritableMap
|
|
9
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
10
9
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
10
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
12
11
|
import com.reactnativestripesdk.buildPaymentSheetAppearance
|
|
13
12
|
import com.reactnativestripesdk.utils.ErrorType
|
|
14
13
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
15
14
|
import com.reactnativestripesdk.utils.createError
|
|
16
|
-
import com.reactnativestripesdk.utils.
|
|
15
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
17
16
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
18
17
|
import com.stripe.android.paymentsheet.addresselement.AddressDetails
|
|
19
18
|
import com.stripe.android.paymentsheet.addresselement.AddressLauncher
|
|
@@ -31,6 +30,14 @@ class AddressSheetView(
|
|
|
31
30
|
private var googlePlacesApiKey: String? = null
|
|
32
31
|
private var autocompleteCountries: Set<String> = emptySet()
|
|
33
32
|
private var additionalFields: AddressLauncher.AdditionalFieldsConfiguration? = null
|
|
33
|
+
private var addressSheetManager: AddressLauncherManager? = null
|
|
34
|
+
|
|
35
|
+
override fun onDetachedFromWindow() {
|
|
36
|
+
super.onDetachedFromWindow()
|
|
37
|
+
|
|
38
|
+
addressSheetManager?.destroy()
|
|
39
|
+
addressSheetManager = null
|
|
40
|
+
}
|
|
34
41
|
|
|
35
42
|
private fun onSubmit(params: WritableMap) {
|
|
36
43
|
UIManagerHelper.getEventDispatcherForReactTag(context, id)?.dispatchEvent(
|
|
@@ -59,29 +66,37 @@ class AddressSheetView(
|
|
|
59
66
|
private fun launchAddressSheet() {
|
|
60
67
|
val appearance =
|
|
61
68
|
try {
|
|
62
|
-
buildPaymentSheetAppearance(
|
|
69
|
+
buildPaymentSheetAppearance(appearanceParams, context)
|
|
63
70
|
} catch (error: PaymentSheetAppearanceException) {
|
|
64
71
|
onError(createError(ErrorType.Failed.toString(), error))
|
|
65
72
|
return
|
|
66
73
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
addressSheetManager?.destroy()
|
|
75
|
+
addressSheetManager =
|
|
76
|
+
AddressLauncherManager(
|
|
77
|
+
context.reactApplicationContext,
|
|
78
|
+
appearance,
|
|
79
|
+
defaultAddress,
|
|
80
|
+
allowedCountries,
|
|
81
|
+
buttonTitle,
|
|
82
|
+
sheetTitle,
|
|
83
|
+
googlePlacesApiKey,
|
|
84
|
+
autocompleteCountries,
|
|
85
|
+
additionalFields,
|
|
86
|
+
) { error, address ->
|
|
87
|
+
addressSheetManager?.destroy()
|
|
88
|
+
addressSheetManager = null
|
|
89
|
+
|
|
90
|
+
if (address != null) {
|
|
91
|
+
onSubmit(buildResult(address))
|
|
92
|
+
} else {
|
|
93
|
+
onError(error)
|
|
94
|
+
}
|
|
95
|
+
isVisible = false
|
|
96
|
+
}.also {
|
|
97
|
+
it.create()
|
|
98
|
+
it.present()
|
|
82
99
|
}
|
|
83
|
-
isVisible = false
|
|
84
|
-
}
|
|
85
100
|
}
|
|
86
101
|
|
|
87
102
|
fun setAppearance(appearanceParams: ReadableMap?) {
|
|
@@ -117,27 +132,25 @@ class AddressSheetView(
|
|
|
117
132
|
}
|
|
118
133
|
|
|
119
134
|
companion object {
|
|
120
|
-
internal fun buildAddressDetails(
|
|
135
|
+
internal fun buildAddressDetails(map: ReadableMap): AddressDetails =
|
|
121
136
|
AddressDetails(
|
|
122
|
-
name =
|
|
123
|
-
address = buildAddress(
|
|
124
|
-
phoneNumber =
|
|
125
|
-
isCheckboxSelected =
|
|
137
|
+
name = map.getString("name"),
|
|
138
|
+
address = buildAddress(map.getMap("address")),
|
|
139
|
+
phoneNumber = map.getString("phone"),
|
|
140
|
+
isCheckboxSelected = map.getBooleanOr("isCheckboxSelected", false),
|
|
126
141
|
)
|
|
127
142
|
|
|
128
|
-
internal fun
|
|
129
|
-
|
|
130
|
-
internal fun buildAddress(bundle: Bundle?): PaymentSheet.Address? {
|
|
131
|
-
if (bundle == null) {
|
|
143
|
+
internal fun buildAddress(map: ReadableMap?): PaymentSheet.Address? {
|
|
144
|
+
if (map == null) {
|
|
132
145
|
return null
|
|
133
146
|
}
|
|
134
147
|
return PaymentSheet.Address(
|
|
135
|
-
city =
|
|
136
|
-
country =
|
|
137
|
-
line1 =
|
|
138
|
-
line2 =
|
|
139
|
-
state =
|
|
140
|
-
postalCode =
|
|
148
|
+
city = map.getString("city"),
|
|
149
|
+
country = map.getString("country"),
|
|
150
|
+
line1 = map.getString("line1"),
|
|
151
|
+
line2 = map.getString("line2"),
|
|
152
|
+
state = map.getString("state"),
|
|
153
|
+
postalCode = map.getString("postalCode"),
|
|
141
154
|
)
|
|
142
155
|
}
|
|
143
156
|
|
|
@@ -159,14 +172,14 @@ class AddressSheetView(
|
|
|
159
172
|
}
|
|
160
173
|
|
|
161
174
|
internal fun buildResult(addressDetails: AddressDetails): WritableMap =
|
|
162
|
-
|
|
175
|
+
Arguments.createMap().apply {
|
|
163
176
|
putMap(
|
|
164
177
|
"result",
|
|
165
|
-
|
|
178
|
+
Arguments.createMap().apply {
|
|
166
179
|
putString("name", addressDetails.name)
|
|
167
180
|
putMap(
|
|
168
181
|
"address",
|
|
169
|
-
|
|
182
|
+
Arguments.createMap().apply {
|
|
170
183
|
putString("city", addressDetails.address?.city)
|
|
171
184
|
putString("country", addressDetails.address?.country)
|
|
172
185
|
putString("line1", addressDetails.address?.line1)
|
package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt
CHANGED
|
@@ -41,7 +41,7 @@ class AddressSheetViewManager :
|
|
|
41
41
|
view: AddressSheetView,
|
|
42
42
|
appearance: Dynamic,
|
|
43
43
|
) {
|
|
44
|
-
view.setAppearance(appearance.
|
|
44
|
+
view.setAppearance(appearance.asMapOrNull())
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
@ReactProp(name = "defaultValues")
|
|
@@ -49,7 +49,7 @@ class AddressSheetViewManager :
|
|
|
49
49
|
view: AddressSheetView,
|
|
50
50
|
defaults: Dynamic,
|
|
51
51
|
) {
|
|
52
|
-
view.setDefaultValues(defaults.
|
|
52
|
+
view.setDefaultValues(defaults.asMapOrNull())
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
@ReactProp(name = "additionalFields")
|
|
@@ -10,79 +10,66 @@ import android.util.Log
|
|
|
10
10
|
import com.facebook.react.bridge.Arguments
|
|
11
11
|
import com.facebook.react.bridge.Promise
|
|
12
12
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap
|
|
13
14
|
import com.facebook.react.bridge.WritableMap
|
|
14
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
15
15
|
import com.reactnativestripesdk.ReactNativeCustomerAdapter
|
|
16
16
|
import com.reactnativestripesdk.ReactNativeCustomerSessionProvider
|
|
17
|
+
import com.reactnativestripesdk.buildBillingDetails
|
|
18
|
+
import com.reactnativestripesdk.buildBillingDetailsCollectionConfiguration
|
|
17
19
|
import com.reactnativestripesdk.buildPaymentSheetAppearance
|
|
18
20
|
import com.reactnativestripesdk.getBase64FromBitmap
|
|
19
21
|
import com.reactnativestripesdk.getBitmapFromDrawable
|
|
20
|
-
import com.reactnativestripesdk.mapToAddressCollectionMode
|
|
21
22
|
import com.reactnativestripesdk.mapToCardBrandAcceptance
|
|
22
|
-
import com.reactnativestripesdk.mapToCollectionMode
|
|
23
23
|
import com.reactnativestripesdk.utils.CreateTokenErrorType
|
|
24
24
|
import com.reactnativestripesdk.utils.ErrorType
|
|
25
25
|
import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
26
26
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
27
|
-
import com.reactnativestripesdk.utils.
|
|
27
|
+
import com.reactnativestripesdk.utils.StripeUIManager
|
|
28
28
|
import com.reactnativestripesdk.utils.createError
|
|
29
|
+
import com.reactnativestripesdk.utils.getBooleanOr
|
|
30
|
+
import com.reactnativestripesdk.utils.getIntegerList
|
|
31
|
+
import com.reactnativestripesdk.utils.getStringList
|
|
29
32
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
30
33
|
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
31
34
|
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
|
|
35
|
+
import com.stripe.android.core.reactnative.ReactNativeSdkInternal
|
|
32
36
|
import com.stripe.android.customersheet.CustomerAdapter
|
|
33
37
|
import com.stripe.android.customersheet.CustomerEphemeralKey
|
|
34
38
|
import com.stripe.android.customersheet.CustomerSheet
|
|
35
39
|
import com.stripe.android.customersheet.CustomerSheetResult
|
|
36
40
|
import com.stripe.android.customersheet.PaymentOptionSelection
|
|
37
41
|
import com.stripe.android.model.PaymentMethod
|
|
38
|
-
import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
|
|
39
42
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
40
43
|
import kotlinx.coroutines.CoroutineScope
|
|
41
44
|
import kotlinx.coroutines.Dispatchers
|
|
42
45
|
import kotlinx.coroutines.launch
|
|
43
46
|
|
|
44
|
-
@OptIn(
|
|
45
|
-
class
|
|
47
|
+
@OptIn(ReactNativeSdkInternal::class, ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi::class)
|
|
48
|
+
class CustomerSheetManager(
|
|
49
|
+
context: ReactApplicationContext,
|
|
50
|
+
private var arguments: ReadableMap,
|
|
51
|
+
private var customerAdapterOverrides: ReadableMap,
|
|
52
|
+
private var initPromise: Promise,
|
|
53
|
+
) : StripeUIManager(context) {
|
|
46
54
|
private var customerSheet: CustomerSheet? = null
|
|
47
55
|
internal var customerAdapter: ReactNativeCustomerAdapter? = null
|
|
48
56
|
internal var customerSessionProvider: ReactNativeCustomerSessionProvider? = null
|
|
49
|
-
internal var context: ReactApplicationContext? = null
|
|
50
|
-
internal var initPromise: Promise? = null
|
|
51
57
|
private var presentPromise: Promise? = null
|
|
52
58
|
private var keepJsAwake: KeepJsAwakeTask? = null
|
|
53
59
|
|
|
54
|
-
override fun
|
|
55
|
-
val
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"No context found during CustomerSheet.initialize. Please file an issue: https://github.com/stripe/stripe-react-native/issues",
|
|
61
|
-
)
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
val initPromise =
|
|
65
|
-
initPromise
|
|
66
|
-
?: run {
|
|
67
|
-
Log.e(
|
|
68
|
-
"StripeReactNative",
|
|
69
|
-
"No promise found for CustomerSheet.initialize. Please file an issue: https://github.com/stripe/stripe-react-native/issues",
|
|
70
|
-
)
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
val headerTextForSelectionScreen = arguments?.getString("headerTextForSelectionScreen")
|
|
75
|
-
val merchantDisplayName = arguments?.getString("merchantDisplayName")
|
|
76
|
-
val googlePayEnabled = arguments?.getBoolean("googlePayEnabled") ?: false
|
|
77
|
-
val billingDetailsBundle = arguments?.getBundle("defaultBillingDetails")
|
|
78
|
-
val billingConfigParams = arguments?.getBundle("billingDetailsCollectionConfiguration")
|
|
60
|
+
override fun onCreate() {
|
|
61
|
+
val headerTextForSelectionScreen = arguments.getString("headerTextForSelectionScreen")
|
|
62
|
+
val merchantDisplayName = arguments.getString("merchantDisplayName")
|
|
63
|
+
val googlePayEnabled = arguments.getBooleanOr("googlePayEnabled", false)
|
|
64
|
+
val billingDetailsMap = arguments.getMap("defaultBillingDetails")
|
|
65
|
+
val billingConfigParams = arguments.getMap("billingDetailsCollectionConfiguration")
|
|
79
66
|
val allowsRemovalOfLastSavedPaymentMethod =
|
|
80
|
-
arguments
|
|
81
|
-
val paymentMethodOrder = arguments
|
|
67
|
+
arguments.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
|
|
68
|
+
val paymentMethodOrder = arguments.getStringList("paymentMethodOrder")
|
|
82
69
|
|
|
83
70
|
val appearance =
|
|
84
71
|
try {
|
|
85
|
-
buildPaymentSheetAppearance(arguments
|
|
72
|
+
buildPaymentSheetAppearance(arguments.getMap("appearance"), context)
|
|
86
73
|
} catch (error: PaymentSheetAppearanceException) {
|
|
87
74
|
initPromise.resolve(createError(ErrorType.Failed.toString(), error))
|
|
88
75
|
return
|
|
@@ -95,13 +82,13 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
95
82
|
.googlePayEnabled(googlePayEnabled)
|
|
96
83
|
.headerTextForSelectionScreen(headerTextForSelectionScreen)
|
|
97
84
|
.preferredNetworks(
|
|
98
|
-
mapToPreferredNetworks(arguments
|
|
85
|
+
mapToPreferredNetworks(arguments.getIntegerList("preferredNetworks")),
|
|
99
86
|
).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
|
|
100
87
|
.cardBrandAcceptance(mapToCardBrandAcceptance(arguments))
|
|
101
88
|
|
|
102
89
|
paymentMethodOrder?.let { configuration.paymentMethodOrder(it) }
|
|
103
|
-
|
|
104
|
-
configuration.defaultBillingDetails(createDefaultBillingDetails(
|
|
90
|
+
billingDetailsMap?.let {
|
|
91
|
+
configuration.defaultBillingDetails(createDefaultBillingDetails(billingDetailsMap))
|
|
105
92
|
}
|
|
106
93
|
billingConfigParams?.let {
|
|
107
94
|
configuration.billingDetailsCollectionConfiguration(
|
|
@@ -109,8 +96,10 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
109
96
|
)
|
|
110
97
|
}
|
|
111
98
|
|
|
112
|
-
val
|
|
113
|
-
|
|
99
|
+
val activity = getCurrentActivityOrResolveWithError(initPromise) ?: return
|
|
100
|
+
|
|
101
|
+
val customerEphemeralKeySecret = arguments.getString("customerEphemeralKeySecret")
|
|
102
|
+
val intentConfiguration = createIntentConfiguration(arguments.getMap("intentConfiguration"))
|
|
114
103
|
if (customerEphemeralKeySecret == null && intentConfiguration == null) {
|
|
115
104
|
initPromise.resolve(
|
|
116
105
|
createError(
|
|
@@ -128,32 +117,34 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
128
117
|
|
|
129
118
|
customerSheet =
|
|
130
119
|
CustomerSheet.create(
|
|
131
|
-
|
|
120
|
+
activity = activity,
|
|
132
121
|
customerSessionProvider = customerSessionProvider,
|
|
133
122
|
callback = ::handleResult,
|
|
134
123
|
)
|
|
135
124
|
} else if (intentConfiguration == null) {
|
|
136
|
-
val customerId = arguments
|
|
125
|
+
val customerId = arguments.getString("customerId")
|
|
137
126
|
if (customerId == null) {
|
|
138
127
|
initPromise.resolve(
|
|
139
|
-
createError(
|
|
128
|
+
createError(
|
|
129
|
+
ErrorType.Failed.toString(),
|
|
130
|
+
"When using `customerEphemeralKeySecret` you must provide a value for `customerId`",
|
|
131
|
+
),
|
|
140
132
|
)
|
|
141
133
|
return
|
|
142
134
|
}
|
|
143
|
-
val setupIntentClientSecret = arguments
|
|
144
|
-
val customerAdapterOverrideParams = arguments?.getBundle("customerAdapter")
|
|
135
|
+
val setupIntentClientSecret = arguments.getString("setupIntentClientSecret")
|
|
145
136
|
val customerAdapter =
|
|
146
137
|
createCustomerAdapter(
|
|
147
138
|
context,
|
|
148
|
-
customerId
|
|
139
|
+
customerId,
|
|
149
140
|
customerEphemeralKeySecret,
|
|
150
141
|
setupIntentClientSecret,
|
|
151
|
-
|
|
142
|
+
customerAdapterOverrides,
|
|
152
143
|
).also { this.customerAdapter = it }
|
|
153
144
|
|
|
154
145
|
customerSheet =
|
|
155
146
|
CustomerSheet.create(
|
|
156
|
-
|
|
147
|
+
activity = activity,
|
|
157
148
|
customerAdapter = customerAdapter,
|
|
158
149
|
callback = ::handleResult,
|
|
159
150
|
)
|
|
@@ -168,7 +159,7 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
168
159
|
|
|
169
160
|
customerSheet?.configure(configuration.build())
|
|
170
161
|
|
|
171
|
-
initPromise.resolve(
|
|
162
|
+
initPromise.resolve(Arguments.createMap())
|
|
172
163
|
}
|
|
173
164
|
|
|
174
165
|
private fun handleResult(result: CustomerSheetResult) {
|
|
@@ -193,16 +184,15 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
193
184
|
resolvePresentPromise(promiseResult)
|
|
194
185
|
}
|
|
195
186
|
|
|
196
|
-
fun
|
|
197
|
-
|
|
198
|
-
promise: Promise,
|
|
199
|
-
) {
|
|
200
|
-
keepJsAwake = context?.let { KeepJsAwakeTask(it).apply { start() } }
|
|
187
|
+
override fun onPresent() {
|
|
188
|
+
keepJsAwake = context.let { KeepJsAwakeTask(it).apply { start() } }
|
|
201
189
|
presentPromise = promise
|
|
190
|
+
val timeout = timeout
|
|
202
191
|
if (timeout != null) {
|
|
203
192
|
presentWithTimeout(timeout)
|
|
193
|
+
} else {
|
|
194
|
+
customerSheet?.present() ?: run { resolvePresentPromise(createMissingInitError()) }
|
|
204
195
|
}
|
|
205
|
-
customerSheet?.present() ?: run { resolvePresentPromise(createMissingInitError()) }
|
|
206
196
|
}
|
|
207
197
|
|
|
208
198
|
private fun presentWithTimeout(timeout: Long) {
|
|
@@ -232,7 +222,7 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
232
222
|
|
|
233
223
|
override fun onActivityDestroyed(activity: Activity) {
|
|
234
224
|
activities = mutableListOf()
|
|
235
|
-
context
|
|
225
|
+
context.currentActivity?.application?.unregisterActivityLifecycleCallbacks(this)
|
|
236
226
|
}
|
|
237
227
|
}
|
|
238
228
|
|
|
@@ -248,7 +238,7 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
248
238
|
)
|
|
249
239
|
|
|
250
240
|
context
|
|
251
|
-
|
|
241
|
+
.currentActivity
|
|
252
242
|
?.application
|
|
253
243
|
?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
254
244
|
|
|
@@ -304,45 +294,21 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
304
294
|
}
|
|
305
295
|
|
|
306
296
|
companion object {
|
|
307
|
-
internal const val TAG = "customer_sheet_launch_fragment"
|
|
308
|
-
|
|
309
297
|
internal fun createMissingInitError(): WritableMap =
|
|
310
298
|
createError(ErrorType.Failed.toString(), "No customer sheet has been initialized yet.")
|
|
311
299
|
|
|
312
|
-
internal fun createDefaultBillingDetails(
|
|
313
|
-
|
|
314
|
-
val address =
|
|
315
|
-
PaymentSheet.Address(
|
|
316
|
-
addressBundle?.getString("city"),
|
|
317
|
-
addressBundle?.getString("country"),
|
|
318
|
-
addressBundle?.getString("line1"),
|
|
319
|
-
addressBundle?.getString("line2"),
|
|
320
|
-
addressBundle?.getString("postalCode"),
|
|
321
|
-
addressBundle?.getString("state"),
|
|
322
|
-
)
|
|
323
|
-
return PaymentSheet.BillingDetails(
|
|
324
|
-
address,
|
|
325
|
-
bundle.getString("email"),
|
|
326
|
-
bundle.getString("name"),
|
|
327
|
-
bundle.getString("phone"),
|
|
328
|
-
)
|
|
329
|
-
}
|
|
300
|
+
internal fun createDefaultBillingDetails(map: ReadableMap): PaymentSheet.BillingDetails =
|
|
301
|
+
buildBillingDetails(map) ?: PaymentSheet.BillingDetails()
|
|
330
302
|
|
|
331
|
-
internal fun createBillingDetailsCollectionConfiguration(
|
|
332
|
-
|
|
333
|
-
name = mapToCollectionMode(bundle.getString("name")),
|
|
334
|
-
phone = mapToCollectionMode(bundle.getString("phone")),
|
|
335
|
-
email = mapToCollectionMode(bundle.getString("email")),
|
|
336
|
-
address = mapToAddressCollectionMode(bundle.getString("address")),
|
|
337
|
-
attachDefaultsToPaymentMethod = bundle.getBoolean("attachDefaultsToPaymentMethod", false),
|
|
338
|
-
)
|
|
303
|
+
internal fun createBillingDetailsCollectionConfiguration(map: ReadableMap): PaymentSheet.BillingDetailsCollectionConfiguration =
|
|
304
|
+
buildBillingDetailsCollectionConfiguration(map)
|
|
339
305
|
|
|
340
306
|
internal fun createCustomerAdapter(
|
|
341
307
|
context: ReactApplicationContext,
|
|
342
308
|
customerId: String,
|
|
343
309
|
customerEphemeralKeySecret: String,
|
|
344
310
|
setupIntentClientSecret: String?,
|
|
345
|
-
customerAdapterOverrideParams:
|
|
311
|
+
customerAdapterOverrideParams: ReadableMap?,
|
|
346
312
|
): ReactNativeCustomerAdapter {
|
|
347
313
|
val ephemeralKeyProvider = {
|
|
348
314
|
CustomerAdapter.Result.success(
|
|
@@ -375,18 +341,17 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
375
341
|
context = context,
|
|
376
342
|
adapter = customerAdapter,
|
|
377
343
|
overridesFetchPaymentMethods =
|
|
378
|
-
customerAdapterOverrideParams
|
|
344
|
+
customerAdapterOverrideParams.getBooleanOr("fetchPaymentMethods", false),
|
|
379
345
|
overridesAttachPaymentMethod =
|
|
380
|
-
customerAdapterOverrideParams
|
|
346
|
+
customerAdapterOverrideParams.getBooleanOr("attachPaymentMethod", false),
|
|
381
347
|
overridesDetachPaymentMethod =
|
|
382
|
-
customerAdapterOverrideParams
|
|
348
|
+
customerAdapterOverrideParams.getBooleanOr("detachPaymentMethod", false),
|
|
383
349
|
overridesSetSelectedPaymentOption =
|
|
384
|
-
customerAdapterOverrideParams
|
|
350
|
+
customerAdapterOverrideParams.getBooleanOr("setSelectedPaymentOption", false),
|
|
385
351
|
overridesFetchSelectedPaymentOption =
|
|
386
|
-
customerAdapterOverrideParams
|
|
352
|
+
customerAdapterOverrideParams.getBooleanOr("fetchSelectedPaymentOption", false),
|
|
387
353
|
overridesSetupIntentClientSecretForCustomerAttach =
|
|
388
|
-
customerAdapterOverrideParams
|
|
389
|
-
?: false,
|
|
354
|
+
customerAdapterOverrideParams.getBooleanOr("setupIntentClientSecretForCustomerAttach", false),
|
|
390
355
|
)
|
|
391
356
|
}
|
|
392
357
|
|
|
@@ -414,15 +379,15 @@ class CustomerSheetFragment : StripeFragment() {
|
|
|
414
379
|
return paymentOptionResult
|
|
415
380
|
}
|
|
416
381
|
|
|
417
|
-
internal fun createIntentConfiguration(intentConfigurationBundle:
|
|
382
|
+
internal fun createIntentConfiguration(intentConfigurationBundle: ReadableMap?): CustomerSheet.IntentConfiguration? =
|
|
418
383
|
intentConfigurationBundle?.let { bundle ->
|
|
419
|
-
val onBehalfOf = bundle
|
|
384
|
+
val onBehalfOf = bundle.getString("onBehalfOf")
|
|
420
385
|
CustomerSheet.IntentConfiguration
|
|
421
386
|
.Builder()
|
|
422
|
-
.paymentMethodTypes(bundle
|
|
387
|
+
.paymentMethodTypes(bundle.getStringList("paymentMethodTypes") ?: emptyList())
|
|
423
388
|
.apply {
|
|
424
389
|
if (onBehalfOf != null) {
|
|
425
|
-
this.onBehalfOf(onBehalfOf
|
|
390
|
+
this.onBehalfOf(onBehalfOf)
|
|
426
391
|
}
|
|
427
392
|
}.build()
|
|
428
393
|
}
|
|
@@ -2,10 +2,8 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
4
|
import com.stripe.android.customersheet.CustomerSheet
|
|
5
|
-
import com.stripe.android.paymentsheet.ExperimentalCustomerSessionApi
|
|
6
5
|
import kotlinx.coroutines.CompletableDeferred
|
|
7
6
|
|
|
8
|
-
@OptIn(ExperimentalCustomerSessionApi::class)
|
|
9
7
|
class ReactNativeCustomerSessionProvider(
|
|
10
8
|
val context: ReactApplicationContext,
|
|
11
9
|
val intentConfiguration: CustomerSheet.IntentConfiguration,
|
|
@@ -13,7 +11,8 @@ class ReactNativeCustomerSessionProvider(
|
|
|
13
11
|
private val stripeSdkModule = context.getNativeModule(StripeSdkModule::class.java)
|
|
14
12
|
|
|
15
13
|
internal var provideSetupIntentClientSecretCallback: CompletableDeferred<String>? = null
|
|
16
|
-
internal var providesCustomerSessionClientSecretCallback:
|
|
14
|
+
internal var providesCustomerSessionClientSecretCallback:
|
|
15
|
+
CompletableDeferred<CustomerSheet.CustomerSessionClientSecret>? = null
|
|
17
16
|
|
|
18
17
|
override suspend fun intentConfiguration(): Result<CustomerSheet.IntentConfiguration> = Result.success(intentConfiguration)
|
|
19
18
|
|