Skip to content

Commit

Permalink
Renames LinkAccountSession to FinancialConnectionsSession. (#4910)
Browse files Browse the repository at this point in the history
* Renames LinkAccountSession to FinancialConnectionsSession.

* Renames endpoints (WIP)

* Style fixes.

* Revert endpoint changes.

* Updates missing session and account occurrences.

* Updates example.

* Updates example.

* Updates payments api.

* Updates changelog.

* Adds missing renames.

* Removes double financial occurrences.

* Api updates.
  • Loading branch information
carlosmuvi-stripe authored Apr 28, 2022
1 parent 8b93a5e commit a3a2796
Show file tree
Hide file tree
Showing 64 changed files with 941 additions and 944 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG
## x.x.x - xxxx-xx-xx

### Payments

* [CHANGED] [4910](https://github.com/stripe/stripe-android/pull/4910) Some changes affecting CollectBankAccountLauncher (ACH)
* `CollectBankAccountResponse#LinkAccountSession` to `FinancialConnectionsSession`
* `LinkedAccount` to `FinancialConnectionsAccount`.

### PaymentSheet
* [FIXED] [4909](https://github.com/stripe/stripe-android/pull/4909) In the multi-step flow when re-opening to a new card the form will pre-populate. Also the default billing address will pre-populate in the form.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FinancialConnectionsExampleActivity : AppCompatActivity() {
}

private fun ActivityFinancialconnectionsExampleBinding.observeViews() {
launchConnectionsSheet.setOnClickListener { viewModel.startLinkAccountSession() }
launchConnectionsSheet.setOnClickListener { viewModel.startFinancialConnectionsSession() }
}

private fun ActivityFinancialconnectionsExampleBinding.observeState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ class FinancialConnectionsExampleViewModel : ViewModel() {
private val _viewEffect = MutableSharedFlow<FinancialConnectionsExampleViewEffect>()
val viewEffect: SharedFlow<FinancialConnectionsExampleViewEffect> = _viewEffect

fun startLinkAccountSession() {
fun startFinancialConnectionsSession() {
viewModelScope.launch {
setState {
copy(
loading = true,
status = "Fetching link account session from example backend!"
status = "Fetching financial connections session from example backend!"
)
}
kotlin.runCatching { repository.createLinkAccountSession() }
// Success creating session: open ConnectionsSheet with received secret
// Success creating session: open FinancialConnectionsSheet with received secret
.onSuccess {
setState {
copy(
loading = false,
status = "Session created, opening ConnectionsSheet."
status = "Session created, opening FinancialConnectionsSheet."
)
}
_viewEffect.emit(
Expand All @@ -56,7 +56,7 @@ class FinancialConnectionsExampleViewModel : ViewModel() {
setState {
copy(
loading = false,
status = "Error starting linked account session: $it"
status = "Error retrieving financial connections session: $it"
)
}
}
Expand All @@ -66,8 +66,8 @@ class FinancialConnectionsExampleViewModel : ViewModel() {
fun onFinancialConnectionsSheetResult(result: FinancialConnectionsSheetResult) {
val statusText = when (result) {
is Completed -> {
val linkedAccountList = result.linkAccountSession.linkedAccounts
linkedAccountList.linkedAccounts.joinToString("\n") {
val accountList = result.financialConnectionsSession.accounts
accountList.financialConnectionsAccounts.joinToString("\n") {
"${it.institutionName} - ${it.displayName} - ${it.last4} - ${it.category}/${it.subcategory}"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<string name="app_name">Financial Connections Example</string>
<string name="launch_connections_sheet">Link Account</string>
<string name="launch_connections_sheet">Connect an Account</string>
</resources>
444 changes: 222 additions & 222 deletions financial-connections/api/financial-connections.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package com.stripe.android.financialconnections
import android.os.Parcelable
import androidx.activity.ComponentActivity
import androidx.fragment.app.Fragment
import com.stripe.android.connections.FinancialConnectionsSheetForTokenResult
import com.stripe.android.financialconnections.launcher.DefaultFinancialConnectionsSheetLauncher
import com.stripe.android.financialconnections.launcher.FinancialConnectionsSheetForTokenLauncher
import com.stripe.android.financialconnections.launcher.FinancialConnectionsSheetLauncher
import kotlinx.parcelize.Parcelize

/**
* A drop in class to present the Link Account Session Auth Flow.
* A drop in class to present the Financial Connections Auth Flow.
*
* This *must* be called unconditionally, as part of initialization path,
* typically as a field initializer of an Activity or Fragment.
Expand All @@ -21,12 +20,12 @@ class FinancialConnectionsSheet internal constructor(
/**
* Configuration for a [FinancialConnectionsSheet]
*
* @param linkAccountSessionClientSecret the client secret for the Link Account Session
* @param financialConnectionsSessionClientSecret the session client secret
* @param publishableKey the Stripe publishable key
*/
@Parcelize
data class Configuration(
val linkAccountSessionClientSecret: String,
val financialConnectionsSessionClientSecret: String,
val publishableKey: String,
) : Parcelable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ internal class FinancialConnectionsSheetActivity : AppCompatActivity() {
}

/**
* If the back button is pressed during the manifest fetch or link account session fetch
* If the back button is pressed during the manifest fetch or session fetch
* return canceled result
*/
override fun onBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.os.Bundle
import android.os.Parcelable
import androidx.activity.result.contract.ActivityResultContract
import androidx.core.os.bundleOf
import com.stripe.android.financialconnections.model.LinkAccountSession
import com.stripe.android.financialconnections.model.FinancialConnectionsSession
import com.stripe.android.model.Token
import kotlinx.parcelize.Parcelize
import java.security.InvalidParameterException
Expand Down Expand Up @@ -48,9 +48,9 @@ internal class FinancialConnectionsSheetContract :
) : Args(configuration)

fun validate() {
if (configuration.linkAccountSessionClientSecret.isBlank()) {
if (configuration.financialConnectionsSessionClientSecret.isBlank()) {
throw InvalidParameterException(
"The link account session client secret cannot be an empty string."
"The session client secret cannot be an empty string."
)
}
if (configuration.publishableKey.isBlank()) {
Expand All @@ -70,11 +70,11 @@ internal class FinancialConnectionsSheetContract :
internal sealed class Result : Parcelable {
/**
* The customer completed the connections session.
* @param linkAccountSession The link account session connected
* @param financialConnectionsSession The financial connections session connected
*/
@Parcelize
data class Completed(
val linkAccountSession: LinkAccountSession,
val financialConnectionsSession: FinancialConnectionsSession,
val token: Token? = null
) : Result()

Expand All @@ -100,8 +100,8 @@ internal class FinancialConnectionsSheetContract :

companion object {
const val EXTRA_ARGS =
"com.stripe.android.connections.ConnectionsSheetContract.extra_args"
"com.stripe.android.financialconnections.ConnectionsSheetContract.extra_args"
private const val EXTRA_RESULT =
"com.stripe.android.connections.ConnectionsSheetContract.extra_result"
"com.stripe.android.financialconnections.ConnectionsSheetContract.extra_result"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stripe.android.connections
package com.stripe.android.financialconnections

import android.os.Parcelable
import com.stripe.android.financialconnections.model.LinkAccountSession
import com.stripe.android.financialconnections.model.FinancialConnectionsSession
import com.stripe.android.model.Token
import kotlinx.parcelize.Parcelize

Expand All @@ -11,11 +11,11 @@ import kotlinx.parcelize.Parcelize
sealed class FinancialConnectionsSheetForTokenResult : Parcelable {
/**
* The customer completed the connections session.
* @param linkAccountSession The link account session connected
* @param financialConnectionsSession The financial connections session connected
*/
@Parcelize
data class Completed(
val linkAccountSession: LinkAccountSession,
val financialConnectionsSession: FinancialConnectionsSession,
val token: Token
) : FinancialConnectionsSheetForTokenResult()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stripe.android.financialconnections

import android.os.Parcelable
import com.stripe.android.financialconnections.model.LinkAccountSession
import com.stripe.android.financialconnections.model.FinancialConnectionsSession
import kotlinx.parcelize.Parcelize

/**
Expand All @@ -10,11 +10,11 @@ import kotlinx.parcelize.Parcelize
sealed class FinancialConnectionsSheetResult : Parcelable {
/**
* The customer completed the connections session.
* @param linkAccountSession The link account session connected
* @param financialConnectionsSession The financial connections session connected
*/
@Parcelize
data class Completed(
val linkAccountSession: LinkAccountSession
val financialConnectionsSession: FinancialConnectionsSession
) : FinancialConnectionsSheetResult()

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.stripe.android.financialconnections

import androidx.lifecycle.SavedStateHandle
import com.stripe.android.financialconnections.model.LinkAccountSessionManifest
import com.stripe.android.financialconnections.model.FinancialConnectionsSessionManifest

/**
* Class containing all of the data needed to represent the screen.
*/
internal data class FinancialConnectionsSheetState(
val activityRecreated: Boolean = false,
val manifest: LinkAccountSessionManifest? = null,
val manifest: FinancialConnectionsSessionManifest? = null,
val authFlowActive: Boolean = false
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.savedstate.SavedStateRegistryOwner
import com.stripe.android.connections.domain.FetchLinkAccountSessionForToken
import com.stripe.android.financialconnections.FinancialConnectionsSheetContract.Result.Canceled
import com.stripe.android.financialconnections.FinancialConnectionsSheetContract.Result.Completed
import com.stripe.android.financialconnections.FinancialConnectionsSheetContract.Result.Failed
Expand All @@ -17,10 +16,11 @@ import com.stripe.android.financialconnections.FinancialConnectionsSheetViewEffe
import com.stripe.android.financialconnections.analytics.FinancialConnectionsEventReporter
import com.stripe.android.financialconnections.di.APPLICATION_ID
import com.stripe.android.financialconnections.di.DaggerFinancialConnectionsSheetComponent
import com.stripe.android.financialconnections.domain.FetchLinkAccountSession
import com.stripe.android.financialconnections.domain.GenerateLinkAccountSessionManifest
import com.stripe.android.financialconnections.model.LinkAccountSession
import com.stripe.android.financialconnections.model.LinkAccountSessionManifest
import com.stripe.android.financialconnections.domain.FetchFinancialConnectionsSession
import com.stripe.android.financialconnections.domain.FetchFinancialConnectionsSessionForToken
import com.stripe.android.financialconnections.domain.GenerateFinancialConnectionsSessionManifest
import com.stripe.android.financialconnections.model.FinancialConnectionsSession
import com.stripe.android.financialconnections.model.FinancialConnectionsSessionManifest
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
Expand All @@ -34,9 +34,9 @@ import javax.inject.Named
internal class FinancialConnectionsSheetViewModel @Inject constructor(
@Named(APPLICATION_ID) private val applicationId: String,
private val starterArgs: FinancialConnectionsSheetContract.Args,
private val generateLinkAccountSessionManifest: GenerateLinkAccountSessionManifest,
private val fetchLinkAccountSession: FetchLinkAccountSession,
private val fetchLinkAccountSessionForToken: FetchLinkAccountSessionForToken,
private val generateFinancialConnectionsSessionManifest: GenerateFinancialConnectionsSessionManifest,
private val fetchFinancialConnectionsSession: FetchFinancialConnectionsSession,
private val fetchFinancialConnectionsSessionForToken: FetchFinancialConnectionsSessionForToken,
private val savedStateHandle: SavedStateHandle,
private val eventReporter: FinancialConnectionsEventReporter
) : ViewModel() {
Expand All @@ -57,14 +57,14 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor(
}

/**
* Fetches the [LinkAccountSessionManifest] from the Stripe API to get the hosted auth flow URL
* Fetches the [FinancialConnectionsSessionManifest] from the Stripe API to get the hosted auth flow URL
* as well as the success and cancel callback URLs to verify.
*/
private fun fetchManifest() {
viewModelScope.launch {
kotlin.runCatching {
generateLinkAccountSessionManifest(
clientSecret = starterArgs.configuration.linkAccountSessionClientSecret,
generateFinancialConnectionsSessionManifest(
clientSecret = starterArgs.configuration.financialConnectionsSessionClientSecret,
applicationId = applicationId
)
}.onFailure {
Expand All @@ -81,7 +81,7 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor(
* @param manifest the manifest containing the hosted auth flow URL to launch
*
*/
private suspend fun openAuthFlow(manifest: LinkAccountSessionManifest) {
private suspend fun openAuthFlow(manifest: FinancialConnectionsSessionManifest) {
// stores manifest in state for future references.
_state.updateAndPersist {
it.copy(
Expand Down Expand Up @@ -139,16 +139,16 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor(
}

/**
* For regular connections flows requesting a link account session:
* For regular connections flows requesting a session:
*
* On successfully completing the hosted auth flow and receiving the success callback intent,
* fetch the updated [LinkAccountSession] model from the API
* fetch the updated [FinancialConnectionsSession] model from the API
* and return it back as a [Completed] result.
*/
private fun fetchLinkAccountSession() {
private fun fetchFinancialConnectionsSession() {
viewModelScope.launch {
kotlin.runCatching {
fetchLinkAccountSession(starterArgs.configuration.linkAccountSessionClientSecret)
fetchFinancialConnectionsSession(starterArgs.configuration.financialConnectionsSessionClientSecret)
}.onSuccess {
val result = Completed(it)
eventReporter.onResult(starterArgs.configuration, result)
Expand All @@ -163,13 +163,15 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor(
* For connections flows requesting an account [com.stripe.android.model.Token]:
*
* On successfully completing the hosted auth flow and receiving the success callback intent,
* fetch the updated [LinkAccountSession] and the generated [com.stripe.android.model.Token]
* fetch the updated [FinancialConnectionsSession] and the generated [com.stripe.android.model.Token]
* and return it back as a [Completed] result.
*/
private fun fetchLinkAccountSessionForToken() {
private fun fetchFinancialConnectionsSessionForToken() {
viewModelScope.launch {
kotlin.runCatching {
fetchLinkAccountSessionForToken(starterArgs.configuration.linkAccountSessionClientSecret)
fetchFinancialConnectionsSessionForToken(
clientSecret = starterArgs.configuration.financialConnectionsSessionClientSecret
)
}.onSuccess { (las, token) ->
val result = Completed(las, token)
eventReporter.onResult(starterArgs.configuration, result)
Expand Down Expand Up @@ -217,8 +219,8 @@ internal class FinancialConnectionsSheetViewModel @Inject constructor(
val manifest = _state.value.manifest
when (intent?.data.toString()) {
manifest?.successUrl -> when (starterArgs) {
is FinancialConnectionsSheetContract.Args.Default -> fetchLinkAccountSession()
is FinancialConnectionsSheetContract.Args.ForToken -> fetchLinkAccountSessionForToken()
is FinancialConnectionsSheetContract.Args.Default -> fetchFinancialConnectionsSession()
is FinancialConnectionsSheetContract.Args.ForToken -> fetchFinancialConnectionsSessionForToken()
}
manifest?.cancelUrl -> onUserCancel()
else -> onFatal(Exception("Error processing FinancialConnectionsSheet intent"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext

internal class DefaultFinancialFinancialConnectionsEventReporter @Inject constructor(
internal class DefaultFinancialConnectionsEventReporter @Inject constructor(
private val analyticsRequestExecutor: AnalyticsRequestExecutor,
private val analyticsRequestFactory: AnalyticsRequestFactory,
@IOContext private val workContext: CoroutineContext
Expand All @@ -20,7 +20,7 @@ internal class DefaultFinancialFinancialConnectionsEventReporter @Inject constru
fireEvent(
FinancialConnectionsAnalyticsEvent(
FinancialConnectionsAnalyticsEvent.Code.SheetPresented,
mapOf(PARAM_CLIENT_SECRET to configuration.linkAccountSessionClientSecret)
mapOf(PARAM_CLIENT_SECRET to configuration.financialConnectionsSessionClientSecret)
)
)
}
Expand All @@ -34,23 +34,23 @@ internal class DefaultFinancialFinancialConnectionsEventReporter @Inject constru
FinancialConnectionsAnalyticsEvent(
FinancialConnectionsAnalyticsEvent.Code.SheetClosed,
mapOf(
PARAM_CLIENT_SECRET to configuration.linkAccountSessionClientSecret,
PARAM_CLIENT_SECRET to configuration.financialConnectionsSessionClientSecret,
PARAM_SESSION_RESULT to "completed"
)
)
is FinancialConnectionsSheetContract.Result.Canceled ->
FinancialConnectionsAnalyticsEvent(
FinancialConnectionsAnalyticsEvent.Code.SheetClosed,
mapOf(
PARAM_CLIENT_SECRET to configuration.linkAccountSessionClientSecret,
PARAM_CLIENT_SECRET to configuration.financialConnectionsSessionClientSecret,
PARAM_SESSION_RESULT to "cancelled"
)
)
is FinancialConnectionsSheetContract.Result.Failed ->
FinancialConnectionsAnalyticsEvent(
FinancialConnectionsAnalyticsEvent.Code.SheetFailed,
mapOf(
PARAM_CLIENT_SECRET to configuration.linkAccountSessionClientSecret,
PARAM_CLIENT_SECRET to configuration.financialConnectionsSessionClientSecret,
PARAM_SESSION_RESULT to "failure"
)
)
Expand Down
Loading

0 comments on commit a3a2796

Please sign in to comment.