@stripe/stripe-react-native 0.65.0 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/android/detekt/detekt-baseline.xml +1 -76
- package/android/gradle.properties +4 -4
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +56 -58
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementEvent.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +139 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +59 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +105 -49
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +72 -12
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +8 -4
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +26 -11
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +14 -5
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +8 -4
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +9 -3
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +118 -48
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +281 -46
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +8 -18
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutAddressUpdate.kt +45 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +127 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/DefaultActivityLifecycleCallbacks.kt +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +4 -2
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +29 -13
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -1
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +6 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerDelegate.java +35 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerInterface.java +18 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +17 -3
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +13 -1
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +116 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +109 -1
- package/android/src/test/java/com/reactnativestripesdk/DrawableLoadingTest.kt +6 -2
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +60 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +145 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +9 -4
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +98 -0
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +57 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +6 -8
- package/ios/CurrencySelectorElementManager.m +16 -0
- package/ios/CurrencySelectorElementView.swift +159 -0
- package/ios/EmbeddedPaymentElementView.swift +1 -1
- package/ios/Mappers+Checkout.swift +337 -0
- package/ios/Mappers.swift +90 -2
- package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +16 -2
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.h +10 -0
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +89 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +6 -0
- package/ios/PaymentOptionDisplayData+ReactNative.swift +1 -1
- package/ios/PaymentSheetAppearance.swift +1 -1
- package/ios/StripeOnrampSdk.mm +19 -0
- package/ios/StripeSdk.mm +136 -0
- package/ios/StripeSdkEmitter.swift +1 -0
- package/ios/StripeSdkImpl+Checkout.swift +360 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
- package/ios/StripeSdkImpl+Embedded.swift +108 -27
- package/ios/StripeSdkImpl+PaymentSheet.swift +18 -2
- package/ios/StripeSdkImpl.swift +89 -7
- package/jest/mock.js +13 -1
- 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/CurrencySelectorElement.js +2 -0
- package/lib/commonjs/components/CurrencySelectorElement.js.map +1 -0
- package/lib/commonjs/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/components/PaymentMethodMessagingElement.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/connect/Components.js +1 -1
- package/lib/commonjs/connect/Components.js.map +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
- package/lib/commonjs/connect/NavigationBar.js +1 -1
- package/lib/commonjs/connect/NavigationBar.js.map +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/hooks/useCheckout.js +1 -1
- package/lib/commonjs/hooks/useCheckout.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +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 +1 -1
- package/lib/commonjs/specs/NativeCurrencySelectorElement.js +2 -0
- package/lib/commonjs/specs/NativeCurrencySelectorElement.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/NativeNavigationBar.js +1 -1
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js +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/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/CurrencySelectorElement.js +2 -0
- package/lib/module/components/CurrencySelectorElement.js.map +1 -0
- package/lib/module/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/module/components/PaymentMethodMessagingElement.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/connect/Components.js +1 -1
- package/lib/module/connect/Components.js.map +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/module/connect/EmbeddedComponent.js +1 -1
- package/lib/module/connect/EmbeddedComponent.js.map +1 -1
- package/lib/module/connect/ModalCloseButton.js +1 -1
- package/lib/module/connect/ModalCloseButton.js.map +1 -1
- package/lib/module/connect/NavigationBar.js +1 -1
- package/lib/module/connect/NavigationBar.js.map +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/hooks/useCheckout.js +1 -1
- package/lib/module/hooks/useCheckout.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +1 -1
- package/lib/module/hooks/useOnramp.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +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 +1 -1
- package/lib/module/specs/NativeCurrencySelectorElement.js +2 -0
- package/lib/module/specs/NativeCurrencySelectorElement.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/NativeNavigationBar.js +1 -1
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js +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/typescript/src/components/CurrencySelectorElement.d.ts +62 -0
- package/lib/typescript/src/components/CurrencySelectorElement.d.ts.map +1 -0
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts +1 -1
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts +11 -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/hooks/useCheckout.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +22 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts +25 -0
- package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +5 -1
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +5 -2
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +268 -86
- package/lib/typescript/src/types/Checkout.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +36 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +94 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
- package/package.json +16 -4
- package/src/components/CurrencySelectorElement.tsx +95 -0
- package/src/components/PaymentMethodMessagingElement.tsx +54 -52
- package/src/events.ts +11 -0
- package/src/functions.ts +30 -1
- package/src/hooks/useCheckout.tsx +129 -74
- package/src/hooks/useOnramp.tsx +44 -0
- package/src/specs/NativeCurrencySelectorElement.ts +35 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +12 -2
- package/src/specs/NativeOnrampSdkModule.ts +5 -0
- package/src/specs/NativeStripeSdkModule.ts +16 -2
- package/src/types/Checkout.ts +291 -86
- package/src/types/EmbeddedPaymentElement.tsx +117 -26
- package/src/types/Onramp.ts +109 -0
- package/stripe-react-native.podspec +1 -1
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -835
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -17
- 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
|
@@ -2,7 +2,6 @@ package com.reactnativestripesdk
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.app.Activity
|
|
5
|
-
import android.app.Application
|
|
6
5
|
import android.content.Intent
|
|
7
6
|
import android.os.Bundle
|
|
8
7
|
import android.os.Handler
|
|
@@ -10,7 +9,6 @@ import android.os.Looper
|
|
|
10
9
|
import android.util.Log
|
|
11
10
|
import android.view.ViewGroup
|
|
12
11
|
import androidx.appcompat.app.AppCompatActivity
|
|
13
|
-
import androidx.browser.customtabs.CustomTabsIntent
|
|
14
12
|
import androidx.core.net.toUri
|
|
15
13
|
import androidx.fragment.app.FragmentActivity
|
|
16
14
|
import com.facebook.react.ReactActivity
|
|
@@ -31,11 +29,13 @@ import com.reactnativestripesdk.customersheet.CustomerSheetManager
|
|
|
31
29
|
import com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy
|
|
32
30
|
import com.reactnativestripesdk.utils.ConfirmPaymentErrorType
|
|
33
31
|
import com.reactnativestripesdk.utils.CreateTokenErrorType
|
|
32
|
+
import com.reactnativestripesdk.utils.DefaultActivityLifecycleCallbacks
|
|
34
33
|
import com.reactnativestripesdk.utils.ErrorType
|
|
35
34
|
import com.reactnativestripesdk.utils.GooglePayErrorType
|
|
36
35
|
import com.reactnativestripesdk.utils.RetrievePaymentIntentErrorType
|
|
37
36
|
import com.reactnativestripesdk.utils.RetrieveSetupIntentErrorType
|
|
38
37
|
import com.reactnativestripesdk.utils.StripeUIManager
|
|
38
|
+
import com.reactnativestripesdk.utils.buildCheckoutAddressUpdate
|
|
39
39
|
import com.reactnativestripesdk.utils.createCanAddCardResult
|
|
40
40
|
import com.reactnativestripesdk.utils.createError
|
|
41
41
|
import com.reactnativestripesdk.utils.createMissingActivityError
|
|
@@ -45,6 +45,7 @@ import com.reactnativestripesdk.utils.getBooleanOr
|
|
|
45
45
|
import com.reactnativestripesdk.utils.getIntOrNull
|
|
46
46
|
import com.reactnativestripesdk.utils.getLongOrNull
|
|
47
47
|
import com.reactnativestripesdk.utils.getValOr
|
|
48
|
+
import com.reactnativestripesdk.utils.mapFromCheckoutState
|
|
48
49
|
import com.reactnativestripesdk.utils.mapFromPaymentIntentResult
|
|
49
50
|
import com.reactnativestripesdk.utils.mapFromPaymentMethod
|
|
50
51
|
import com.reactnativestripesdk.utils.mapFromSetupIntentResult
|
|
@@ -55,11 +56,13 @@ import com.reactnativestripesdk.utils.mapToPaymentMethodType
|
|
|
55
56
|
import com.reactnativestripesdk.utils.mapToReturnURL
|
|
56
57
|
import com.reactnativestripesdk.utils.mapToShippingDetails
|
|
57
58
|
import com.reactnativestripesdk.utils.mapToUICustomization
|
|
59
|
+
import com.reactnativestripesdk.utils.toCheckoutAddress
|
|
58
60
|
import com.stripe.android.ApiResultCallback
|
|
59
61
|
import com.stripe.android.GooglePayJsonFactory
|
|
60
62
|
import com.stripe.android.PaymentAuthConfig
|
|
61
63
|
import com.stripe.android.PaymentConfiguration
|
|
62
64
|
import com.stripe.android.Stripe
|
|
65
|
+
import com.stripe.android.checkout.Checkout
|
|
63
66
|
import com.stripe.android.core.ApiVersion
|
|
64
67
|
import com.stripe.android.core.AppInfo
|
|
65
68
|
import com.stripe.android.core.reactnative.ReactNativeAnalytics
|
|
@@ -75,16 +78,23 @@ import com.stripe.android.model.PaymentMethod
|
|
|
75
78
|
import com.stripe.android.model.RadarSession
|
|
76
79
|
import com.stripe.android.model.SetupIntent
|
|
77
80
|
import com.stripe.android.model.Token
|
|
81
|
+
import com.stripe.android.paymentelement.CheckoutSessionPreview
|
|
78
82
|
import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration
|
|
79
83
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
84
|
+
import kotlinx.coroutines.CancellableContinuation
|
|
80
85
|
import kotlinx.coroutines.CompletableDeferred
|
|
81
86
|
import kotlinx.coroutines.CoroutineScope
|
|
82
87
|
import kotlinx.coroutines.Dispatchers
|
|
88
|
+
import kotlinx.coroutines.Job
|
|
89
|
+
import kotlinx.coroutines.flow.combine
|
|
90
|
+
import kotlinx.coroutines.flow.distinctUntilChanged
|
|
83
91
|
import kotlinx.coroutines.launch
|
|
92
|
+
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
84
93
|
import org.json.JSONObject
|
|
94
|
+
import java.util.UUID
|
|
85
95
|
|
|
86
96
|
@ReactModule(name = StripeSdkModule.NAME)
|
|
87
|
-
@OptIn(ReactNativeSdkInternal::class)
|
|
97
|
+
@OptIn(ReactNativeSdkInternal::class, CheckoutSessionPreview::class)
|
|
88
98
|
class StripeSdkModule(
|
|
89
99
|
reactContext: ReactApplicationContext,
|
|
90
100
|
) : NativeStripeSdkModuleSpec(reactContext) {
|
|
@@ -106,6 +116,14 @@ class StripeSdkModule(
|
|
|
106
116
|
private var financialConnectionsSheetManager: FinancialConnectionsSheetManager? = null
|
|
107
117
|
private var googlePayLauncherManager: GooglePayLauncherManager? = null
|
|
108
118
|
private var googlePayPaymentMethodLauncherManager: GooglePayPaymentMethodLauncherManager? = null
|
|
119
|
+
internal val checkoutInstances = mutableMapOf<String, Checkout>()
|
|
120
|
+
private val serverUpdateContinuations =
|
|
121
|
+
mutableMapOf<String, CancellableContinuation<Result<Unit>>>()
|
|
122
|
+
|
|
123
|
+
// / Tracks the long-running coroutine that observes each Checkout's
|
|
124
|
+
// / `checkoutSession` + `isLoading` flows and forwards transitions to JS as
|
|
125
|
+
// / `checkoutSessionDidChangeState` events.
|
|
126
|
+
private val checkoutStateObservers = mutableMapOf<String, Job>()
|
|
109
127
|
|
|
110
128
|
private var customerSheetManager: CustomerSheetManager? = null
|
|
111
129
|
|
|
@@ -158,6 +176,9 @@ class StripeSdkModule(
|
|
|
158
176
|
|
|
159
177
|
stripeUIManagers.forEach { it.destroy() }
|
|
160
178
|
stripeUIManagers.clear()
|
|
179
|
+
checkoutStateObservers.values.forEach { it.cancel() }
|
|
180
|
+
checkoutStateObservers.clear()
|
|
181
|
+
checkoutInstances.clear()
|
|
161
182
|
}
|
|
162
183
|
|
|
163
184
|
private fun registerStripeUIManager(uiManager: StripeUIManager) {
|
|
@@ -278,7 +299,7 @@ class StripeSdkModule(
|
|
|
278
299
|
}
|
|
279
300
|
} else {
|
|
280
301
|
paymentSheetManager =
|
|
281
|
-
PaymentSheetManager(reactApplicationContext, params, promise).also {
|
|
302
|
+
PaymentSheetManager(reactApplicationContext, params, promise, checkoutInstances).also {
|
|
282
303
|
registerStripeUIManager(it)
|
|
283
304
|
}
|
|
284
305
|
}
|
|
@@ -1382,13 +1403,28 @@ class StripeSdkModule(
|
|
|
1382
1403
|
)
|
|
1383
1404
|
}
|
|
1384
1405
|
|
|
1406
|
+
// Android owns EmbeddedPaymentElement through its native view. Configuration,
|
|
1407
|
+
// update, confirm, and clear commands are handled by EmbeddedPaymentElementViewManager
|
|
1408
|
+
// so they can target the mounted Compose view instance. iOS stores its
|
|
1409
|
+
// EmbeddedPaymentElement on StripeSdkImpl instead, so the shared TurboModule
|
|
1410
|
+
// spec includes these module methods for the iOS implementation.
|
|
1411
|
+
|
|
1385
1412
|
@ReactMethod
|
|
1386
1413
|
override fun createEmbeddedPaymentElement(
|
|
1387
1414
|
intentConfig: ReadableMap,
|
|
1388
1415
|
configuration: ReadableMap,
|
|
1389
1416
|
promise: Promise,
|
|
1390
1417
|
) {
|
|
1391
|
-
|
|
1418
|
+
promise.resolve(null)
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
@ReactMethod
|
|
1422
|
+
override fun createEmbeddedPaymentElementWithCheckout(
|
|
1423
|
+
sessionKey: String,
|
|
1424
|
+
configuration: ReadableMap,
|
|
1425
|
+
promise: Promise,
|
|
1426
|
+
) {
|
|
1427
|
+
promise.resolve(null)
|
|
1392
1428
|
}
|
|
1393
1429
|
|
|
1394
1430
|
@ReactMethod
|
|
@@ -1396,7 +1432,7 @@ class StripeSdkModule(
|
|
|
1396
1432
|
viewTag: Double,
|
|
1397
1433
|
promise: Promise,
|
|
1398
1434
|
) {
|
|
1399
|
-
//
|
|
1435
|
+
// No-op on Android. JS dispatches confirm through the view command instead.
|
|
1400
1436
|
}
|
|
1401
1437
|
|
|
1402
1438
|
@ReactMethod
|
|
@@ -1407,12 +1443,21 @@ class StripeSdkModule(
|
|
|
1407
1443
|
// TODO:
|
|
1408
1444
|
}
|
|
1409
1445
|
|
|
1446
|
+
@ReactMethod
|
|
1447
|
+
override fun updateEmbeddedPaymentElementWithCheckout(
|
|
1448
|
+
sessionKey: String,
|
|
1449
|
+
promise: Promise,
|
|
1450
|
+
) {
|
|
1451
|
+
// No-op on Android. JS dispatches Checkout updates through the view command instead.
|
|
1452
|
+
promise.resolve(null)
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1410
1455
|
@ReactMethod
|
|
1411
1456
|
override fun clearEmbeddedPaymentOption(
|
|
1412
1457
|
viewTag: Double,
|
|
1413
1458
|
promise: Promise,
|
|
1414
1459
|
) {
|
|
1415
|
-
//
|
|
1460
|
+
// No-op on Android. JS dispatches clear through the view command instead.
|
|
1416
1461
|
}
|
|
1417
1462
|
|
|
1418
1463
|
@ReactMethod
|
|
@@ -1563,7 +1608,7 @@ class StripeSdkModule(
|
|
|
1563
1608
|
// Schedule cleanup
|
|
1564
1609
|
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
|
|
1565
1610
|
file.delete()
|
|
1566
|
-
},
|
|
1611
|
+
}, FILE_CLEANUP_DELAY_MS)
|
|
1567
1612
|
|
|
1568
1613
|
promise.resolve(
|
|
1569
1614
|
Arguments.createMap().apply {
|
|
@@ -1695,10 +1740,40 @@ class StripeSdkModule(
|
|
|
1695
1740
|
// noop, iOS only.
|
|
1696
1741
|
}
|
|
1697
1742
|
|
|
1698
|
-
|
|
1743
|
+
override fun initCheckoutSession(
|
|
1744
|
+
clientSecret: String,
|
|
1745
|
+
configuration: ReadableMap,
|
|
1746
|
+
promise: Promise,
|
|
1747
|
+
) {
|
|
1748
|
+
val checkoutConfiguration = buildCheckoutConfiguration(configuration)
|
|
1749
|
+
|
|
1750
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
1751
|
+
Checkout.configure(
|
|
1752
|
+
context = reactApplicationContext,
|
|
1753
|
+
checkoutSessionClientSecret = clientSecret,
|
|
1754
|
+
configuration = checkoutConfiguration,
|
|
1755
|
+
).fold(
|
|
1756
|
+
onSuccess = { checkout ->
|
|
1757
|
+
val sessionKey = UUID.randomUUID().toString()
|
|
1758
|
+
checkoutInstances[sessionKey] = checkout
|
|
1759
|
+
observeCheckoutState(sessionKey, checkout)
|
|
1699
1760
|
|
|
1700
|
-
|
|
1701
|
-
|
|
1761
|
+
promise.resolve(
|
|
1762
|
+
Arguments.createMap().apply {
|
|
1763
|
+
putString("sessionKey", sessionKey)
|
|
1764
|
+
putMap("state", mapFromCheckoutState(checkout))
|
|
1765
|
+
},
|
|
1766
|
+
)
|
|
1767
|
+
},
|
|
1768
|
+
onFailure = { error ->
|
|
1769
|
+
promise.reject(
|
|
1770
|
+
ErrorType.Failed.toString(),
|
|
1771
|
+
error.message ?: "Failed to initialize checkout session.",
|
|
1772
|
+
error,
|
|
1773
|
+
)
|
|
1774
|
+
},
|
|
1775
|
+
)
|
|
1776
|
+
}
|
|
1702
1777
|
}
|
|
1703
1778
|
|
|
1704
1779
|
override fun checkoutUpdateShippingAddress(
|
|
@@ -1708,7 +1783,21 @@ class StripeSdkModule(
|
|
|
1708
1783
|
phone: String?,
|
|
1709
1784
|
promise: Promise,
|
|
1710
1785
|
) {
|
|
1711
|
-
|
|
1786
|
+
val addressUpdate = buildCheckoutAddressUpdate(name, phone, address) ?: run {
|
|
1787
|
+
promise.reject(ErrorType.Failed.toString(), "A shipping address country is required.")
|
|
1788
|
+
return
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
performCheckoutMutation(
|
|
1792
|
+
sessionKey = sessionKey,
|
|
1793
|
+
promise = promise,
|
|
1794
|
+
) { checkout ->
|
|
1795
|
+
checkout.updateShippingAddress(
|
|
1796
|
+
name = addressUpdate.name,
|
|
1797
|
+
phoneNumber = addressUpdate.phone,
|
|
1798
|
+
address = addressUpdate.toCheckoutAddress(),
|
|
1799
|
+
)
|
|
1800
|
+
}
|
|
1712
1801
|
}
|
|
1713
1802
|
|
|
1714
1803
|
override fun checkoutUpdateBillingAddress(
|
|
@@ -1718,15 +1807,40 @@ class StripeSdkModule(
|
|
|
1718
1807
|
phone: String?,
|
|
1719
1808
|
promise: Promise,
|
|
1720
1809
|
) {
|
|
1721
|
-
|
|
1810
|
+
val addressUpdate = buildCheckoutAddressUpdate(name, phone, address) ?: run {
|
|
1811
|
+
promise.reject(ErrorType.Failed.toString(), "A billing address country is required.")
|
|
1812
|
+
return
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
performCheckoutMutation(
|
|
1816
|
+
sessionKey = sessionKey,
|
|
1817
|
+
promise = promise,
|
|
1818
|
+
) { checkout ->
|
|
1819
|
+
checkout.updateBillingAddress(
|
|
1820
|
+
name = addressUpdate.name,
|
|
1821
|
+
phoneNumber = addressUpdate.phone,
|
|
1822
|
+
address = addressUpdate.toCheckoutAddress(),
|
|
1823
|
+
)
|
|
1824
|
+
}
|
|
1722
1825
|
}
|
|
1723
1826
|
|
|
1724
|
-
override fun checkoutApplyPromotionCode(
|
|
1725
|
-
|
|
1827
|
+
override fun checkoutApplyPromotionCode(
|
|
1828
|
+
sessionKey: String,
|
|
1829
|
+
code: String,
|
|
1830
|
+
promise: Promise,
|
|
1831
|
+
) {
|
|
1832
|
+
performCheckoutMutation(sessionKey, promise) { checkout ->
|
|
1833
|
+
checkout.applyPromotionCode(code)
|
|
1834
|
+
}
|
|
1726
1835
|
}
|
|
1727
1836
|
|
|
1728
|
-
override fun checkoutRemovePromotionCode(
|
|
1729
|
-
|
|
1837
|
+
override fun checkoutRemovePromotionCode(
|
|
1838
|
+
sessionKey: String,
|
|
1839
|
+
promise: Promise,
|
|
1840
|
+
) {
|
|
1841
|
+
performCheckoutMutation(sessionKey, promise) { checkout ->
|
|
1842
|
+
checkout.removePromotionCode()
|
|
1843
|
+
}
|
|
1730
1844
|
}
|
|
1731
1845
|
|
|
1732
1846
|
override fun checkoutUpdateLineItemQuantity(
|
|
@@ -1735,19 +1849,149 @@ class StripeSdkModule(
|
|
|
1735
1849
|
quantity: Double,
|
|
1736
1850
|
promise: Promise,
|
|
1737
1851
|
) {
|
|
1738
|
-
|
|
1852
|
+
if (!quantity.isFinite() || quantity % 1.0 != 0.0) {
|
|
1853
|
+
promise.reject(ErrorType.Failed.toString(), "Line item quantity must be an integer.")
|
|
1854
|
+
return
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
performCheckoutMutation(sessionKey, promise) { checkout ->
|
|
1858
|
+
checkout.updateLineItemQuantity(lineItemId = lineItemId, quantity = quantity.toInt())
|
|
1859
|
+
}
|
|
1739
1860
|
}
|
|
1740
1861
|
|
|
1741
|
-
override fun checkoutSelectShippingOption(
|
|
1742
|
-
|
|
1862
|
+
override fun checkoutSelectShippingOption(
|
|
1863
|
+
sessionKey: String,
|
|
1864
|
+
id: String,
|
|
1865
|
+
promise: Promise,
|
|
1866
|
+
) {
|
|
1867
|
+
performCheckoutMutation(sessionKey, promise) { checkout ->
|
|
1868
|
+
checkout.selectShippingOption(id)
|
|
1869
|
+
}
|
|
1743
1870
|
}
|
|
1744
1871
|
|
|
1745
|
-
override fun checkoutUpdateTaxId(
|
|
1746
|
-
|
|
1872
|
+
override fun checkoutUpdateTaxId(
|
|
1873
|
+
sessionKey: String,
|
|
1874
|
+
type: String,
|
|
1875
|
+
value: String,
|
|
1876
|
+
promise: Promise,
|
|
1877
|
+
) {
|
|
1878
|
+
performCheckoutMutation(sessionKey, promise) { checkout ->
|
|
1879
|
+
checkout.updateTaxId(type = type, value = value)
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
override fun checkoutRunServerUpdateStart(
|
|
1884
|
+
sessionKey: String,
|
|
1885
|
+
promise: Promise,
|
|
1886
|
+
) {
|
|
1887
|
+
val checkout = checkoutInstances[sessionKey] ?: run {
|
|
1888
|
+
promise.reject(ErrorType.Failed.toString(), "Checkout session not found.")
|
|
1889
|
+
return
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
if (serverUpdateContinuations.containsKey(sessionKey)) {
|
|
1893
|
+
promise.reject(ErrorType.Failed.toString(), "A server update is already in progress for this session.")
|
|
1894
|
+
return
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
1898
|
+
checkout.runServerUpdate {
|
|
1899
|
+
suspendCancellableCoroutine { continuation ->
|
|
1900
|
+
serverUpdateContinuations[sessionKey] = continuation
|
|
1901
|
+
}
|
|
1902
|
+
}.fold(
|
|
1903
|
+
onSuccess = { promise.resolve(mapFromCheckoutState(checkout)) },
|
|
1904
|
+
onFailure = { promise.reject(ErrorType.Failed.toString(), it.message, it) },
|
|
1905
|
+
)
|
|
1906
|
+
}
|
|
1747
1907
|
}
|
|
1748
1908
|
|
|
1749
|
-
override fun
|
|
1750
|
-
|
|
1909
|
+
override fun checkoutRunServerUpdateComplete(
|
|
1910
|
+
sessionKey: String,
|
|
1911
|
+
error: String?,
|
|
1912
|
+
promise: Promise,
|
|
1913
|
+
) {
|
|
1914
|
+
val continuation = serverUpdateContinuations.remove(sessionKey) ?: run {
|
|
1915
|
+
promise.reject(ErrorType.Failed.toString(), "No pending server update for this session.")
|
|
1916
|
+
return
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
if (error != null) {
|
|
1920
|
+
continuation.resume(Result.failure(Exception(error))) {}
|
|
1921
|
+
} else {
|
|
1922
|
+
continuation.resume(Result.success(Unit)) {}
|
|
1923
|
+
}
|
|
1924
|
+
promise.resolve(null)
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
private fun buildCheckoutConfiguration(configuration: ReadableMap): Checkout.Configuration {
|
|
1928
|
+
val checkoutConfiguration = Checkout.Configuration()
|
|
1929
|
+
val adaptivePricing = configuration.getMap("adaptivePricing")
|
|
1930
|
+
if (adaptivePricing?.hasKey("allowed") == true) {
|
|
1931
|
+
checkoutConfiguration.adaptivePricingAllowed(adaptivePricing.getBooleanOr("allowed", false))
|
|
1932
|
+
}
|
|
1933
|
+
return checkoutConfiguration
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
/**
|
|
1937
|
+
* Forwards the checkout's `(checkoutSession, isLoading)` flow to JS as
|
|
1938
|
+
* `checkoutSessionDidChangeState` events. Equivalent to the iOS
|
|
1939
|
+
* `CheckoutDelegate` bridge — every native-side mutation (currency selection,
|
|
1940
|
+
* promo code, refresh, etc.) goes through one canonical channel that
|
|
1941
|
+
* `useCheckout` listens to.
|
|
1942
|
+
*/
|
|
1943
|
+
private fun observeCheckoutState(
|
|
1944
|
+
sessionKey: String,
|
|
1945
|
+
checkout: Checkout,
|
|
1946
|
+
) {
|
|
1947
|
+
checkoutStateObservers[sessionKey]?.cancel()
|
|
1948
|
+
|
|
1949
|
+
val job = CoroutineScope(Dispatchers.Main).launch {
|
|
1950
|
+
// `combine` re-emits on every upstream tick. `distinctUntilChanged`
|
|
1951
|
+
// collapses runs where neither field actually moved — both flows are
|
|
1952
|
+
// StateFlows so we'd otherwise see a redundant initial replay when
|
|
1953
|
+
// wiring up.
|
|
1954
|
+
combine(
|
|
1955
|
+
checkout.checkoutSession,
|
|
1956
|
+
checkout.isLoading,
|
|
1957
|
+
) { session, isLoading -> session to isLoading }
|
|
1958
|
+
.distinctUntilChanged()
|
|
1959
|
+
.collect {
|
|
1960
|
+
eventEmitter.emitCheckoutSessionDidChangeState(
|
|
1961
|
+
Arguments.createMap().apply {
|
|
1962
|
+
putString("sessionKey", sessionKey)
|
|
1963
|
+
putMap("state", mapFromCheckoutState(checkout))
|
|
1964
|
+
},
|
|
1965
|
+
)
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
checkoutStateObservers[sessionKey] = job
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
private fun performCheckoutMutation(
|
|
1972
|
+
sessionKey: String,
|
|
1973
|
+
promise: Promise,
|
|
1974
|
+
operation: suspend (Checkout) -> Result<Unit>,
|
|
1975
|
+
) {
|
|
1976
|
+
val checkout = checkoutInstances[sessionKey] ?: run {
|
|
1977
|
+
promise.reject(ErrorType.Failed.toString(), "Checkout session not found.")
|
|
1978
|
+
return
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
CoroutineScope(Dispatchers.Main).launch {
|
|
1982
|
+
operation(checkout).fold(
|
|
1983
|
+
onSuccess = {
|
|
1984
|
+
promise.resolve(mapFromCheckoutState(checkout))
|
|
1985
|
+
},
|
|
1986
|
+
onFailure = { error ->
|
|
1987
|
+
promise.reject(
|
|
1988
|
+
ErrorType.Failed.toString(),
|
|
1989
|
+
error.message ?: "Checkout operation failed.",
|
|
1990
|
+
error,
|
|
1991
|
+
)
|
|
1992
|
+
},
|
|
1993
|
+
)
|
|
1994
|
+
}
|
|
1751
1995
|
}
|
|
1752
1996
|
|
|
1753
1997
|
/**
|
|
@@ -1765,14 +2009,14 @@ class StripeSdkModule(
|
|
|
1765
2009
|
private var isRecreatingReactActivity = false
|
|
1766
2010
|
private var isAuthWebViewActive = false
|
|
1767
2011
|
private val activityLifecycleCallbacks =
|
|
1768
|
-
object :
|
|
2012
|
+
object : DefaultActivityLifecycleCallbacks() {
|
|
1769
2013
|
override fun onActivityCreated(
|
|
1770
2014
|
activity: Activity,
|
|
1771
|
-
|
|
2015
|
+
savedInstanceState: Bundle?,
|
|
1772
2016
|
) {
|
|
1773
|
-
// Only set flag when ReactActivity is actually being recreated (
|
|
1774
|
-
//
|
|
1775
|
-
if (activity is ReactActivity &&
|
|
2017
|
+
// Only set flag when ReactActivity is actually being recreated (savedInstanceState != null)
|
|
2018
|
+
// savedInstanceState != null means this is a recreation, not first creation
|
|
2019
|
+
if (activity is ReactActivity && savedInstanceState != null) {
|
|
1776
2020
|
isRecreatingReactActivity = true
|
|
1777
2021
|
}
|
|
1778
2022
|
|
|
@@ -1791,21 +2035,6 @@ class StripeSdkModule(
|
|
|
1791
2035
|
}
|
|
1792
2036
|
}
|
|
1793
2037
|
}
|
|
1794
|
-
|
|
1795
|
-
override fun onActivityStarted(activity: Activity) {}
|
|
1796
|
-
|
|
1797
|
-
override fun onActivityResumed(activity: Activity) {}
|
|
1798
|
-
|
|
1799
|
-
override fun onActivityPaused(activity: Activity) {}
|
|
1800
|
-
|
|
1801
|
-
override fun onActivityStopped(activity: Activity) {}
|
|
1802
|
-
|
|
1803
|
-
override fun onActivitySaveInstanceState(
|
|
1804
|
-
activity: Activity,
|
|
1805
|
-
bundle: Bundle,
|
|
1806
|
-
) {}
|
|
1807
|
-
|
|
1808
|
-
override fun onActivityDestroyed(activity: Activity) {}
|
|
1809
2038
|
}
|
|
1810
2039
|
|
|
1811
2040
|
/**
|
|
@@ -1818,13 +2047,17 @@ class StripeSdkModule(
|
|
|
1818
2047
|
*/
|
|
1819
2048
|
private fun preventActivityRecreation() {
|
|
1820
2049
|
isRecreatingReactActivity = false
|
|
1821
|
-
reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(
|
|
2050
|
+
reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(
|
|
2051
|
+
activityLifecycleCallbacks
|
|
2052
|
+
)
|
|
1822
2053
|
reactApplicationContext.currentActivity?.application?.registerActivityLifecycleCallbacks(activityLifecycleCallbacks)
|
|
1823
2054
|
}
|
|
1824
2055
|
|
|
1825
2056
|
private fun setupComposeCompatView() {
|
|
1826
2057
|
UiThreadUtil.runOnUiThread {
|
|
1827
|
-
composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(
|
|
2058
|
+
composeCompatView = composeCompatView ?: StripeAbstractComposeView.CompatView(
|
|
2059
|
+
context = reactApplicationContext
|
|
2060
|
+
).also {
|
|
1828
2061
|
reactApplicationContext.currentActivity?.findViewById<ViewGroup>(android.R.id.content)?.addView(
|
|
1829
2062
|
it,
|
|
1830
2063
|
)
|
|
@@ -1842,6 +2075,8 @@ class StripeSdkModule(
|
|
|
1842
2075
|
// Timeout for auth webview fallback (if JavaScript doesn't call authWebViewDeepLinkHandled)
|
|
1843
2076
|
private const val AUTH_WEBVIEW_FALLBACK_TIMEOUT_MS = 60_000L
|
|
1844
2077
|
|
|
2078
|
+
private const val FILE_CLEANUP_DELAY_MS = 3_000L
|
|
2079
|
+
|
|
1845
2080
|
// SDK-managed storage for pending stripe-connect:// URLs
|
|
1846
2081
|
// This is static because deep links can arrive before ReactContext is available
|
|
1847
2082
|
private val pendingConnectUrls = mutableListOf<String>()
|
|
@@ -54,6 +54,7 @@ class StripeSdkPackage : BaseReactPackage() {
|
|
|
54
54
|
CardFieldViewManager(),
|
|
55
55
|
AuBECSDebitFormViewManager(),
|
|
56
56
|
StripeContainerManager(),
|
|
57
|
+
CurrencySelectorElementViewManager(),
|
|
57
58
|
CardFormViewManager(),
|
|
58
59
|
GooglePayButtonManager(),
|
|
59
60
|
AddToWalletButtonManager(),
|
|
@@ -61,6 +62,7 @@ class StripeSdkPackage : BaseReactPackage() {
|
|
|
61
62
|
EmbeddedPaymentElementViewManager(),
|
|
62
63
|
NavigationBarManager(),
|
|
63
64
|
PaymentMethodMessagingElementViewManager(),
|
|
65
|
+
CurrencySelectorElementViewManager(),
|
|
64
66
|
)
|
|
65
67
|
|
|
66
68
|
private fun getOnrampModuleClass(): Class<out NativeModule?>? {
|
package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt
CHANGED
|
@@ -55,7 +55,8 @@ class AddressLauncherManager(
|
|
|
55
55
|
callback.invoke(
|
|
56
56
|
createError(
|
|
57
57
|
ErrorType.Failed.toString(),
|
|
58
|
-
"No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the
|
|
58
|
+
"No publishable key set. Stripe has not been initialized. Initialize Stripe in your app with the " +
|
|
59
|
+
"StripeProvider component or the initStripe method.",
|
|
59
60
|
),
|
|
60
61
|
null,
|
|
61
62
|
)
|
|
@@ -162,7 +162,9 @@ class AddressSheetView(
|
|
|
162
162
|
else -> AddressLauncher.AdditionalFieldsConfiguration.FieldConfiguration.HIDDEN
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
internal fun buildAdditionalFieldsConfiguration(
|
|
165
|
+
internal fun buildAdditionalFieldsConfiguration(
|
|
166
|
+
params: ReadableMap
|
|
167
|
+
): AddressLauncher.AdditionalFieldsConfiguration {
|
|
166
168
|
val phoneConfiguration = getFieldConfiguration(params.getString("phoneNumber"))
|
|
167
169
|
|
|
168
170
|
return AddressLauncher.AdditionalFieldsConfiguration(
|
package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.reactnativestripesdk.customersheet
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
|
-
import android.app.Application
|
|
5
4
|
import android.graphics.drawable.Drawable
|
|
6
5
|
import android.os.Bundle
|
|
7
6
|
import android.os.Handler
|
|
@@ -20,6 +19,7 @@ import com.reactnativestripesdk.buildPaymentSheetAppearance
|
|
|
20
19
|
import com.reactnativestripesdk.convertDrawableToBase64
|
|
21
20
|
import com.reactnativestripesdk.mapToCardBrandAcceptance
|
|
22
21
|
import com.reactnativestripesdk.utils.CreateTokenErrorType
|
|
22
|
+
import com.reactnativestripesdk.utils.DefaultActivityLifecycleCallbacks
|
|
23
23
|
import com.reactnativestripesdk.utils.ErrorType
|
|
24
24
|
import com.reactnativestripesdk.utils.KeepJsAwakeTask
|
|
25
25
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
@@ -224,7 +224,7 @@ class CustomerSheetManager(
|
|
|
224
224
|
private fun presentWithTimeout(timeout: Long) {
|
|
225
225
|
var activities: MutableList<Activity> = mutableListOf()
|
|
226
226
|
val activityLifecycleCallbacks =
|
|
227
|
-
object :
|
|
227
|
+
object : DefaultActivityLifecycleCallbacks() {
|
|
228
228
|
override fun onActivityCreated(
|
|
229
229
|
activity: Activity,
|
|
230
230
|
savedInstanceState: Bundle?,
|
|
@@ -232,20 +232,6 @@ class CustomerSheetManager(
|
|
|
232
232
|
activities.add(activity)
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
override fun onActivityStarted(activity: Activity) {}
|
|
236
|
-
|
|
237
|
-
override fun onActivityResumed(activity: Activity) {}
|
|
238
|
-
|
|
239
|
-
override fun onActivityPaused(activity: Activity) {}
|
|
240
|
-
|
|
241
|
-
override fun onActivityStopped(activity: Activity) {}
|
|
242
|
-
|
|
243
|
-
override fun onActivitySaveInstanceState(
|
|
244
|
-
activity: Activity,
|
|
245
|
-
outState: Bundle,
|
|
246
|
-
) {
|
|
247
|
-
}
|
|
248
|
-
|
|
249
235
|
override fun onActivityDestroyed(activity: Activity) {
|
|
250
236
|
activities = mutableListOf()
|
|
251
237
|
context.currentActivity?.application?.unregisterActivityLifecycleCallbacks(this)
|
|
@@ -326,7 +312,9 @@ class CustomerSheetManager(
|
|
|
326
312
|
internal fun createDefaultBillingDetails(map: ReadableMap): PaymentSheet.BillingDetails =
|
|
327
313
|
buildBillingDetails(map) ?: PaymentSheet.BillingDetails()
|
|
328
314
|
|
|
329
|
-
internal fun createBillingDetailsCollectionConfiguration(
|
|
315
|
+
internal fun createBillingDetailsCollectionConfiguration(
|
|
316
|
+
map: ReadableMap
|
|
317
|
+
): PaymentSheet.BillingDetailsCollectionConfiguration =
|
|
330
318
|
buildBillingDetailsCollectionConfiguration(map)
|
|
331
319
|
|
|
332
320
|
internal fun createCustomerAdapter(
|
|
@@ -405,7 +393,9 @@ class CustomerSheetManager(
|
|
|
405
393
|
return paymentOptionResult
|
|
406
394
|
}
|
|
407
395
|
|
|
408
|
-
internal fun createIntentConfiguration(
|
|
396
|
+
internal fun createIntentConfiguration(
|
|
397
|
+
intentConfigurationBundle: ReadableMap?
|
|
398
|
+
): CustomerSheet.IntentConfiguration? =
|
|
409
399
|
intentConfigurationBundle?.let { bundle ->
|
|
410
400
|
val onBehalfOf = bundle.getString("onBehalfOf")
|
|
411
401
|
CustomerSheet.IntentConfiguration
|
package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt
CHANGED
|
@@ -67,7 +67,9 @@ class ReactNativeCustomerAdapter(
|
|
|
67
67
|
return adapter.detachPaymentMethod(paymentMethodId)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
override suspend fun setSelectedPaymentOption(
|
|
70
|
+
override suspend fun setSelectedPaymentOption(
|
|
71
|
+
paymentOption: CustomerAdapter.PaymentOption?
|
|
72
|
+
): CustomerAdapter.Result<Unit> {
|
|
71
73
|
if (overridesSetSelectedPaymentOption) {
|
|
72
74
|
CompletableDeferred<Unit>().also {
|
|
73
75
|
setSelectedPaymentOptionCallback = it
|
|
@@ -14,7 +14,8 @@ class ReactNativeCustomerSessionProvider(
|
|
|
14
14
|
internal var providesCustomerSessionClientSecretCallback:
|
|
15
15
|
CompletableDeferred<CustomerSheet.CustomerSessionClientSecret>? = null
|
|
16
16
|
|
|
17
|
-
override suspend fun intentConfiguration(): Result<CustomerSheet.IntentConfiguration> =
|
|
17
|
+
override suspend fun intentConfiguration(): Result<CustomerSheet.IntentConfiguration> =
|
|
18
|
+
Result.success(intentConfiguration)
|
|
18
19
|
|
|
19
20
|
override suspend fun provideSetupIntentClientSecret(customerId: String): Result<String> {
|
|
20
21
|
CompletableDeferred<String>().also {
|
package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt
CHANGED
|
@@ -30,7 +30,8 @@ class AddToWalletButtonManager :
|
|
|
30
30
|
view.onAfterUpdateTransaction()
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView =
|
|
33
|
+
override fun createViewInstance(reactContext: ThemedReactContext): AddToWalletButtonView =
|
|
34
|
+
AddToWalletButtonView(reactContext)
|
|
34
35
|
|
|
35
36
|
override fun getExportedCustomDirectEventTypeConstants() =
|
|
36
37
|
mutableMapOf(
|