Skip to content

Commit 84a0193

Browse files
authored
Merge pull request #5914 from woocommerce/issue/5528-both-active
[Mobile Payments] Show "Both WCPay and Stripe Extension are active" screen when both plugins installed
2 parents 4678118 + 5767d3a commit 84a0193

File tree

5 files changed

+81
-2
lines changed

5 files changed

+81
-2
lines changed

Storage/Storage/Model/GeneralAppSettings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public struct GeneralAppSettings: Codable, Equatable, GeneratedCopiable {
2828
///
2929
public let isOrderCreationSwitchEnabled: Bool
3030

31-
/// Thes state for the Stripe Gateway Extension IPP feature switch
31+
/// The state for the Stripe Gateway Extension IPP feature switch
3232
///
3333
public let isStripeInPersonPaymentsSwitchEnabled: Bool
3434

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct InPersonPaymentsView: View {
2727
switch viewModel.state {
2828
case .loading:
2929
InPersonPaymentsLoading()
30+
case .selectPlugin:
31+
InPersonPaymentsSelectPlugin(onRefresh: viewModel.refresh)
3032
case .countryNotSupported(let countryCode):
3133
InPersonPaymentsCountryNotSupported(countryCode: countryCode)
3234
case .pluginNotInstalled:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import SwiftUI
2+
3+
struct InPersonPaymentsSelectPlugin: View {
4+
let onRefresh: () -> Void
5+
@State var presentedSetupURL: URL? = nil
6+
7+
var body: some View {
8+
ScrollableVStack {
9+
Spacer()
10+
11+
InPersonPaymentsOnboardingError.MainContent(
12+
title: Localization.title,
13+
message: Localization.message,
14+
image: InPersonPaymentsOnboardingError.ImageInfo(
15+
image: .paymentsPlugin,
16+
height: Constants.height
17+
),
18+
supportLink: false
19+
)
20+
21+
Spacer()
22+
23+
Button {
24+
presentedSetupURL = setupURL
25+
} label: {
26+
HStack {
27+
Text(Localization.primaryButton)
28+
Image(uiImage: .externalImage)
29+
}
30+
}
31+
.buttonStyle(PrimaryButtonStyle())
32+
.padding(.bottom, Constants.padding)
33+
34+
InPersonPaymentsLearnMore()
35+
}
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)
45+
}
46+
}
47+
48+
private enum Localization {
49+
static let title = NSLocalizedString(
50+
"Please select an extension",
51+
comment: "Title for the error screen when there is more than one extension active."
52+
)
53+
54+
static let message = NSLocalizedString(
55+
"You must disable either the WooCommerce Payments or the WooCommerce Stripe Gateway extension.",
56+
comment: "Message requesting merchants to select between available payments processors"
57+
)
58+
59+
static let primaryButton = NSLocalizedString(
60+
"Select extension in Store Admin",
61+
comment: "Button to select the active payment processor plugin"
62+
)
63+
}
64+
65+
private enum Constants {
66+
static let height: CGFloat = 108.0
67+
static let padding: CGFloat = 24.0
68+
}
69+
70+
struct InPersonPaymentsSelectPlugin_Previews: PreviewProvider {
71+
static var previews: some View {
72+
InPersonPaymentsSelectPlugin(onRefresh: {})
73+
}
74+
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@
14071407
D89CFF3A25B43BBB000E4683 /* WrongAccountErrorViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89CFF3925B43BBB000E4683 /* WrongAccountErrorViewModel.swift */; };
14081408
D89CFFDD25B44468000E4683 /* ULAccountMismatchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89CFFDB25B44468000E4683 /* ULAccountMismatchViewController.swift */; };
14091409
D89CFFDE25B44468000E4683 /* ULAccountMismatchViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D89CFFDC25B44468000E4683 /* ULAccountMismatchViewController.xib */; };
1410+
D89FAF4E2795BDFF00D8DA66 /* InPersonPaymentsSelectPluginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89FAF4D2795BDFF00D8DA66 /* InPersonPaymentsSelectPluginView.swift */; };
14101411
D8A8C4F32268288F001C72BF /* AddManualCustomTrackingViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A8C4F22268288F001C72BF /* AddManualCustomTrackingViewModelTests.swift */; };
14111412
D8AB131E225DC25F002BB5D1 /* MockOrders.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AB131D225DC25F002BB5D1 /* MockOrders.swift */; };
14121413
D8B4D5EE26C2C26C00F34E94 /* InPersonPaymentsStripeAcountReviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8B4D5ED26C2C26C00F34E94 /* InPersonPaymentsStripeAcountReviewView.swift */; };
@@ -3008,6 +3009,7 @@
30083009
D89CFF3925B43BBB000E4683 /* WrongAccountErrorViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrongAccountErrorViewModel.swift; sourceTree = "<group>"; };
30093010
D89CFFDB25B44468000E4683 /* ULAccountMismatchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ULAccountMismatchViewController.swift; sourceTree = "<group>"; };
30103011
D89CFFDC25B44468000E4683 /* ULAccountMismatchViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ULAccountMismatchViewController.xib; sourceTree = "<group>"; };
3012+
D89FAF4D2795BDFF00D8DA66 /* InPersonPaymentsSelectPluginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InPersonPaymentsSelectPluginView.swift; sourceTree = "<group>"; };
30113013
D8A8C4F22268288F001C72BF /* AddManualCustomTrackingViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AddManualCustomTrackingViewModelTests.swift; path = WooCommerceTests/Model/AddManualCustomTrackingViewModelTests.swift; sourceTree = SOURCE_ROOT; };
30123014
D8AB131D225DC25F002BB5D1 /* MockOrders.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockOrders.swift; sourceTree = "<group>"; };
30133015
D8B4D5ED26C2C26C00F34E94 /* InPersonPaymentsStripeAcountReviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InPersonPaymentsStripeAcountReviewView.swift; sourceTree = "<group>"; };
@@ -7289,6 +7291,7 @@
72897291
E15F163026C5117300D3059B /* InPersonPaymentsNoConnectionView.swift */,
72907292
310D1B472734919E001D55B4 /* InPersonPaymentsLiveSiteInTestModeView.swift */,
72917293
ABC35055F8AC8C8EB649F421 /* InPersonPaymentsUnavailableView.swift */,
7294+
D89FAF4D2795BDFF00D8DA66 /* InPersonPaymentsSelectPluginView.swift */,
72927295
ABC35A4B736A0B2D8348DD08 /* InPersonPaymentsOnboardingError.swift */,
72937296
);
72947297
path = "Onboarding Errors";
@@ -8133,6 +8136,7 @@
81338136
AEE2610F26E664CE00B142A0 /* EditOrderAddressFormViewModel.swift in Sources */,
81348137
025C00BA25514A7100FAC222 /* BarcodeScannerFrameScaler.swift in Sources */,
81358138
02913E9723A774E600707A0C /* DecimalInputFormatter.swift in Sources */,
8139+
D89FAF4E2795BDFF00D8DA66 /* InPersonPaymentsSelectPluginView.swift in Sources */,
81368140
E15F163126C5117300D3059B /* InPersonPaymentsNoConnectionView.swift in Sources */,
81378141
456CB50D2444BFAC00992A05 /* ProductPurchaseNoteViewController.swift in Sources */,
81388142
D802541F2655137A001B2CC1 /* CardPresentModalNonRetryableError.swift in Sources */,

Yosemite/Yosemite/Stores/AppSettingsStore.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ private extension AppSettingsStore {
313313
} catch {
314314
onCompletion(.failure(error))
315315
}
316-
317316
}
318317

319318
/// Sets the state for the Product SKU Input Scanner beta feature switch into `GeneralAppSettings`.

0 commit comments

Comments
 (0)