Skip to content

Commit

Permalink
Use new backend-provided disclaimer
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Sep 12, 2024
1 parent 1a92721 commit e0ba692
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 298 deletions.
10 changes: 0 additions & 10 deletions financial-connections/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@
</plurals>
<string name="stripe_search">Search</string>
<string name="stripe_account_picker_dropdown_hint">Choose one</string>
<string name="stripe_data_accessible_callout_stripe">Stripe can access %1$s. <annotation clickable="learn_more">Learn more</annotation></string>
<string name="stripe_data_accessible_callout_business">%1$s can access %2$s. <annotation clickable="learn_more">Learn more</annotation></string>
<string name="stripe_data_accessible_callout_no_business">This business can access %1$s. <annotation clickable="learn_more">Learn more</annotation></string>
<string name="stripe_data_accessible_type_accountdetails">account details</string>
<string name="stripe_data_accessible_type_balances">balances</string>
<string name="stripe_data_accessible_type_transactions">transactions</string>
<string name="stripe_data_accessible_type_ownership">account ownership details</string>
<string name="stripe_data_sharing_callout_link_business">Your login and financial details are never shared with %1$s. <annotation clickable="learn_more">Learn more</annotation></string>
<string name="stripe_data_sharing_callout_link_no_business">Your login and financial details are never shared with this business. <annotation clickable="learn_more">Learn more</annotation></string>
<string name="stripe_success_pane_title">Success</string>
<string name="stripe_success_pane_desc_microdeposits">You can expect micro-deposits to account ••••%1$s in 1–2 days and an email with further instructions.</string>
<string name="stripe_success_pane_desc_microdeposits_no_account">You can expect micro-deposits to your account in 1–2 days and an email with further instructions.</string>
<plurals name="stripe_success_pane_desc">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import com.stripe.android.core.exception.APIException
import com.stripe.android.financialconnections.exception.AccountNoneEligibleForPaymentMethodError
import com.stripe.android.financialconnections.features.accountpicker.AccountPickerState.SelectionMode
import com.stripe.android.financialconnections.features.common.MerchantDataAccessModel
import com.stripe.android.financialconnections.model.Bullet
import com.stripe.android.financialconnections.model.ConnectedAccessNotice
import com.stripe.android.financialconnections.model.DataAccessNotice
Expand Down Expand Up @@ -74,7 +73,8 @@ internal class AccountPickerPreviewParameterProvider :
accounts = partnerAccountList(),
dataAccessNotice = dataAccessNotice(),
selectionMode = SelectionMode.Multiple,
dataAccess = accessibleCallout(),
dataAccessDisclaimer = "This business can access account details, balances, " +
"account ownership details and transactions. <a href=\"https://stripe.com\">Learn more</a>",
singleAccount = false,
stripeDirect = false,
businessName = "Random business",
Expand Down Expand Up @@ -103,7 +103,7 @@ internal class AccountPickerPreviewParameterProvider :
accounts = partnerAccountList(),
dataAccessNotice = dataAccessNotice(),
selectionMode = SelectionMode.Single,
dataAccess = accessibleCallout(),
dataAccessDisclaimer = null,
singleAccount = true,
stripeDirect = false,
businessName = "Random business",
Expand Down Expand Up @@ -202,17 +202,4 @@ internal class AccountPickerPreviewParameterProvider :
supportedPaymentMethodTypes = emptyList()
),
)

