diff --git a/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundActivity.kt b/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundActivity.kt index 3e0c29d58bc..b25a5201c11 100644 --- a/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundActivity.kt +++ b/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundActivity.kt @@ -174,6 +174,7 @@ class FinancialConnectionsPlaygroundActivity : AppCompatActivity() { clientSecret = paymentIntentSecret, configuration = CollectBankAccountConfiguration.InstantDebits( email = email, + intentContext = intentContext, ) ) } diff --git a/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundViewModel.kt b/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundViewModel.kt index 787b51eb4b9..ff13cc6c082 100644 --- a/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundViewModel.kt +++ b/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/FinancialConnectionsPlaygroundViewModel.kt @@ -11,6 +11,7 @@ import com.stripe.android.Stripe import com.stripe.android.confirmPaymentIntent import com.stripe.android.financialconnections.FinancialConnections import com.stripe.android.financialconnections.FinancialConnectionsSheet +import com.stripe.android.financialconnections.FinancialConnectionsSheet.IntentContext import com.stripe.android.financialconnections.FinancialConnectionsSheetForTokenResult import com.stripe.android.financialconnections.FinancialConnectionsSheetResult import com.stripe.android.financialconnections.analytics.FinancialConnectionsEvent @@ -123,6 +124,11 @@ internal class FinancialConnectionsPlaygroundViewModel( publishableKey = it.publishableKey, ephemeralKey = it.ephemeralKey, customerId = it.customerId, + intentContext = IntentContext( + id = it.id, + amount = it.amount, + currency = it.currency, + ), experience = settings.get().selectedOption, integrationType = settings.get().selectedOption, ) @@ -480,6 +486,7 @@ sealed class FinancialConnectionsPlaygroundViewEffect { val publishableKey: String, val experience: Experience, val integrationType: IntegrationType, + val intentContext: IntentContext, ) : FinancialConnectionsPlaygroundViewEffect() } diff --git a/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/data/model/CreateIntentResponse.kt b/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/data/model/CreateIntentResponse.kt index fae690d7472..1e00d3f4d91 100644 --- a/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/data/model/CreateIntentResponse.kt +++ b/financial-connections-example/src/main/java/com/stripe/android/financialconnections/example/data/model/CreateIntentResponse.kt @@ -7,8 +7,11 @@ import kotlinx.serialization.Serializable @Keep @Serializable data class CreateIntentResponse( + @SerialName("id") val id: String, @SerialName("secret") val intentSecret: String, @SerialName("publishable_key") val publishableKey: String, @SerialName("ephemeral_key") val ephemeralKey: String? = null, - @SerialName("customer_id") val customerId: String? = null + @SerialName("customer_id") val customerId: String? = null, + @SerialName("amount") val amount: Long?, + @SerialName("currency") val currency: String?, ) diff --git a/financial-connections/api/financial-connections.api b/financial-connections/api/financial-connections.api index 29e9918cc67..4f537f20105 100644 --- a/financial-connections/api/financial-connections.api +++ b/financial-connections/api/financial-connections.api @@ -145,6 +145,14 @@ public final class com/stripe/android/financialconnections/FinancialConnectionsS public synthetic fun newArray (I)[Ljava/lang/Object; } +public final class com/stripe/android/financialconnections/FinancialConnectionsSheet$IntentContext$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/financialconnections/FinancialConnectionsSheet$IntentContext; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/stripe/android/financialconnections/FinancialConnectionsSheet$IntentContext; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + public final class com/stripe/android/financialconnections/FinancialConnectionsSheetComposeKt { public static final fun rememberFinancialConnectionsSheet (Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/financialconnections/FinancialConnectionsSheet; public static final fun rememberFinancialConnectionsSheetForToken (Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)Lcom/stripe/android/financialconnections/FinancialConnectionsSheet; diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheet.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheet.kt index 5cb7871f2dc..ff7b0bfdb37 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheet.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheet.kt @@ -2,6 +2,7 @@ package com.stripe.android.financialconnections import android.os.Parcelable import androidx.activity.ComponentActivity +import androidx.annotation.RestrictTo import androidx.fragment.app.Fragment import com.stripe.android.financialconnections.launcher.FinancialConnectionsSheetForDataLauncher import com.stripe.android.financialconnections.launcher.FinancialConnectionsSheetForTokenLauncher @@ -32,6 +33,14 @@ class FinancialConnectionsSheet internal constructor( val stripeAccountId: String? = null ) : Parcelable + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) + @Parcelize + data class IntentContext( + val id: String?, + val amount: Long?, + val currency: String?, + ) : Parcelable + /** * Present the [FinancialConnectionsSheet]. * @@ -40,7 +49,21 @@ class FinancialConnectionsSheet internal constructor( fun present( configuration: Configuration ) { - financialConnectionsSheetLauncher.present(configuration) + financialConnectionsSheetLauncher.present( + configuration = configuration, + intentContext = null, + ) + } + + @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) + fun presentInternal( + configuration: Configuration, + intentContext: IntentContext?, + ) { + financialConnectionsSheetLauncher.present( + configuration = configuration, + intentContext = intentContext, + ) } companion object { diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetActivity.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetActivity.kt index bf88fc37413..037d63a3d7c 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetActivity.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetActivity.kt @@ -151,7 +151,8 @@ internal class FinancialConnectionsSheetActivity : AppCompatActivity() { context = this, args = FinancialConnectionsSheetNativeActivityArgs( initialSyncResponse = viewEffect.initialSyncResponse, - configuration = viewEffect.configuration + configuration = viewEffect.configuration, + intentContext = viewEffect.intentContext, ) ) ) diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetState.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetState.kt index f656fca1c68..98880f5485c 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetState.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetState.kt @@ -87,7 +87,8 @@ internal sealed class FinancialConnectionsSheetViewEffect { */ data class OpenNativeAuthFlow( val configuration: FinancialConnectionsSheet.Configuration, - val initialSyncResponse: SynchronizeSessionResponse + val initialSyncResponse: SynchronizeSessionResponse, + val intentContext: FinancialConnectionsSheet.IntentContext?, ) : FinancialConnectionsSheetViewEffect() /** diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetViewModel.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetViewModel.kt index 8ff7f45c209..104854f3aa1 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetViewModel.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/FinancialConnectionsSheetViewModel.kt @@ -14,6 +14,7 @@ import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewmodel.initializer import androidx.lifecycle.viewmodel.viewModelFactory import com.stripe.android.core.Logger +import com.stripe.android.financialconnections.FinancialConnectionsSheet.IntentContext import com.stripe.android.financialconnections.FinancialConnectionsSheetActivity.Companion.getArgs import com.stripe.android.financialconnections.FinancialConnectionsSheetState.AuthFlowStatus import com.stripe.android.financialconnections.FinancialConnectionsSheetViewEffect.FinishWithResult @@ -144,7 +145,11 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor( copy( manifest = manifest, webAuthFlowStatus = AuthFlowStatus.NONE, - viewEffect = OpenNativeAuthFlow(initialArgs.configuration, sync) + viewEffect = OpenNativeAuthFlow( + configuration = initialArgs.configuration, + initialSyncResponse = sync, + intentContext = initialArgs.retrieveIntentContext(), + ) ) } } else { @@ -540,3 +545,7 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor( return null } } + +private fun FinancialConnectionsSheetActivityArgs.retrieveIntentContext(): IntentContext? { + return (this as? ForInstantDebits)?.intentContext +} diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/di/FinancialConnectionsSheetNativeModule.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/di/FinancialConnectionsSheetNativeModule.kt index cfd5ad6a6ef..05cb43e2c95 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/di/FinancialConnectionsSheetNativeModule.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/di/FinancialConnectionsSheetNativeModule.kt @@ -7,6 +7,7 @@ import com.stripe.android.core.Logger import com.stripe.android.core.networking.ApiRequest import com.stripe.android.core.networking.StripeNetworkClient import com.stripe.android.core.version.StripeSdkVersion +import com.stripe.android.financialconnections.FinancialConnectionsSheet import com.stripe.android.financialconnections.domain.AttachConsumerToLinkAccountSession import com.stripe.android.financialconnections.domain.CreateInstantDebitsResult import com.stripe.android.financialconnections.domain.HandleError @@ -23,6 +24,7 @@ import com.stripe.android.financialconnections.model.SynchronizeSessionResponse import com.stripe.android.financialconnections.navigation.NavigationManager import com.stripe.android.financialconnections.navigation.NavigationManagerImpl import com.stripe.android.financialconnections.network.FinancialConnectionsRequestExecutor +import com.stripe.android.financialconnections.presentation.FinancialConnectionsSheetNativeState import com.stripe.android.financialconnections.repository.ConsumerSessionRepository import com.stripe.android.financialconnections.repository.FinancialConnectionsAccountsRepository import com.stripe.android.financialconnections.repository.FinancialConnectionsConsumerSessionRepository @@ -123,6 +125,7 @@ internal interface FinancialConnectionsSheetNativeModule { locale: Locale?, logger: Logger, isLinkWithStripe: IsLinkWithStripe, + intentContext: FinancialConnectionsSheet.IntentContext?, ) = FinancialConnectionsConsumerSessionRepository( financialConnectionsConsumersApiService = financialConnectionsConsumersApiService, provideApiRequestOptions = provideApiRequestOptions, @@ -131,6 +134,7 @@ internal interface FinancialConnectionsSheetNativeModule { locale = locale ?: Locale.getDefault(), logger = logger, isLinkWithStripe = isLinkWithStripe, + intentContext = intentContext, ) @Singleton @@ -184,5 +188,12 @@ internal interface FinancialConnectionsSheetNativeModule { linkSignupHandlerForNetworking.get() } } + + @Provides + internal fun provideIntentContext( + initialState: FinancialConnectionsSheetNativeState, + ): FinancialConnectionsSheet.IntentContext? { + return initialState.intentContext + } } } diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetActivityArgs.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetActivityArgs.kt index c92cae46019..583deff65d4 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetActivityArgs.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetActivityArgs.kt @@ -32,7 +32,8 @@ sealed class FinancialConnectionsSheetActivityArgs( @Parcelize @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class ForInstantDebits( - override val configuration: FinancialConnectionsSheet.Configuration + override val configuration: FinancialConnectionsSheet.Configuration, + val intentContext: FinancialConnectionsSheet.IntentContext?, ) : FinancialConnectionsSheetActivityArgs(configuration) internal fun validate() { diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForDataLauncher.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForDataLauncher.kt index 5ac7f04f9e5..88fdec0c50c 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForDataLauncher.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForDataLauncher.kt @@ -50,7 +50,10 @@ class FinancialConnectionsSheetForDataLauncher( } ) - override fun present(configuration: FinancialConnectionsSheet.Configuration) { + override fun present( + configuration: FinancialConnectionsSheet.Configuration, + intentContext: FinancialConnectionsSheet.IntentContext? + ) { activityResultLauncher.launch( FinancialConnectionsSheetActivityArgs.ForData( configuration diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForInstantDebitsLauncher.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForInstantDebitsLauncher.kt index 8f04b3ea1ca..cf41360ee26 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForInstantDebitsLauncher.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForInstantDebitsLauncher.kt @@ -37,11 +37,12 @@ class FinancialConnectionsSheetForInstantDebitsLauncher( ) ) - override fun present(configuration: FinancialConnectionsSheet.Configuration) { + override fun present( + configuration: FinancialConnectionsSheet.Configuration, + intentContext: FinancialConnectionsSheet.IntentContext? + ) { activityResultLauncher.launch( - FinancialConnectionsSheetActivityArgs.ForInstantDebits( - configuration - ) + FinancialConnectionsSheetActivityArgs.ForInstantDebits(configuration, intentContext) ) } } diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForTokenLauncher.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForTokenLauncher.kt index ea612318b54..daed4626593 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForTokenLauncher.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetForTokenLauncher.kt @@ -48,7 +48,10 @@ internal class FinancialConnectionsSheetForTokenLauncher( } ) - override fun present(configuration: FinancialConnectionsSheet.Configuration) { + override fun present( + configuration: FinancialConnectionsSheet.Configuration, + intentContext: FinancialConnectionsSheet.IntentContext? + ) { activityResultLauncher.launch( FinancialConnectionsSheetActivityArgs.ForToken( configuration diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetLauncher.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetLauncher.kt index f47e38aefca..c54c6f18f94 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetLauncher.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetLauncher.kt @@ -5,5 +5,8 @@ import com.stripe.android.financialconnections.FinancialConnectionsSheet @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) interface FinancialConnectionsSheetLauncher { - fun present(configuration: FinancialConnectionsSheet.Configuration) + fun present( + configuration: FinancialConnectionsSheet.Configuration, + intentContext: FinancialConnectionsSheet.IntentContext?, + ) } diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetNativeActivityArgs.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetNativeActivityArgs.kt index 841313ffe18..b599a73e10e 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetNativeActivityArgs.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/launcher/FinancialConnectionsSheetNativeActivityArgs.kt @@ -8,5 +8,6 @@ import kotlinx.parcelize.Parcelize @Parcelize internal data class FinancialConnectionsSheetNativeActivityArgs constructor( val configuration: FinancialConnectionsSheet.Configuration, - val initialSyncResponse: SynchronizeSessionResponse + val initialSyncResponse: SynchronizeSessionResponse, + val intentContext: FinancialConnectionsSheet.IntentContext?, ) : Parcelable diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/presentation/FinancialConnectionsSheetNativeViewModel.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/presentation/FinancialConnectionsSheetNativeViewModel.kt index 4a3eb18658e..401fbccfed3 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/presentation/FinancialConnectionsSheetNativeViewModel.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/presentation/FinancialConnectionsSheetNativeViewModel.kt @@ -16,6 +16,7 @@ import androidx.navigation.compose.NavHost import com.stripe.android.core.Logger import com.stripe.android.financialconnections.FinancialConnections import com.stripe.android.financialconnections.FinancialConnectionsSheet +import com.stripe.android.financialconnections.FinancialConnectionsSheet.IntentContext import com.stripe.android.financialconnections.analytics.FinancialConnectionsAnalyticsEvent.AppBackgrounded import com.stripe.android.financialconnections.analytics.FinancialConnectionsAnalyticsEvent.ClickNavBarBack import com.stripe.android.financialconnections.analytics.FinancialConnectionsAnalyticsEvent.ClickNavBarClose @@ -513,6 +514,7 @@ internal data class FinancialConnectionsSheetNativeState( val initialPane: Pane, val theme: Theme, val isLinkWithStripe: Boolean, + val intentContext: IntentContext?, ) { /** @@ -533,6 +535,7 @@ internal data class FinancialConnectionsSheetNativeState( theme = args.initialSyncResponse.manifest.theme?.toLocalTheme() ?: Theme.default, viewEffect = null, isLinkWithStripe = args.initialSyncResponse.manifest.isLinkWithStripe ?: false, + intentContext = args.intentContext, ) companion object { diff --git a/financial-connections/src/main/java/com/stripe/android/financialconnections/repository/FinancialConnectionsConsumerSessionRepository.kt b/financial-connections/src/main/java/com/stripe/android/financialconnections/repository/FinancialConnectionsConsumerSessionRepository.kt index d3ed269dbde..2e319582af8 100644 --- a/financial-connections/src/main/java/com/stripe/android/financialconnections/repository/FinancialConnectionsConsumerSessionRepository.kt +++ b/financial-connections/src/main/java/com/stripe/android/financialconnections/repository/FinancialConnectionsConsumerSessionRepository.kt @@ -2,6 +2,7 @@ package com.stripe.android.financialconnections.repository import com.stripe.android.core.Logger import com.stripe.android.financialconnections.domain.IsLinkWithStripe +import com.stripe.android.financialconnections.FinancialConnectionsSheet.IntentContext import com.stripe.android.financialconnections.repository.api.FinancialConnectionsConsumersApiService import com.stripe.android.financialconnections.repository.api.ProvideApiRequestOptions import com.stripe.android.model.AttachConsumerToLinkAccountSession @@ -65,6 +66,7 @@ internal interface FinancialConnectionsConsumerSessionRepository { locale: Locale?, logger: Logger, isLinkWithStripe: IsLinkWithStripe, + intentContext: IntentContext?, ): FinancialConnectionsConsumerSessionRepository = FinancialConnectionsConsumerSessionRepositoryImpl( consumersApiService = consumersApiService, @@ -74,6 +76,7 @@ internal interface FinancialConnectionsConsumerSessionRepository { locale = locale, logger = logger, isLinkWithStripe = isLinkWithStripe, + intentContext = intentContext, ) } } @@ -85,6 +88,7 @@ private class FinancialConnectionsConsumerSessionRepositoryImpl( private val provideApiRequestOptions: ProvideApiRequestOptions, private val locale: Locale?, private val logger: Logger, + private val intentContext: IntentContext?, isLinkWithStripe: IsLinkWithStripe, ) : FinancialConnectionsConsumerSessionRepository { @@ -120,6 +124,16 @@ private class FinancialConnectionsConsumerSessionRepositoryImpl( country = country, name = null, locale = locale, + amount = intentContext?.amount, + currency = intentContext?.currency, + financialIncentive = intentContext?.id?.let { + mapOf( + "financial_incentive" to mapOf( + // This only supports payment intents for now + "payment_intent" to it, + ) + ) + }, requestOptions = provideApiRequestOptions(useConsumerPublishableKey = false), requestSurface = requestSurface, consentAction = EnteredPhoneNumberClickedSaveToLink, diff --git a/link/src/main/java/com/stripe/android/link/repositories/LinkApiRepository.kt b/link/src/main/java/com/stripe/android/link/repositories/LinkApiRepository.kt index f47cfc49b69..351a48fba6d 100644 --- a/link/src/main/java/com/stripe/android/link/repositories/LinkApiRepository.kt +++ b/link/src/main/java/com/stripe/android/link/repositories/LinkApiRepository.kt @@ -65,6 +65,9 @@ internal class LinkApiRepository @Inject constructor( phoneNumber = phone, country = country, name = name, + amount = null, + currency = null, + financialIncentive = null, locale = locale, consentAction = consentAction, requestOptions = buildRequestOptions(), diff --git a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/CollectBankAccountLauncher.kt b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/CollectBankAccountLauncher.kt index 633488d78ea..fd15f630705 100644 --- a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/CollectBankAccountLauncher.kt +++ b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/CollectBankAccountLauncher.kt @@ -6,6 +6,7 @@ import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultRegistryOwner import androidx.annotation.RestrictTo import androidx.fragment.app.Fragment +import com.stripe.android.financialconnections.FinancialConnectionsSheet.IntentContext import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountContract import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountResult import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountResultInternal @@ -137,6 +138,7 @@ sealed interface CollectBankAccountConfiguration : Parcelable { @Parcelize @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) data class InstantDebits( - val email: String? + val email: String?, + val intentContext: IntentContext?, ) : Parcelable, CollectBankAccountConfiguration } diff --git a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountActivity.kt b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountActivity.kt index bec072fb3ef..787d0e095a2 100644 --- a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountActivity.kt +++ b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountActivity.kt @@ -68,7 +68,8 @@ internal class CollectBankAccountActivity : AppCompatActivity() { financialConnectionsPaymentsProxy.present( financialConnectionsSessionClientSecret = financialConnectionsSessionSecret, publishableKey = publishableKey, - stripeAccountId = stripeAccountId + stripeAccountId = stripeAccountId, + intentContext = intentContext, ) } diff --git a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewEffect.kt b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewEffect.kt index 15f2ead757e..0d1c504452e 100644 --- a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewEffect.kt +++ b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewEffect.kt @@ -1,5 +1,6 @@ package com.stripe.android.payments.bankaccount.ui +import com.stripe.android.financialconnections.FinancialConnectionsSheet.IntentContext import com.stripe.android.payments.bankaccount.navigation.CollectBankAccountResultInternal /** @@ -16,7 +17,8 @@ internal sealed class CollectBankAccountViewEffect { data class OpenConnectionsFlow( val publishableKey: String, val financialConnectionsSessionSecret: String, - val stripeAccountId: String? + val stripeAccountId: String?, + val intentContext: IntentContext?, ) : CollectBankAccountViewEffect() /** diff --git a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewModel.kt b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewModel.kt index 91bec0c1b60..5e0ee14e064 100644 --- a/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewModel.kt +++ b/payments-core/src/main/java/com/stripe/android/payments/bankaccount/ui/CollectBankAccountViewModel.kt @@ -8,10 +8,13 @@ import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewmodel.CreationExtras import com.stripe.android.core.Logger import com.stripe.android.core.utils.requireApplication +import com.stripe.android.financialconnections.FinancialConnectionsSheet.IntentContext import com.stripe.android.financialconnections.FinancialConnectionsSheetResult import com.stripe.android.financialconnections.launcher.FinancialConnectionsSheetInstantDebitsResult import com.stripe.android.financialconnections.model.FinancialConnectionsSession import com.stripe.android.model.StripeIntent +import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration +import com.stripe.android.payments.bankaccount.CollectBankAccountConfiguration.InstantDebits import com.stripe.android.payments.bankaccount.di.DaggerCollectBankAccountComponent import com.stripe.android.payments.bankaccount.domain.AttachFinancialConnectionsSession import com.stripe.android.payments.bankaccount.domain.CreateFinancialConnectionsSession @@ -109,7 +112,8 @@ internal class CollectBankAccountViewModel @Inject constructor( OpenConnectionsFlow( financialConnectionsSessionSecret = financialConnectionsSessionSecret, publishableKey = args.publishableKey, - stripeAccountId = args.stripeAccountId + stripeAccountId = args.stripeAccountId, + intentContext = args.configuration.retrieveIntentContext(), ) ) } @@ -272,3 +276,7 @@ internal class CollectBankAccountViewModel @Inject constructor( private const val KEY_HAS_LAUNCHED = "key_has_launched" } } + +private fun CollectBankAccountConfiguration.retrieveIntentContext(): IntentContext? { + return (this as? InstantDebits)?.intentContext +} diff --git a/payments-core/src/main/java/com/stripe/android/payments/financialconnections/FinancialConnectionsPaymentsProxy.kt b/payments-core/src/main/java/com/stripe/android/payments/financialconnections/FinancialConnectionsPaymentsProxy.kt index 54c204bb56e..120bb06400e 100644 --- a/payments-core/src/main/java/com/stripe/android/payments/financialconnections/FinancialConnectionsPaymentsProxy.kt +++ b/payments-core/src/main/java/com/stripe/android/payments/financialconnections/FinancialConnectionsPaymentsProxy.kt @@ -17,7 +17,8 @@ internal interface FinancialConnectionsPaymentsProxy { fun present( financialConnectionsSessionClientSecret: String, publishableKey: String, - stripeAccountId: String? + stripeAccountId: String?, + intentContext: FinancialConnectionsSheet.IntentContext?, ) companion object { @@ -70,14 +71,16 @@ internal class FinancialConnectionsLauncherProxy?, requestSurface: String, consentAction: ConsumerSignUpConsentAction, requestOptions: ApiRequest.Options, @@ -99,9 +102,12 @@ class ConsumersApiServiceImpl( country: String, name: String?, locale: Locale?, + amount: Long?, + currency: String?, + financialIncentive: Map?, requestSurface: String, consentAction: ConsumerSignUpConsentAction, - requestOptions: ApiRequest.Options, + requestOptions: ApiRequest.Options ): Result { return executeRequestWithResultParser( stripeErrorJsonParser = stripeErrorJsonParser, @@ -113,6 +119,8 @@ class ConsumersApiServiceImpl( "email_address" to email.lowercase(), "phone_number" to phoneNumber, "country" to country, + "amount" to amount, + "currency" to currency, "country_inferring_method" to "PHONE_NUMBER", "consent_action" to consentAction.value, "request_surface" to requestSurface, @@ -124,6 +132,8 @@ class ConsumersApiServiceImpl( name?.let { mapOf("legal_name" to it) } ?: emptyMap() + ).plus( + financialIncentive.orEmpty() ), ), responseJsonParser = ConsumerSessionSignupJsonParser, diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt index 756aa1f53a2..e603ed310b1 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModel.kt @@ -462,6 +462,9 @@ internal class USBankAccountFormViewModel @Inject internal constructor( val configuration = if (args.instantDebits) { CollectBankAccountConfiguration.InstantDebits( email = email.value, + amount = args.formArgs.amount?.value, + currency = args.formArgs.amount?.currencyCode, + intentId = args.stripeIntentId, ) } else { CollectBankAccountConfiguration.USBankAccount(