Created
June 7, 2022 10:28
-
-
Save koke/8866d7eb16224e56a4b7bc9dbba640f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift | |
index d26f26b356..bb4eeb5019 100644 | |
--- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift | |
+++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift | |
@@ -96,7 +96,7 @@ final class CardPresentPaymentsOnboardingUseCase: CardPresentPaymentsOnboardingU | |
precondition(state == .selectPlugin) | |
preferredPluginLocal = plugin | |
updateState() | |
- if state == .completed(plugin: plugin) { | |
+ if state == .completed(plugin: plugin, multipleGateways: true) { | |
savePreferredPlugin(plugin) | |
} | |
} | |
@@ -166,9 +166,9 @@ private extension CardPresentPaymentsOnboardingUseCase { | |
switch (wcPay, stripe) { | |
case (.some(let wcPay), nil): | |
- return wcPayOnlyOnboardingState(plugin: wcPay) | |
+ return wcPayOnlyOnboardingState(plugin: wcPay, multipleGateways: false) | |
case (nil, .some(let stripe)): | |
- return stripeGatewayOnlyOnboardingState(plugin: stripe) | |
+ return stripeGatewayOnlyOnboardingState(plugin: stripe, multipleGateways: false) | |
case (.some(let wcPay), .some(let stripe)): | |
return bothPluginsInstalledOnboardingState(wcPay: wcPay, stripe: stripe) | |
case (nil, nil): | |
@@ -181,9 +181,9 @@ private extension CardPresentPaymentsOnboardingUseCase { | |
case (true, true): | |
return bothPluginsInstalledAndActiveOnboardingState(wcPay: wcPay, stripe: stripe) | |
case (true, false): | |
- return wcPayOnlyOnboardingState(plugin: wcPay) | |
+ return wcPayOnlyOnboardingState(plugin: wcPay, multipleGateways: true) | |
case (false, true): | |
- return stripeGatewayOnlyOnboardingState(plugin: stripe) | |
+ return stripeGatewayOnlyOnboardingState(plugin: stripe, multipleGateways: true) | |
case (false, false): | |
return .pluginNotActivated(plugin: .wcPay) | |
} | |
@@ -199,11 +199,16 @@ private extension CardPresentPaymentsOnboardingUseCase { | |
} | |
if !isStripeSupportedInCountry { | |
- return wcPayOnlyOnboardingState(plugin: wcPay) | |
+ return wcPayOnlyOnboardingState(plugin: wcPay, multipleGateways: true) | |
} | |
if let preferredPlugin = preferredPluginLocal { | |
- return onboardingStateForPlugin(preferredPlugin, wcPay: wcPay, stripe: stripe) | |
+ switch preferredPlugin { | |
+ case .wcPay: | |
+ return wcPayOnlyOnboardingState(plugin: wcPay, multipleGateways: true) | |
+ case .stripe: | |
+ return stripeGatewayOnlyOnboardingState(plugin: stripe, multipleGateways: true) | |
+ } | |
} | |
return .selectPlugin | |
@@ -217,16 +222,7 @@ private extension CardPresentPaymentsOnboardingUseCase { | |
return .selectPlugin | |
} | |
- func onboardingStateForPlugin(_ plugin: CardPresentPaymentsPlugin, wcPay: SystemPlugin, stripe: SystemPlugin) -> CardPresentPaymentOnboardingState { | |
- switch plugin { | |
- case .wcPay: | |
- return wcPayOnlyOnboardingState(plugin: wcPay) | |
- case .stripe: | |
- return stripeGatewayOnlyOnboardingState(plugin: stripe) | |
- } | |
- } | |
- | |
- func wcPayOnlyOnboardingState(plugin: SystemPlugin) -> CardPresentPaymentOnboardingState { | |
+ func wcPayOnlyOnboardingState(plugin: SystemPlugin, multipleGateways: Bool) -> CardPresentPaymentOnboardingState { | |
// Plugin checks | |
guard cardPresentPluginsDataProvider.isWCPayVersionSupported(plugin: plugin) | |
else { | |
@@ -237,10 +233,10 @@ private extension CardPresentPaymentsOnboardingUseCase { | |
} | |
// Account checks | |
- return accountChecks(plugin: .wcPay) | |
+ return accountChecks(plugin: .wcPay, multipleGateways: multipleGateways) | |
} | |
- func stripeGatewayOnlyOnboardingState(plugin: SystemPlugin) -> CardPresentPaymentOnboardingState { | |
+ func stripeGatewayOnlyOnboardingState(plugin: SystemPlugin, multipleGateways: Bool) -> CardPresentPaymentOnboardingState { | |
guard isStripeSupportedInCountry else { | |
guard let countryCode = storeCountryCode else { | |
DDLogError("[CardPresentPaymentsOnboarding] Couldn't determine country for store") | |
@@ -257,10 +253,10 @@ private extension CardPresentPaymentsOnboardingUseCase { | |
return .pluginNotActivated(plugin: .stripe) | |
} | |
- return accountChecks(plugin: .stripe) | |
+ return accountChecks(plugin: .stripe, multipleGateways: multipleGateways) | |
} | |
- func accountChecks(plugin: CardPresentPaymentsPlugin) -> CardPresentPaymentOnboardingState { | |
+ func accountChecks(plugin: CardPresentPaymentsPlugin, multipleGateways: Bool) -> CardPresentPaymentOnboardingState { | |
guard let account = getPaymentGatewayAccount(plugin: plugin) else { | |
/// Active plugin but unable to fetch an account? Prompt the merchant to finish setting it up. | |
return .pluginSetupNotCompleted(plugin: plugin) | |
@@ -291,7 +287,7 @@ private extension CardPresentPaymentsOnboardingUseCase { | |
let setAccount = CardPresentPaymentAction.use(paymentGatewayAccount: account) | |
stores.dispatch(setAccount) | |
- return .completed(plugin: plugin) | |
+ return .completed(plugin: plugin, multipleGateways: multipleGateways) | |
} | |
} | |
diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsMenuViewController.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsMenuViewController.swift | |
index 2cc3ce7205..9cf8f0cdff 100644 | |
--- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsMenuViewController.swift | |
+++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsMenuViewController.swift | |
@@ -4,11 +4,13 @@ import Yosemite | |
final class InPersonPaymentsMenuViewController: UITableViewController { | |
private let plugin: CardPresentPaymentsPlugin | |
+ private let multipleGateways: Bool | |
private var rows = [Row]() | |
private let configurationLoader: CardPresentConfigurationLoader | |
- init(plugin: CardPresentPaymentsPlugin) { | |
+ init(plugin: CardPresentPaymentsPlugin, multipleGateways: Bool) { | |
self.plugin = plugin | |
+ self.multipleGateways = multipleGateways | |
configurationLoader = CardPresentConfigurationLoader() | |
super.init(style: .grouped) | |
} | |
@@ -260,9 +262,10 @@ private enum Constants { | |
/// | |
struct InPersonPaymentsMenu: UIViewControllerRepresentable { | |
let plugin: CardPresentPaymentsPlugin | |
+ let multipleGateways: Bool | |
func makeUIViewController(context: Context) -> some UIViewController { | |
- InPersonPaymentsMenuViewController(plugin: plugin) | |
+ InPersonPaymentsMenuViewController(plugin: plugin, multipleGateways: multipleGateways) | |
} | |
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { | |
diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsViewController.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsViewController.swift | |
index 8ed5fa8e83..23b9acbe96 100644 | |
--- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsViewController.swift | |
+++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsViewController.swift | |
@@ -70,9 +70,9 @@ struct InPersonPaymentsView: View { | |
InPersonPaymentsStripeAccountReview() | |
case .stripeAccountRejected: | |
InPersonPaymentsStripeRejected() | |
- case .completed(let plugin): | |
+ case .completed(let plugin, let multipleGateways): | |
if viewModel.showMenuOnCompletion { | |
- InPersonPaymentsMenu(plugin: plugin) | |
+ InPersonPaymentsMenu(plugin: plugin, multipleGateways: multipleGateways) | |
} else { | |
InPersonPaymentsCompleted() | |
} | |
@@ -108,7 +108,7 @@ private enum Localization { | |
struct InPersonPaymentsView_Previews: PreviewProvider { | |
static var previews: some View { | |
NavigationView { | |
- InPersonPaymentsView(viewModel: InPersonPaymentsViewModel(fixedState: .completed(plugin: .stripe))) | |
+ InPersonPaymentsView(viewModel: InPersonPaymentsViewModel(fixedState: .completed(plugin: .stripe, multipleGateways: false))) | |
} | |
} | |
} | |
diff --git a/Yosemite/Yosemite/Model/Enums/CardPresentPaymentsOnboardingState.swift b/Yosemite/Yosemite/Model/Enums/CardPresentPaymentsOnboardingState.swift | |
index a8c1e9b2fc..ad3f5f8051 100644 | |
--- a/Yosemite/Yosemite/Model/Enums/CardPresentPaymentsOnboardingState.swift | |
+++ b/Yosemite/Yosemite/Model/Enums/CardPresentPaymentsOnboardingState.swift | |
@@ -6,7 +6,7 @@ public enum CardPresentPaymentOnboardingState: Equatable { | |
/// All the requirements are met and the feature is ready to use | |
/// | |
- case completed(plugin: CardPresentPaymentsPlugin) | |
+ case completed(plugin: CardPresentPaymentsPlugin, multipleGateways: Bool) | |
/// There is more than one plugin installed and activated. The user must deactivate one. | |
/// | |
@@ -115,7 +115,7 @@ extension CardPresentPaymentOnboardingState { | |
} | |
public var isCompleted: Bool { | |
- if case .completed(_) = self { | |
+ if case .completed = self { | |
return true | |
} else { | |
return false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment