Skip to content

Commit b0f5bba

Browse files
committed
Simplify. Make the new screen a dead end
1 parent 6fc256c commit b0f5bba

File tree

4 files changed

+37
-70
lines changed

4 files changed

+37
-70
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ final class CardPresentPaymentsOnboardingUseCase: CardPresentPaymentsOnboardingU
3131
let storageManager: StorageManagerType
3232
let stores: StoresManager
3333
private var stripeGatewayIPPEnabled: Bool?
34-
private var bypassPluginSelection: Bool = false
3534

3635
@Published var state: CardPresentPaymentOnboardingState = .loading
3736

@@ -66,12 +65,6 @@ final class CardPresentPaymentsOnboardingUseCase: CardPresentPaymentsOnboardingU
6665
}
6766
}
6867

69-
func refreshBypassingPluginSelection() {
70-
bypassPluginSelection = true
71-
72-
refresh()
73-
}
74-
7568
/// We need to sync payment gateway accounts to see if the payment gateway is set up correctly.
7669
/// But first we also need to prompt the CardPresentPaymentStore to use the right backend based on the active plugin.
7770
///
@@ -80,11 +73,6 @@ final class CardPresentPaymentsOnboardingUseCase: CardPresentPaymentsOnboardingU
8073
return
8174
}
8275

83-
guard !bypassPluginSelection else {
84-
self.updateState()
85-
return
86-
}
87-
8876
let wcPayPlugin = getWCPayPlugin()
8977
let stripePlugin = getStripePlugin()
9078

@@ -187,7 +175,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
187175

188176
// If both the Stripe plugin and WCPay are installed and activated, the user needs
189177
// to deactivate one: pdfdoF-fW-p2#comment-683
190-
if bothPluginsInstalledAndActive(wcPay: wcPay, stripe: stripe) && bypassPluginSelection == false {
178+
if bothPluginsInstalledAndActive(wcPay: wcPay, stripe: stripe) {
191179
return .selectPlugin
192180
}
193181

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct InPersonPaymentsView: View {
2828
case .loading:
2929
InPersonPaymentsLoading()
3030
case .selectPlugin:
31-
InPersonPaymentsSelectPlugin(onRefresh: viewModel.updateGateway(useStripe:))
31+
InPersonPaymentsSelectPlugin(onRefresh: viewModel.refresh)
3232
case .countryNotSupported(let countryCode):
3333
InPersonPaymentsCountryNotSupported(countryCode: countryCode)
3434
case .pluginNotInstalled:

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsViewModel.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ final class InPersonPaymentsViewModel: ObservableObject {
3131
func refresh() {
3232
useCase.refresh()
3333
}
34-
35-
func updateGateway(useStripe: Bool) {
36-
let storesManager = ServiceLocator.stores
37-
guard let siteID = storesManager.sessionManager.defaultStoreID else {
38-
return
39-
}
40-
41-
let saveStripeActivationStatus = AppSettingsAction.setStripeExtensionAvailability(siteID: siteID, isAvailable: useStripe) { [weak self] result in
42-
self?.useCase.refreshBypassingPluginSelection()
43-
}
44-
45-
storesManager.dispatch(saveStripeActivationStatus)
46-
}
4734
}
4835

4936
private func trackState(_ state: CardPresentPaymentOnboardingState) {
Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
11
import SwiftUI
22

33
struct InPersonPaymentsSelectPlugin: View {
4-
let onRefresh: (Bool) -> Void
5-
6-
@State private var activateWCPay = true
7-
@State private var activateStripe = true
4+
let onRefresh: () -> Void
5+
@State var presentedSetupURL: URL? = nil
86

97
var body: some View {
10-
VStack {
11-
InPersonPaymentsOnboardingError(
12-
title: Localization.unavailable,
8+
ScrollableVStack {
9+
Spacer()
10+
11+
InPersonPaymentsOnboardingError.MainContent(
12+
title: Localization.title,
1313
message: Localization.message,
1414
image: InPersonPaymentsOnboardingError.ImageInfo(
15-
image: .paymentErrorImage,
16-
height: 180.0
15+
image: .paymentsPlugin,
16+
height: 108.0
1717
),
18-
supportLink: false,
19-
learnMore: false,
20-
button: InPersonPaymentsOnboardingError.ButtonInfo(
21-
text: Localization.primaryButton,
22-
action: {
23-
onRefresh(activateStripe)
24-
}
25-
)
18+
supportLink: false
2619
)
2720

28-
VStack {
29-
// Switch to activate WooCommercePayments
30-
Toggle(Localization.wcPay, isOn: $activateWCPay)
31-
.onChange(of: activateWCPay, perform: { value in
32-
activateStripe = !value
33-
})
21+
Spacer()
3422

35-
// Switch to activate Stripe extension
36-
Toggle(Localization.stripeExtension, isOn: $activateStripe)
37-
.onChange(of: activateStripe, perform: { value in
38-
activateWCPay = !value
39-
})
23+
Button {
24+
presentedSetupURL = setupURL
25+
} label: {
26+
HStack {
27+
Text(Localization.primaryButton)
28+
Image(uiImage: .externalImage)
29+
}
4030
}
41-
.padding([.leading, .trailing, .bottom])
31+
.buttonStyle(PrimaryButtonStyle())
32+
.padding(.bottom, 24.0)
33+
34+
InPersonPaymentsLearnMore()
4235
}
36+
.safariSheet(url: $presentedSetupURL, onDismiss: onRefresh)
37+
}
38+
39+
var setupURL: URL? {
40+
guard let adminURL = ServiceLocator.stores.sessionManager.defaultSite?.adminURL else {
41+
return nil
42+
}
43+
44+
return URL(string: adminURL)
4345
}
4446
}
4547

4648
private enum Localization {
47-
static let unavailable = NSLocalizedString(
49+
static let title = NSLocalizedString(
4850
"Please select an extension",
4951
comment: "Title for the error screen when there is more than one extension active."
5052
)
@@ -54,24 +56,14 @@ private enum Localization {
5456
comment: "Message requesting merchants to select between available payments processors"
5557
)
5658

57-
static let stripeExtension = NSLocalizedString(
58-
"Stripe Extension",
59-
comment: "Message asking merchants whether the Stripe Extension should be active"
60-
)
61-
62-
static let wcPay = NSLocalizedString(
63-
"WooCommerce Payments",
64-
comment: "Message asking merchants whether the WooCommerce Payments should be active"
65-
)
66-
6759
static let primaryButton = NSLocalizedString(
68-
"Refresh",
69-
comment: "Button to reload plugin data after selecting a payment plugin"
60+
"Select extension in Store Admin",
61+
comment: "Button to set up the WooCommerce Payments plugin after installing it"
7062
)
7163
}
7264

7365
struct InPersonPaymentsSelectPlugin_Previews: PreviewProvider {
7466
static var previews: some View {
75-
InPersonPaymentsSelectPlugin(onRefresh: {_ in })
67+
InPersonPaymentsSelectPlugin(onRefresh: {})
7668
}
7769
}

0 commit comments

Comments
 (0)