@stripe/stripe-react-native 0.57.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 +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +13 -11
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +17 -21
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherManager.kt +2 -0
- 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 +46 -119
- 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/FinancialConnectionsSheetManager.kt +13 -15
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +1 -1
- 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/PaymentLauncherManager.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +3 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +73 -30
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +19 -245
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +52 -14
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +4 -4
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +15 -35
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- 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 +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +92 -44
- 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 +25 -25
- 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 +210 -71
- 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 -24
- 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 +15 -17
- 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 +30 -25
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +36 -34
- package/ios/StripeSdkImpl.swift +913 -185
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +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/StripeContainer.js +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/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/AddressSheet.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js +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/StripeContainer.js +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/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/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/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +20 -7
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.reactnativestripesdk
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
+
import android.widget.FrameLayout
|
|
4
5
|
import androidx.compose.runtime.Composable
|
|
5
6
|
import androidx.compose.ui.platform.AbstractComposeView
|
|
6
7
|
import androidx.compose.ui.platform.ViewCompositionStrategy
|
|
@@ -17,13 +18,24 @@ import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
|
|
17
18
|
import com.facebook.react.bridge.ReactContext
|
|
18
19
|
|
|
19
20
|
/**
|
|
21
|
+
* A wrapper around Compose views that safely handles React Native's layout system.
|
|
22
|
+
*
|
|
23
|
+
* This uses a FrameLayout wrapper pattern to solve the "Cannot locate windowRecomposer;
|
|
24
|
+
* View is not attached to a window" crash that occurs when React Native measures views
|
|
25
|
+
* before they are attached to the window hierarchy. By extending FrameLayout instead of
|
|
26
|
+
* AbstractComposeView directly, the view can be safely measured before the Compose
|
|
27
|
+
* infrastructure is ready.
|
|
28
|
+
*
|
|
29
|
+
* The inner ComposeView is only created when the wrapper is attached to the window,
|
|
30
|
+
* ensuring the WindowRecomposer is always available.
|
|
31
|
+
*
|
|
20
32
|
* Compose disposes views by default when using Fragments, which is not compatible with how
|
|
21
33
|
* react-native-screens work. To avoid this we change the composition strategy to use the
|
|
22
34
|
* activity lifecycle instead of the fragment. Note that `setViewTreeLifecycleOwner` also
|
|
23
35
|
* needs to be set otherwise a different code path will dispose of the view.
|
|
24
36
|
*
|
|
25
37
|
* **IMPORTANT** Views using this will need to call `handleOnDropViewInstance` manually to avoid leaking.
|
|
26
|
-
* This can be done using the
|
|
38
|
+
* This can be done using the following code in the view manager:
|
|
27
39
|
*
|
|
28
40
|
* ```
|
|
29
41
|
* override fun onDropViewInstance(view: SomeStripeAbstractComposeView) {
|
|
@@ -35,7 +47,7 @@ import com.facebook.react.bridge.ReactContext
|
|
|
35
47
|
*/
|
|
36
48
|
abstract class StripeAbstractComposeView(
|
|
37
49
|
context: Context,
|
|
38
|
-
) :
|
|
50
|
+
) : FrameLayout(context) {
|
|
39
51
|
/**
|
|
40
52
|
* Dummy compose view that will be added at the root of the app, this is needed so that the context
|
|
41
53
|
* that compose needs is already initialized and we can set it directly on our compose views.
|
|
@@ -55,6 +67,7 @@ abstract class StripeAbstractComposeView(
|
|
|
55
67
|
}
|
|
56
68
|
}
|
|
57
69
|
|
|
70
|
+
private var innerComposeView: InnerComposeView? = null
|
|
58
71
|
private var isLifecycleSetup = false
|
|
59
72
|
|
|
60
73
|
// Create a lifecycle this is tied to the activity, but that we can manually
|
|
@@ -67,24 +80,35 @@ abstract class StripeAbstractComposeView(
|
|
|
67
80
|
}
|
|
68
81
|
private var lifecycleRegistry = LifecycleRegistry(lifecycleOwner)
|
|
69
82
|
|
|
70
|
-
init {
|
|
71
|
-
// Setup lifecycles
|
|
72
|
-
setViewCompositionStrategy(
|
|
73
|
-
ViewCompositionStrategy.DisposeOnLifecycleDestroyed(lifecycleOwner = lifecycleOwner),
|
|
74
|
-
)
|
|
75
|
-
setViewTreeLifecycleOwner(lifecycleOwner = lifecycleOwner)
|
|
76
|
-
|
|
77
|
-
// Setup context from dummy compose view.
|
|
78
|
-
(context as ReactContext).getNativeModule(StripeSdkModule::class.java)?.composeCompatView?.let {
|
|
79
|
-
setParentCompositionContext(it.findViewTreeCompositionContext())
|
|
80
|
-
setViewTreeSavedStateRegistryOwner(it.findViewTreeSavedStateRegistryOwner())
|
|
81
|
-
setViewTreeViewModelStoreOwner(it.findViewTreeViewModelStoreOwner())
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
83
|
override fun onAttachedToWindow() {
|
|
86
84
|
super.onAttachedToWindow()
|
|
85
|
+
ensureComposeViewCreated()
|
|
86
|
+
setupActivityLifecycleObserver()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private fun ensureComposeViewCreated() {
|
|
90
|
+
if (innerComposeView != null) return
|
|
91
|
+
|
|
92
|
+
innerComposeView =
|
|
93
|
+
InnerComposeView(context).also { cv ->
|
|
94
|
+
// Setup lifecycles
|
|
95
|
+
cv.setViewCompositionStrategy(
|
|
96
|
+
ViewCompositionStrategy.DisposeOnLifecycleDestroyed(lifecycleOwner = lifecycleOwner),
|
|
97
|
+
)
|
|
98
|
+
cv.setViewTreeLifecycleOwner(lifecycleOwner = lifecycleOwner)
|
|
87
99
|
|
|
100
|
+
// Setup context from dummy compose view (now safe since we're attached to window)
|
|
101
|
+
(context as? ReactContext)?.getNativeModule(StripeSdkModule::class.java)?.composeCompatView?.let {
|
|
102
|
+
cv.setParentCompositionContext(it.findViewTreeCompositionContext())
|
|
103
|
+
cv.setViewTreeSavedStateRegistryOwner(it.findViewTreeSavedStateRegistryOwner())
|
|
104
|
+
cv.setViewTreeViewModelStoreOwner(it.findViewTreeViewModelStoreOwner())
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
addView(cv, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private fun setupActivityLifecycleObserver() {
|
|
88
112
|
if (isLifecycleSetup) {
|
|
89
113
|
return
|
|
90
114
|
}
|
|
@@ -111,4 +135,16 @@ abstract class StripeAbstractComposeView(
|
|
|
111
135
|
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
112
136
|
}
|
|
113
137
|
}
|
|
138
|
+
|
|
139
|
+
@Composable
|
|
140
|
+
abstract fun Content()
|
|
141
|
+
|
|
142
|
+
private inner class InnerComposeView(
|
|
143
|
+
context: Context,
|
|
144
|
+
) : AbstractComposeView(context) {
|
|
145
|
+
@Composable
|
|
146
|
+
override fun Content() {
|
|
147
|
+
this@StripeAbstractComposeView.Content()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
114
150
|
}
|
|
@@ -7,6 +7,7 @@ import android.content.Intent
|
|
|
7
7
|
import android.os.Bundle
|
|
8
8
|
import android.util.Log
|
|
9
9
|
import android.view.ViewGroup
|
|
10
|
+
import androidx.browser.customtabs.CustomTabsIntent
|
|
10
11
|
import androidx.fragment.app.FragmentActivity
|
|
11
12
|
import com.facebook.react.ReactActivity
|
|
12
13
|
import com.facebook.react.bridge.Arguments
|
|
@@ -18,7 +19,6 @@ import com.facebook.react.bridge.ReadableArray
|
|
|
18
19
|
import com.facebook.react.bridge.ReadableMap
|
|
19
20
|
import com.facebook.react.bridge.UiThreadUtil
|
|
20
21
|
import com.facebook.react.bridge.WritableMap
|
|
21
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
22
22
|
import com.facebook.react.module.annotations.ReactModule
|
|
23
23
|
import com.reactnativestripesdk.addresssheet.AddressLauncherManager
|
|
24
24
|
import com.reactnativestripesdk.customersheet.CustomerSheetManager
|
|
@@ -35,6 +35,7 @@ import com.reactnativestripesdk.utils.createMissingInitError
|
|
|
35
35
|
import com.reactnativestripesdk.utils.createResult
|
|
36
36
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
37
37
|
import com.reactnativestripesdk.utils.getIntOrNull
|
|
38
|
+
import com.reactnativestripesdk.utils.getLongOrNull
|
|
38
39
|
import com.reactnativestripesdk.utils.getValOr
|
|
39
40
|
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
40
41
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
@@ -163,7 +164,7 @@ class StripeSdkModule(
|
|
|
163
164
|
|
|
164
165
|
private fun configure3dSecure(params: ReadableMap) {
|
|
165
166
|
val stripe3dsConfigBuilder = PaymentAuthConfig.Stripe3ds2Config.Builder()
|
|
166
|
-
|
|
167
|
+
params.getIntOrNull("timeout")?.let { stripe3dsConfigBuilder.setTimeout(it) }
|
|
167
168
|
val uiCustomization = mapToUICustomization(params)
|
|
168
169
|
|
|
169
170
|
PaymentAuthConfig.init(
|
|
@@ -244,10 +245,10 @@ class StripeSdkModule(
|
|
|
244
245
|
return
|
|
245
246
|
}
|
|
246
247
|
|
|
247
|
-
val
|
|
248
|
-
if (
|
|
248
|
+
val timeout = options.getLongOrNull("timeout")
|
|
249
|
+
if (timeout != null) {
|
|
249
250
|
paymentSheetManager?.presentWithTimeout(
|
|
250
|
-
|
|
251
|
+
timeout,
|
|
251
252
|
promise,
|
|
252
253
|
)
|
|
253
254
|
} else {
|
|
@@ -502,7 +503,7 @@ class StripeSdkModule(
|
|
|
502
503
|
object : ApiResultCallback<Token> {
|
|
503
504
|
override fun onSuccess(result: Token) {
|
|
504
505
|
val tokenId = result.id
|
|
505
|
-
val res =
|
|
506
|
+
val res = Arguments.createMap()
|
|
506
507
|
res.putString("tokenId", tokenId)
|
|
507
508
|
promise.resolve(res)
|
|
508
509
|
}
|
|
@@ -760,6 +761,7 @@ class StripeSdkModule(
|
|
|
760
761
|
return
|
|
761
762
|
}
|
|
762
763
|
|
|
764
|
+
unregisterStripeUIManager(googlePayLauncherManager)
|
|
763
765
|
googlePayLauncherManager =
|
|
764
766
|
GooglePayLauncherManager(
|
|
765
767
|
reactApplicationContext,
|
|
@@ -779,7 +781,7 @@ class StripeSdkModule(
|
|
|
779
781
|
expand = listOf("payment_method"),
|
|
780
782
|
object : ApiResultCallback<PaymentIntent> {
|
|
781
783
|
override fun onError(e: Exception) {
|
|
782
|
-
promise.resolve(createResult("paymentIntent",
|
|
784
|
+
promise.resolve(createResult("paymentIntent", Arguments.createMap()))
|
|
783
785
|
}
|
|
784
786
|
|
|
785
787
|
override fun onSuccess(result: PaymentIntent) {
|
|
@@ -799,7 +801,7 @@ class StripeSdkModule(
|
|
|
799
801
|
expand = listOf("payment_method"),
|
|
800
802
|
object : ApiResultCallback<SetupIntent> {
|
|
801
803
|
override fun onError(e: Exception) {
|
|
802
|
-
promise.resolve(createResult("setupIntent",
|
|
804
|
+
promise.resolve(createResult("setupIntent", Arguments.createMap()))
|
|
803
805
|
}
|
|
804
806
|
|
|
805
807
|
override fun onSuccess(result: SetupIntent) {
|
|
@@ -829,6 +831,9 @@ class StripeSdkModule(
|
|
|
829
831
|
}
|
|
830
832
|
}
|
|
831
833
|
}
|
|
834
|
+
}.also {
|
|
835
|
+
registerStripeUIManager(it)
|
|
836
|
+
it.present()
|
|
832
837
|
}
|
|
833
838
|
}
|
|
834
839
|
|
|
@@ -909,7 +914,7 @@ class StripeSdkModule(
|
|
|
909
914
|
PushProvisioningProxy.isCardInWallet(it, last4) { isCardInWallet, token, error ->
|
|
910
915
|
val result: WritableMap =
|
|
911
916
|
error ?: run {
|
|
912
|
-
val map =
|
|
917
|
+
val map = Arguments.createMap()
|
|
913
918
|
map.putBoolean("isInWallet", isCardInWallet)
|
|
914
919
|
map.putMap("token", token)
|
|
915
920
|
map
|
|
@@ -1129,7 +1134,7 @@ class StripeSdkModule(
|
|
|
1129
1134
|
params: ReadableMap,
|
|
1130
1135
|
promise: Promise,
|
|
1131
1136
|
) {
|
|
1132
|
-
val timeout = params.
|
|
1137
|
+
val timeout = params.getLongOrNull("timeout")
|
|
1133
1138
|
customerSheetManager?.present(promise, timeout) ?: run {
|
|
1134
1139
|
promise.resolve(CustomerSheetManager.createMissingInitError())
|
|
1135
1140
|
}
|
|
@@ -1329,6 +1334,39 @@ class StripeSdkModule(
|
|
|
1329
1334
|
// noop, iOS only
|
|
1330
1335
|
}
|
|
1331
1336
|
|
|
1337
|
+
@ReactMethod
|
|
1338
|
+
override fun openAuthenticatedWebView(
|
|
1339
|
+
id: String,
|
|
1340
|
+
url: String,
|
|
1341
|
+
promise: Promise,
|
|
1342
|
+
) {
|
|
1343
|
+
val activity = getCurrentActivityOrResolveWithError(promise) ?: return
|
|
1344
|
+
|
|
1345
|
+
UiThreadUtil.runOnUiThread {
|
|
1346
|
+
try {
|
|
1347
|
+
val uri = android.net.Uri.parse(url)
|
|
1348
|
+
val builder =
|
|
1349
|
+
androidx.browser.customtabs.CustomTabsIntent
|
|
1350
|
+
.Builder()
|
|
1351
|
+
|
|
1352
|
+
// Set toolbar color for better UX
|
|
1353
|
+
builder.setShowTitle(true)
|
|
1354
|
+
builder.setUrlBarHidingEnabled(true)
|
|
1355
|
+
|
|
1356
|
+
val customTabsIntent = builder.build()
|
|
1357
|
+
|
|
1358
|
+
// Note: Custom Tabs doesn't have built-in redirect handling like iOS ASWebAuthenticationSession.
|
|
1359
|
+
// The redirect will be handled via deep linking when the auth server redirects to stripe-connect://
|
|
1360
|
+
// The React Native Linking module will capture the deep link and pass it back to the JS layer.
|
|
1361
|
+
customTabsIntent.launchUrl(activity, uri)
|
|
1362
|
+
|
|
1363
|
+
promise.resolve(null)
|
|
1364
|
+
} catch (e: Exception) {
|
|
1365
|
+
promise.resolve(createError("Failed", e))
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1332
1370
|
override fun addListener(eventType: String?) {
|
|
1333
1371
|
// noop, iOS only
|
|
1334
1372
|
}
|
|
@@ -1376,7 +1414,7 @@ class StripeSdkModule(
|
|
|
1376
1414
|
* provided will be resolved with an error message instructing the user to retry the method.
|
|
1377
1415
|
*/
|
|
1378
1416
|
private fun getCurrentActivityOrResolveWithError(promise: Promise?): FragmentActivity? {
|
|
1379
|
-
(currentActivity as? FragmentActivity)?.let {
|
|
1417
|
+
(reactApplicationContext.currentActivity as? FragmentActivity)?.let {
|
|
1380
1418
|
return it
|
|
1381
1419
|
}
|
|
1382
1420
|
promise?.resolve(createMissingActivityError())
|
|
@@ -1430,14 +1468,14 @@ class StripeSdkModule(
|
|
|
1430
1468
|
*/
|
|
1431
1469
|
private fun preventActivityRecreation() {
|
|
1432
1470
|
isRecreatingReactActivity = false
|
|
1433
|
-
currentActivity?.application?.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1434
|
-
currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1471
|
+
reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1472
|
+
reactApplicationContext.currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1435
1473
|
}
|
|
1436
1474
|
|
|
1437
1475
|
private fun setupComposeCompatView() {
|
|
1438
1476
|
UiThreadUtil.runOnUiThread {
|
|
1439
1477
|
composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(context = reactApplicationContext).also {
|
|
1440
|
-
currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
|
|
1478
|
+
reactApplicationContext.currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
|
|
1441
1479
|
it,
|
|
1442
1480
|
)
|
|
1443
1481
|
}
|
|
@@ -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
|
}
|
|
@@ -3,9 +3,9 @@ package com.reactnativestripesdk.addresssheet
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.util.Log
|
|
5
5
|
import android.widget.FrameLayout
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
6
7
|
import com.facebook.react.bridge.ReadableMap
|
|
7
8
|
import com.facebook.react.bridge.WritableMap
|
|
8
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
9
9
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
10
10
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
11
11
|
import com.reactnativestripesdk.buildPaymentSheetAppearance
|
|
@@ -172,14 +172,14 @@ class AddressSheetView(
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
internal fun buildResult(addressDetails: AddressDetails): WritableMap =
|
|
175
|
-
|
|
175
|
+
Arguments.createMap().apply {
|
|
176
176
|
putMap(
|
|
177
177
|
"result",
|
|
178
|
-
|
|
178
|
+
Arguments.createMap().apply {
|
|
179
179
|
putString("name", addressDetails.name)
|
|
180
180
|
putMap(
|
|
181
181
|
"address",
|
|
182
|
-
|
|
182
|
+
Arguments.createMap().apply {
|
|
183
183
|
putString("city", addressDetails.address?.city)
|
|
184
184
|
putString("country", addressDetails.address?.country)
|
|
185
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")
|
package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt
CHANGED
|
@@ -12,17 +12,14 @@ import com.facebook.react.bridge.Promise
|
|
|
12
12
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
13
|
import com.facebook.react.bridge.ReadableMap
|
|
14
14
|
import com.facebook.react.bridge.WritableMap
|
|
15
|
-
import com.facebook.react.bridge.WritableNativeMap
|
|
16
15
|
import com.reactnativestripesdk.ReactNativeCustomerAdapter
|
|
17
16
|
import com.reactnativestripesdk.ReactNativeCustomerSessionProvider
|
|
17
|
+
import com.reactnativestripesdk.buildBillingDetails
|
|
18
|
+
import com.reactnativestripesdk.buildBillingDetailsCollectionConfiguration
|
|
18
19
|
import com.reactnativestripesdk.buildPaymentSheetAppearance
|
|
19
20
|
import com.reactnativestripesdk.getBase64FromBitmap
|
|
20
21
|
import com.reactnativestripesdk.getBitmapFromDrawable
|
|
21
|
-
import com.reactnativestripesdk.getIntegerArrayList
|
|
22
|
-
import com.reactnativestripesdk.getStringArrayList
|
|
23
|
-
import com.reactnativestripesdk.mapToAddressCollectionMode
|
|
24
22
|
import com.reactnativestripesdk.mapToCardBrandAcceptance
|
|
25
|
-
import com.reactnativestripesdk.mapToCollectionMode
|
|
26
23
|
import com.reactnativestripesdk.utils.CreateTokenErrorType
|
|
27
24
|
import com.reactnativestripesdk.utils.ErrorType
|
|
28
25
|
import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
@@ -30,6 +27,8 @@ import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
|
30
27
|
import com.reactnativestripesdk.utils.StripeUIManager
|
|
31
28
|
import com.reactnativestripesdk.utils.createError
|
|
32
29
|
import com.reactnativestripesdk.utils.getBooleanOr
|
|
30
|
+
import com.reactnativestripesdk.utils.getIntegerList
|
|
31
|
+
import com.reactnativestripesdk.utils.getStringList
|
|
33
32
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
34
33
|
import com.reactnativestripesdk.utils.mapToPreferredNetworks
|
|
35
34
|
import com.stripe.android.ExperimentalAllowsRemovalOfLastSavedPaymentMethodApi
|
|
@@ -66,7 +65,7 @@ class CustomerSheetManager(
|
|
|
66
65
|
val billingConfigParams = arguments.getMap("billingDetailsCollectionConfiguration")
|
|
67
66
|
val allowsRemovalOfLastSavedPaymentMethod =
|
|
68
67
|
arguments.getBooleanOr("allowsRemovalOfLastSavedPaymentMethod", true)
|
|
69
|
-
val paymentMethodOrder = arguments.
|
|
68
|
+
val paymentMethodOrder = arguments.getStringList("paymentMethodOrder")
|
|
70
69
|
|
|
71
70
|
val appearance =
|
|
72
71
|
try {
|
|
@@ -83,7 +82,7 @@ class CustomerSheetManager(
|
|
|
83
82
|
.googlePayEnabled(googlePayEnabled)
|
|
84
83
|
.headerTextForSelectionScreen(headerTextForSelectionScreen)
|
|
85
84
|
.preferredNetworks(
|
|
86
|
-
mapToPreferredNetworks(arguments.
|
|
85
|
+
mapToPreferredNetworks(arguments.getIntegerList("preferredNetworks")),
|
|
87
86
|
).allowsRemovalOfLastSavedPaymentMethod(allowsRemovalOfLastSavedPaymentMethod)
|
|
88
87
|
.cardBrandAcceptance(mapToCardBrandAcceptance(arguments))
|
|
89
88
|
|
|
@@ -126,7 +125,10 @@ class CustomerSheetManager(
|
|
|
126
125
|
val customerId = arguments.getString("customerId")
|
|
127
126
|
if (customerId == null) {
|
|
128
127
|
initPromise.resolve(
|
|
129
|
-
createError(
|
|
128
|
+
createError(
|
|
129
|
+
ErrorType.Failed.toString(),
|
|
130
|
+
"When using `customerEphemeralKeySecret` you must provide a value for `customerId`",
|
|
131
|
+
),
|
|
130
132
|
)
|
|
131
133
|
return
|
|
132
134
|
}
|
|
@@ -157,7 +159,7 @@ class CustomerSheetManager(
|
|
|
157
159
|
|
|
158
160
|
customerSheet?.configure(configuration.build())
|
|
159
161
|
|
|
160
|
-
initPromise.resolve(
|
|
162
|
+
initPromise.resolve(Arguments.createMap())
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
private fun handleResult(result: CustomerSheetResult) {
|
|
@@ -295,33 +297,11 @@ class CustomerSheetManager(
|
|
|
295
297
|
internal fun createMissingInitError(): WritableMap =
|
|
296
298
|
createError(ErrorType.Failed.toString(), "No customer sheet has been initialized yet.")
|
|
297
299
|
|
|
298
|
-
internal fun createDefaultBillingDetails(map: ReadableMap): PaymentSheet.BillingDetails
|
|
299
|
-
|
|
300
|
-
val address =
|
|
301
|
-
PaymentSheet.Address(
|
|
302
|
-
addressMap?.getString("city"),
|
|
303
|
-
addressMap?.getString("country"),
|
|
304
|
-
addressMap?.getString("line1"),
|
|
305
|
-
addressMap?.getString("line2"),
|
|
306
|
-
addressMap?.getString("postalCode"),
|
|
307
|
-
addressMap?.getString("state"),
|
|
308
|
-
)
|
|
309
|
-
return PaymentSheet.BillingDetails(
|
|
310
|
-
address,
|
|
311
|
-
map.getString("email"),
|
|
312
|
-
map.getString("name"),
|
|
313
|
-
map.getString("phone"),
|
|
314
|
-
)
|
|
315
|
-
}
|
|
300
|
+
internal fun createDefaultBillingDetails(map: ReadableMap): PaymentSheet.BillingDetails =
|
|
301
|
+
buildBillingDetails(map) ?: PaymentSheet.BillingDetails()
|
|
316
302
|
|
|
317
303
|
internal fun createBillingDetailsCollectionConfiguration(map: ReadableMap): PaymentSheet.BillingDetailsCollectionConfiguration =
|
|
318
|
-
|
|
319
|
-
name = mapToCollectionMode(map.getString("name")),
|
|
320
|
-
phone = mapToCollectionMode(map.getString("phone")),
|
|
321
|
-
email = mapToCollectionMode(map.getString("email")),
|
|
322
|
-
address = mapToAddressCollectionMode(map.getString("address")),
|
|
323
|
-
attachDefaultsToPaymentMethod = map.getBooleanOr("attachDefaultsToPaymentMethod", false),
|
|
324
|
-
)
|
|
304
|
+
buildBillingDetailsCollectionConfiguration(map)
|
|
325
305
|
|
|
326
306
|
internal fun createCustomerAdapter(
|
|
327
307
|
context: ReactApplicationContext,
|
|
@@ -404,7 +384,7 @@ class CustomerSheetManager(
|
|
|
404
384
|
val onBehalfOf = bundle.getString("onBehalfOf")
|
|
405
385
|
CustomerSheet.IntentConfiguration
|
|
406
386
|
.Builder()
|
|
407
|
-
.paymentMethodTypes(bundle.
|
|
387
|
+
.paymentMethodTypes(bundle.getStringList("paymentMethodTypes") ?: emptyList())
|
|
408
388
|
.apply {
|
|
409
389
|
if (onBehalfOf != null) {
|
|
410
390
|
this.onBehalfOf(onBehalfOf)
|
|
@@ -11,7 +11,8 @@ class ReactNativeCustomerSessionProvider(
|
|
|
11
11
|
private val stripeSdkModule = context.getNativeModule(StripeSdkModule::class.java)
|
|
12
12
|
|
|
13
13
|
internal var provideSetupIntentClientSecretCallback: CompletableDeferred<String>? = null
|
|
14
|
-
internal var providesCustomerSessionClientSecretCallback:
|
|
14
|
+
internal var providesCustomerSessionClientSecretCallback:
|
|
15
|
+
CompletableDeferred<CustomerSheet.CustomerSessionClientSecret>? = null
|
|
15
16
|
|
|
16
17
|
override suspend fun intentConfiguration(): Result<CustomerSheet.IntentConfiguration> = Result.success(intentConfiguration)
|
|
17
18
|
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
package com.reactnativestripesdk.pushprovisioning
|
|
2
2
|
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import com.bumptech.glide.Glide
|
|
5
3
|
import com.facebook.react.bridge.Dynamic
|
|
6
4
|
import com.facebook.react.bridge.ReadableMap
|
|
7
5
|
import com.facebook.react.module.annotations.ReactModule
|
|
@@ -13,12 +11,10 @@ import com.facebook.react.viewmanagers.AddToWalletButtonManagerInterface
|
|
|
13
11
|
import com.reactnativestripesdk.utils.asMapOrNull
|
|
14
12
|
|
|
15
13
|
@ReactModule(name = AddToWalletButtonManager.REACT_CLASS)
|
|
16
|
-
class AddToWalletButtonManager
|
|
17
|
-
|
|
18
|
-
) : SimpleViewManager<AddToWalletButtonView>(),
|
|
14
|
+
class AddToWalletButtonManager :
|
|
15
|
+
SimpleViewManager<AddToWalletButtonView>(),
|
|
19
16
|
AddToWalletButtonManagerInterface<AddToWalletButtonView> {
|
|
20
17
|
private val delegate = AddToWalletButtonManagerDelegate(this)
|
|
21
|
-
private val requestManager = Glide.with(applicationContext)
|
|
22
18
|
|
|
23
19
|
override fun getName() = REACT_CLASS
|
|
24
20
|
|
|
@@ -34,8 +30,7 @@ class AddToWalletButtonManager(
|
|
|
34
30
|
view.onAfterUpdateTransaction()
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView =
|
|
38
|
-
AddToWalletButtonView(reactContext, requestManager)
|
|
33
|
+
override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView = AddToWalletButtonView(reactContext)
|
|
39
34
|
|
|
40
35
|
override fun getExportedCustomDirectEventTypeConstants() =
|
|
41
36
|
mutableMapOf(
|
|
@@ -64,7 +59,7 @@ class AddToWalletButtonManager(
|
|
|
64
59
|
view: AddToWalletButtonView,
|
|
65
60
|
ephemeralKey: Dynamic,
|
|
66
61
|
) {
|
|
67
|
-
val map = ephemeralKey.
|
|
62
|
+
val map = ephemeralKey.asMapOrNull()
|
|
68
63
|
if (map == null) return
|
|
69
64
|
view.setEphemeralKey(map)
|
|
70
65
|
}
|
|
@@ -74,7 +69,7 @@ class AddToWalletButtonManager(
|
|
|
74
69
|
view: AddToWalletButtonView,
|
|
75
70
|
token: Dynamic,
|
|
76
71
|
) {
|
|
77
|
-
val map = token.
|
|
72
|
+
val map = token.asMapOrNull()
|
|
78
73
|
if (map == null) return
|
|
79
74
|
view.setToken(map)
|
|
80
75
|
}
|