private fun accessibleCallout() = AccountPickerState.DataAccess.FinancialConnections(
model = MerchantDataAccessModel(
businessName = "My business",
permissions = listOf(
FinancialConnectionsAccount.Permissions.PAYMENT_METHOD,
FinancialConnectionsAccount.Permissions.BALANCES,
FinancialConnectionsAccount.Permissions.OWNERSHIP,
FinancialConnectionsAccount.Permissions.TRANSACTIONS,
),
isStripeDirect = false,
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import com.stripe.android.financialconnections.R
import com.stripe.android.financialconnections.exception.AccountLoadError
import com.stripe.android.financialconnections.exception.AccountNoneEligibleForPaymentMethodError
import com.stripe.android.financialconnections.features.accountpicker.AccountPickerClickableText.DATA
import com.stripe.android.financialconnections.features.accountpicker.AccountPickerState.SelectionMode
import com.stripe.android.financialconnections.features.accountpicker.AccountPickerState.ViewEffect.OpenUrl
import com.stripe.android.financialconnections.features.common.AccountItem
import com.stripe.android.financialconnections.features.common.DataAccessText
import com.stripe.android.financialconnections.features.common.InstitutionIcon
import com.stripe.android.financialconnections.features.common.LoadingShimmerEffect
import com.stripe.android.financialconnections.features.common.NoAccountsAvailableErrorContent
Expand All @@ -50,7 +49,10 @@ import com.stripe.android.financialconnections.presentation.Async.Uninitialized
import com.stripe.android.financialconnections.presentation.paneViewModel
import com.stripe.android.financialconnections.presentation.parentViewModel
import com.stripe.android.financialconnections.ui.FinancialConnectionsPreview
import com.stripe.android.financialconnections.ui.TextResource
import com.stripe.android.financialconnections.ui.components.AnnotatedText
import com.stripe.android.financialconnections.ui.components.FinancialConnectionsButton
import com.stripe.android.financialconnections.ui.sdui.fromHtml
import com.stripe.android.financialconnections.ui.theme.FinancialConnectionsTheme
import com.stripe.android.financialconnections.ui.theme.LazyLayout
import com.stripe.android.uicore.utils.collectAsState
Expand Down Expand Up @@ -160,7 +162,7 @@ private fun AccountPickerLoaded(
footer = {
displayablePayload?.let {
Footer(
dataAccess = it.dataAccess,
dataAccessDisclaimer = it.dataAccessDisclaimer,
onClickableTextClick = onClickableTextClick,
submitEnabled = state.submitEnabled,
submitLoading = state.submitLoading,
Expand Down Expand Up @@ -233,19 +235,21 @@ private fun LazyListScope.accountPickerContent(

@Composable
private fun Footer(
dataAccess: AccountPickerState.DataAccess,
dataAccessDisclaimer: String?,
onClickableTextClick: (String) -> Unit,
submitEnabled: Boolean,
submitLoading: Boolean,
onSubmit: () -> Unit,
selectedIds: Set<String>
) {
Column {
DataAccessText(
dataAccess = dataAccess,
onLearnMoreClick = { onClickableTextClick(DATA.value) },
)
Spacer(modifier = Modifier.size(12.dp))
if (dataAccessDisclaimer != null) {
DataAccessDisclaimerText(
text = dataAccessDisclaimer,
onLearnMoreClick = onClickableTextClick,
)
Spacer(modifier = Modifier.size(12.dp))
}
FinancialConnectionsButton(
enabled = submitEnabled,
loading = submitLoading,
Expand All @@ -264,6 +268,22 @@ private fun Footer(
}
}

@Composable
private fun DataAccessDisclaimerText(
text: String,
onLearnMoreClick: (String) -> Unit
) {
AnnotatedText(
modifier = Modifier.fillMaxWidth(),
text = TextResource.Text(fromHtml(text)),
onClickableTextClick = onLearnMoreClick,
defaultStyle = FinancialConnectionsTheme.typography.labelSmall.copy(
color = FinancialConnectionsTheme.colors.textDefault,
textAlign = TextAlign.Center,
),
)
}

@Preview(
showBackground = true,
group = "Account Picker Pane",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.stripe.android.financialconnections.analytics.logError
import com.stripe.android.financialconnections.di.FinancialConnectionsSheetNativeComponent
import com.stripe.android.financialconnections.domain.GetCachedConsumerSession
import com.stripe.android.financialconnections.domain.GetOrFetchSync
import com.stripe.android.financialconnections.domain.IsLinkWithStripe
import com.stripe.android.financialconnections.domain.NativeAuthFlowCoordinator
import com.stripe.android.financialconnections.domain.PollAuthorizationSessionAccounts
import com.stripe.android.financialconnections.domain.SaveAccountToLink
Expand All @@ -28,7 +27,6 @@ import com.stripe.android.financialconnections.domain.toCachedPartnerAccounts
import com.stripe.android.financialconnections.features.accountpicker.AccountPickerClickableText.DATA
import com.stripe.android.financialconnections.features.accountpicker.AccountPickerState.SelectionMode
import com.stripe.android.financialconnections.features.accountpicker.AccountPickerState.ViewEffect
import com.stripe.android.financialconnections.features.common.MerchantDataAccessModel
import com.stripe.android.financialconnections.features.common.canSaveAccountsToLink
import com.stripe.android.financialconnections.features.common.isDataFlow
import com.stripe.android.financialconnections.features.notice.NoticeSheetState.NoticeSheetContent.DataAccess
Expand Down Expand Up @@ -69,7 +67,6 @@ internal class AccountPickerViewModel @AssistedInject constructor(
private val logger: Logger,
private val pollAuthorizationSessionAccounts: PollAuthorizationSessionAccounts,
private val presentSheet: PresentSheet,
private val isLinkWithStripe: IsLinkWithStripe,
) : FinancialConnectionsViewModel<AccountPickerState>(initialState, nativeAuthFlowCoordinator) {

init {
Expand Down Expand Up @@ -121,20 +118,7 @@ internal class AccountPickerViewModel @AssistedInject constructor(
}

val accounts = partnerAccountList.data.sortedBy { it.allowSelection.not() }

val dataAccess = if (isLinkWithStripe()) {
AccountPickerState.DataAccess.InstantDebits(
businessName = manifest.businessName,
)
} else {
AccountPickerState.DataAccess.FinancialConnections(
model = MerchantDataAccessModel(
businessName = manifest.businessName,
permissions = manifest.permissions,
isStripeDirect = manifest.isStripeDirect ?: false
)
)
}
val dataAccessDisclaimer = sync.text?.accountPicker?.dataAccessNotice

AccountPickerState.Payload(
// note that this uses ?? instead of ||, we do NOT want to skip account selection
Expand All @@ -147,7 +131,7 @@ internal class AccountPickerViewModel @AssistedInject constructor(
accounts = accounts,
selectionMode = if (manifest.singleAccount) SelectionMode.Single else SelectionMode.Multiple,
dataAccessNotice = dataAccessNotice,
dataAccess = dataAccess,
dataAccessDisclaimer = dataAccessDisclaimer,
singleAccount = manifest.singleAccount,
userSelectedSingleAccountInInstitution = manifest.singleAccount &&
activeAuthSession.institutionSkipAccountSelection == true &&
Expand Down Expand Up @@ -363,22 +347,12 @@ internal class AccountPickerViewModel @AssistedInject constructor(
},
knownDeeplinkActions = mapOf(
DATA.value to {
presentDataAccessNotice()
presentDataAccessBottomSheet()
}
)
)
}

private fun presentDataAccessNotice() {
if (isLinkWithStripe()) {
val date = Date()
val url = "https://support.link.com/questions/connecting-your-bank-account"
setState { copy(viewEffect = ViewEffect.OpenUrl(url, date.time)) }
} else {
presentDataAccessBottomSheet()
}
}

private fun presentDataAccessBottomSheet() {
val dataAccessNotice = stateFlow.value.payload()?.dataAccessNotice ?: return
eventTracker.track(ClickLearnMoreDataAccess(PANE))
Expand Down Expand Up @@ -428,9 +402,9 @@ internal data class AccountPickerState(
data class Payload(
val skipAccountSelection: Boolean,
val accounts: List<PartnerAccount>,
val dataAccessDisclaimer: String?,
val dataAccessNotice: DataAccessNotice?,
val selectionMode: SelectionMode,
val dataAccess: DataAccess,
val singleAccount: Boolean,
val stripeDirect: Boolean,
val businessName: String?,
Expand All @@ -444,17 +418,6 @@ internal data class AccountPickerState(
get() = skipAccountSelection || userSelectedSingleAccountInInstitution
}

sealed interface DataAccess {

data class InstantDebits(
val businessName: String?,
) : DataAccess

data class FinancialConnections(
val model: MerchantDataAccessModel,
) : DataAccess
}

enum class SelectionMode {
Single, Multiple
}
Expand Down
Loading

0 comments on commit e0ba692

Please sign in to comment.