Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and testing for merchant-initiated repair flows #4522

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,36 @@ final class PlaygroundConfiguration {
configurationStore[Self.phoneKey] = newValue
}
}

// MARK: - Relink Authorization

private static let customerIdKey = "customer_id"
var customerId: String {
get {
if let customerId = configurationStore[Self.customerIdKey] as? String {
return customerId
} else {
return ""
}
}
set {
configurationStore[Self.customerIdKey] = newValue
}
}

private static let relinkAuthorizationKey = "relink_authorization"
var relinkAuthorization: String {
get {
if let relinkAuthorization = configurationStore[Self.relinkAuthorizationKey] as? String {
return relinkAuthorization
} else {
return ""
}
}
set {
configurationStore[Self.relinkAuthorizationKey] = newValue
tillh-stripe marked this conversation as resolved.
Show resolved Hide resolved
}
}

// MARK: - Permissions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ struct PlaygroundView: View {
.accessibility(identifier: "playground-phone")
}
}

Section(header: Text("Relink")) {
TextField("Customer", text: viewModel.customerId)
tillh-stripe marked this conversation as resolved.
Show resolved Hide resolved
.keyboardType(.default)
.autocapitalization(.none)
.accessibility(identifier: "playground-customer-id")

TextField("Relink authorization", text: viewModel.relinkAuthorization)
tillh-stripe marked this conversation as resolved.
Show resolved Hide resolved
.keyboardType(.default)
.accessibility(identifier: "playground-relink-authorization")
}

Section(header: Text("PERMISSIONS")) {
Toggle("Balances", isOn: viewModel.balancesPermission)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,30 @@ final class PlaygroundViewModel: ObservableObject {
}
)
}

var customerId: Binding<String> {
Binding(
get: {
self.playgroundConfiguration.customerId
},
set: {
self.playgroundConfiguration.customerId = $0
self.objectWillChange.send()
}
)
}

var relinkAuthorization: Binding<String> {
Binding(
get: {
self.playgroundConfiguration.relinkAuthorization
},
set: {
self.playgroundConfiguration.relinkAuthorization = $0
self.objectWillChange.send()
}
)
}

var balancesPermission: Binding<Bool> {
Binding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ extension NativeFlowController {
//
// keeping this logic in `pushPane` is helpful because we want to
// reuse `skipSuccessPane` and `manualEntryMode == .custom` logic
clearNavigationStack: Bool = false
clearNavigationStack: Bool = false,
// Useful for cases where we want to prevent the current pane from being shown again,
// but not affect any previous panes.
removeCurrent: Bool = false
) {
if pane == .success && dataManager.manifest.skipSuccessPane == true {
closeAuthFlow(error: nil)
Expand All @@ -192,8 +195,11 @@ extension NativeFlowController {
nativeFlowController: self,
dataManager: dataManager
)
if clearNavigationStack, let paneViewController = paneViewController {
if clearNavigationStack, let paneViewController {
setNavigationControllerViewControllers([paneViewController], animated: animated)
} else if removeCurrent, let paneViewController {
let viewControllers = Array(navigationController.viewControllers.dropLast())
setNavigationControllerViewControllers(viewControllers + [paneViewController], animated: animated)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this scenario, is there a back button on the current pane? If so, pressing it would skip the immediately previous pane the user saw and go back two panes. Would this UX feel disjointed at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that’s what will happen and is in line with the behavior on Web.

} else {
pushViewController(paneViewController, animated: animated)
}
Expand Down Expand Up @@ -829,6 +835,14 @@ extension NativeFlowController: PartnerAuthViewControllerDelegate {

showErrorPane(forError: error, referrerPane: .partnerAuth)
}

func partnerAuthViewController(
_ viewController: PartnerAuthViewController,
didRequestNextPane nextPane: FinancialConnectionsSessionManifest.NextPane
) {
dataManager.authSession = nil // clear any lingering auth sessions
pushPane(nextPane, animated: true, removeCurrent: true)
}
}

// MARK: - AccountPickerViewControllerDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ protocol PartnerAuthViewControllerDelegate: AnyObject {
_ viewController: PartnerAuthViewController,
didReceiveError error: Error
)
func partnerAuthViewController(
_ viewController: PartnerAuthViewController,
didRequestNextPane nextPane: FinancialConnectionsSessionManifest.NextPane
)
}

final class PartnerAuthViewController: SheetViewController {
Expand Down Expand Up @@ -157,7 +161,20 @@ final class PartnerAuthViewController: SheetViewController {
},
didSelectCancel: { [weak self] in
guard let self = self else { return }
self.delegate?.partnerAuthViewControllerDidRequestToGoBack(self)
let isModal = panePresentationStyle == .sheet

self.dataSource.analyticsClient.log(
eventName: isModal ? "click.prepane.cancel" : "click.prepane.choose_another_bank",
pane: .partnerAuth
)

self.dataSource.cancelPendingAuthSessionIfNeeded()

if isModal {
self.delegate?.partnerAuthViewControllerDidRequestToGoBack(self)
} else {
self.delegate?.partnerAuthViewController(self, didRequestNextPane: .institutionPicker)
}
}
)
self.prepaneViews = prepaneViews
Expand Down
Loading