Skip to content

Commit 07b8c1c

Browse files
authored
Merge pull request #5935 from woocommerce/issue/5934-only-stripe-installed-but-not-active
Check for when Stripe is installed but not active
2 parents 1010e4a + 92f6427 commit 07b8c1c

File tree

10 files changed

+146
-89
lines changed

10 files changed

+146
-89
lines changed

WooCommerce/Classes/ViewModels/CardPresentPayments/CardPresentModalFoundReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final class CardPresentModalFoundReader: CardPresentPaymentsModalViewModel {
5252
private extension CardPresentModalFoundReader {
5353
enum Localization {
5454
static let title = NSLocalizedString(
55-
"Do you want to connect to reader %@?",
55+
"Do you want to connect to reader %1$@?",
5656
comment: "Dialog title that displays the name of a found card reader"
5757
)
5858

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ private extension CardPresentPaymentsOnboardingUseCase {
163163
return .selectPlugin
164164
}
165165

166-
// If only the Stripe extension is active, skip to checking plugin version
166+
// If only the Stripe extension is installed, skip to checking Stripe activation and version
167167
if let stripe = stripe,
168-
onlyStripeIsActive(wcPay: wcPay, stripe: stripe) {
168+
onlyStripeIsInstalled(wcPay: wcPay, stripe: stripe) {
169169
return stripeGatewayOnlyOnboardingState(plugin: stripe)
170170
} else {
171171
return wcPayOnlyOnboardingState(plugin: wcPay)
@@ -181,7 +181,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
181181
return .pluginUnsupportedVersion(plugin: .wcPay)
182182
}
183183
guard plugin.active else {
184-
return .pluginNotActivated
184+
return .pluginNotActivated(plugin: .wcPay)
185185
}
186186

187187
// Account checks
@@ -192,6 +192,10 @@ private extension CardPresentPaymentsOnboardingUseCase {
192192
guard isStripeVersionSupported(plugin: plugin) else {
193193
return .pluginUnsupportedVersion(plugin: .stripe)
194194
}
195+
guard plugin.active else {
196+
return .pluginNotActivated(plugin: .stripe)
197+
}
198+
195199
return accountChecks()
196200
}
197201

@@ -273,12 +277,13 @@ private extension CardPresentPaymentsOnboardingUseCase {
273277
return wcPay.active && stripe.active
274278
}
275279

276-
func onlyStripeIsActive(wcPay: SystemPlugin?, stripe: SystemPlugin) -> Bool {
277-
if let wcPay = wcPay {
278-
return wcPay.active == false && stripe.active == true
279-
} else {
280-
return stripe.active
280+
func onlyStripeIsInstalled(wcPay: SystemPlugin?, stripe: SystemPlugin) -> Bool {
281+
// If the WCPay plugin is installed, immediately return false
282+
guard wcPay == nil else {
283+
return false
281284
}
285+
286+
return true
282287
}
283288

284289
func isWCPayVersionSupported(plugin: SystemPlugin) -> Bool {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ struct InPersonPaymentsView: View {
3535
InPersonPaymentsPluginNotInstalled(onRefresh: viewModel.refresh)
3636
case .pluginUnsupportedVersion(let plugin):
3737
InPersonPaymentsPluginNotSupportedVersion(plugin: plugin, onRefresh: viewModel.refresh)
38-
case .pluginNotActivated:
39-
InPersonPaymentsPluginNotActivated(onRefresh: viewModel.refresh)
38+
case .pluginNotActivated(let plugin):
39+
InPersonPaymentsPluginNotActivated(plugin: plugin, onRefresh: viewModel.refresh)
4040
case .pluginInTestModeWithLiveStripeAccount:
4141
InPersonPaymentsLiveSiteInTestMode(onRefresh:
4242
viewModel.refresh)

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/Onboarding Errors/InPersonPaymentsCountryNotSupported.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct InPersonPaymentsCountryNotSupported: View {
2727

2828
private enum Localization {
2929
static let title = NSLocalizedString(
30-
"We don’t support In-Person Payments in %@",
30+
"We don’t support In-Person Payments in %1$@",
3131
comment: "Title for the error screen when WooCommerce Payments is not supported in a specific country"
3232
)
3333

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/Onboarding Errors/InPersonPaymentsOnboardingError.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SwiftUI
2+
import Yosemite
23

34
struct InPersonPaymentsOnboardingError: View {
45
let title: String
@@ -77,3 +78,14 @@ struct InPersonPaymentsOnboardingError: View {
7778
}
7879
}
7980
}
81+
82+
extension CardPresentPaymentsPlugins {
83+
public var image: UIImage {
84+
switch self {
85+
case .wcPay:
86+
return .wcPayPlugin
87+
case .stripe:
88+
return .stripePlugin
89+
}
90+
}
91+
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import SwiftUI
2+
import Yosemite
23

34
struct InPersonPaymentsPluginNotActivated: View {
5+
let plugin: CardPresentPaymentsPlugins
46
let onRefresh: () -> Void
57

68
var body: some View {
79
InPersonPaymentsOnboardingError(
8-
title: Localization.title,
9-
message: Localization.message,
10+
title: String(format: Localization.title, plugin.pluginName),
11+
message: String(format: Localization.message, plugin.pluginName),
1012
image: InPersonPaymentsOnboardingError.ImageInfo(
11-
image: .wcPayPlugin,
13+
image: plugin.image,
1214
height: 108.0
1315
),
1416
supportLink: false,
@@ -23,23 +25,23 @@ struct InPersonPaymentsPluginNotActivated: View {
2325

2426
private enum Localization {
2527
static let title = NSLocalizedString(
26-
"Activate WooCommerce Payments",
27-
comment: "Title for the error screen when WooCommerce Payments is installed but not activated"
28+
"Activate %1$@",
29+
comment: "Title for the error screen when a Card Present Payments extension is installed but not activated"
2830
)
2931

3032
static let message = NSLocalizedString(
31-
"The WooCommerce Payments extension is installed on your store but not activated. Please activate it to accept In-Person Payments",
32-
comment: "Error message when WooCommerce Payments is not activated"
33+
"The %1$@ extension is installed on your store but not activated. Please activate it to accept In-Person Payments",
34+
comment: "Error message when a Card Present Payments extension is not activated"
3335
)
3436

3537
static let primaryButton = NSLocalizedString(
3638
"Refresh After Activating",
37-
comment: "Button to reload plugin data after activating the WooCommerce Payments plugin"
39+
comment: "Button to reload plugin data after activating a Card Present Payments extension"
3840
)
3941
}
4042

4143
struct InPersonPaymentsPluginNotActivated_Previews: PreviewProvider {
4244
static var previews: some View {
43-
InPersonPaymentsPluginNotActivated(onRefresh: {})
45+
InPersonPaymentsPluginNotActivated(plugin: .wcPay, onRefresh: {})
4446
}
4547
}

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/Onboarding Errors/InPersonPaymentsPluginNotSupportedVersionView.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct InPersonPaymentsPluginNotSupportedVersion: View {
1010
title: String(format: Localization.title, plugin.pluginName),
1111
message: String(format: Localization.message, plugin.pluginName),
1212
image: InPersonPaymentsOnboardingError.ImageInfo(
13-
image: image,
13+
image: plugin.image,
1414
height: 108.0
1515
),
1616
supportLink: false,
@@ -21,25 +21,16 @@ struct InPersonPaymentsPluginNotSupportedVersion: View {
2121
)
2222
)
2323
}
24-
25-
var image: UIImage {
26-
switch plugin {
27-
case .wcPay:
28-
return .wcPayPlugin
29-
case .stripe:
30-
return .stripePlugin
31-
}
32-
}
3324
}
3425

3526
private enum Localization {
3627
static let title = NSLocalizedString(
37-
"Unsupported %@ version",
28+
"Unsupported %1$@ version",
3829
comment: "Title for the error screen when the installed version of a Card Present Payments extension is unsupported"
3930
)
4031

4132
static let message = NSLocalizedString(
42-
"The %@ extension is installed on your store, but needs to be updated for In-Person Payments. "
33+
"The %1$@ extension is installed on your store, but needs to be updated for In-Person Payments. "
4334
+ "Please update it to the most recent version.",
4435
comment: "Error message when a Card Present Payments extension is installed but the version is not supported"
4536
)

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,6 @@
948948
800A5BC7275889ED009DE2CD /* reports_revenue_stats_month.json in Resources */ = {isa = PBXBuildFile; fileRef = 800A5BC3275889EC009DE2CD /* reports_revenue_stats_month.json */; };
949949
800A5BC8275889ED009DE2CD /* reports_revenue_stats_year.json in Resources */ = {isa = PBXBuildFile; fileRef = 800A5BC4275889EC009DE2CD /* reports_revenue_stats_year.json */; };
950950
800A5BCB2759CE4B009DE2CD /* ProductsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800A5BCA2759CE4B009DE2CD /* ProductsTests.swift */; };
951-
80AD2CA22782B4EB00A63DE8 /* products_on_review.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA12782B4EB00A63DE8 /* products_on_review.json */; };
952-
80B8D34C278E8A0C00FE6E6B /* MenuScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B8D34B278E8A0C00FE6E6B /* MenuScreen.swift */; };
953951
80AD2CA22782B4EB00A63DE8 /* products_list_1.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA12782B4EB00A63DE8 /* products_list_1.json */; };
954952
80AD2CA427858BAB00A63DE8 /* StatsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80AD2CA327858BAB00A63DE8 /* StatsTests.swift */; };
955953
80AD2CA627859B4400A63DE8 /* reports_leaderboards_stats_day.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA527859B4400A63DE8 /* reports_leaderboards_stats_day.json */; };
@@ -958,6 +956,7 @@
958956
80B8D34327859C7F00FE6E6B /* reports_leaderboards_stats_year.json in Resources */ = {isa = PBXBuildFile; fileRef = 80B8D34227859C7F00FE6E6B /* reports_leaderboards_stats_year.json */; };
959957
80B8D3452785A08900FE6E6B /* products_list_2.json in Resources */ = {isa = PBXBuildFile; fileRef = 80B8D3442785A08900FE6E6B /* products_list_2.json */; };
960958
80B8D3492785A0A900FE6E6B /* products_list_3.json in Resources */ = {isa = PBXBuildFile; fileRef = 80B8D3482785A0A900FE6E6B /* products_list_3.json */; };
959+
80B8D34C278E8A0C00FE6E6B /* MenuScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80B8D34B278E8A0C00FE6E6B /* MenuScreen.swift */; };
961960
80C3626B27704EE1005CEAD3 /* ProductDataStructs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80C3626A27704EE1005CEAD3 /* ProductDataStructs.swift */; };
962961
80C3626F277453E8005CEAD3 /* ReviewsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80C3626E277453E7005CEAD3 /* ReviewsTests.swift */; };
963962
80C3627127745737005CEAD3 /* ReviewDataStructs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80C3627027745737005CEAD3 /* ReviewDataStructs.swift */; };
@@ -2519,8 +2518,6 @@
25192518
800A5BC3275889EC009DE2CD /* reports_revenue_stats_month.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_month.json; sourceTree = "<group>"; };
25202519
800A5BC4275889EC009DE2CD /* reports_revenue_stats_year.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_year.json; sourceTree = "<group>"; };
25212520
800A5BCA2759CE4B009DE2CD /* ProductsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsTests.swift; sourceTree = "<group>"; };
2522-
80AD2CA12782B4EB00A63DE8 /* products_on_review.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_on_review.json; sourceTree = "<group>"; };
2523-
80B8D34B278E8A0C00FE6E6B /* MenuScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuScreen.swift; sourceTree = "<group>"; };
25242521
80AD2CA12782B4EB00A63DE8 /* products_list_1.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_list_1.json; sourceTree = "<group>"; };
25252522
80AD2CA327858BAB00A63DE8 /* StatsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsTests.swift; sourceTree = "<group>"; };
25262523
80AD2CA527859B4400A63DE8 /* reports_leaderboards_stats_day.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = reports_leaderboards_stats_day.json; sourceTree = "<group>"; };
@@ -2529,6 +2526,7 @@
25292526
80B8D34227859C7F00FE6E6B /* reports_leaderboards_stats_year.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = reports_leaderboards_stats_year.json; sourceTree = "<group>"; };
25302527
80B8D3442785A08900FE6E6B /* products_list_2.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_list_2.json; sourceTree = "<group>"; };
25312528
80B8D3482785A0A900FE6E6B /* products_list_3.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_list_3.json; sourceTree = "<group>"; };
2529+
80B8D34B278E8A0C00FE6E6B /* MenuScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuScreen.swift; sourceTree = "<group>"; };
25322530
80C3626A27704EE1005CEAD3 /* ProductDataStructs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDataStructs.swift; sourceTree = "<group>"; };
25332531
80C3626E277453E7005CEAD3 /* ReviewsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReviewsTests.swift; sourceTree = "<group>"; };
25342532
80C3627027745737005CEAD3 /* ReviewDataStructs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewDataStructs.swift; sourceTree = "<group>"; };
@@ -8087,7 +8085,6 @@
80878085
3F0CF3132704490A00EF3D71 /* PrologueScreen.swift in Sources */,
80888086
3F0CF3102704490A00EF3D71 /* SingleOrderScreen.swift in Sources */,
80898087
3F0CF3062704490A00EF3D71 /* SingleReviewScreen.swift in Sources */,
8090-
80B8D350279123D500FE6E6B /* MenuScreen.swift in Sources */,
80918088
3F0CF3112704490A00EF3D71 /* ProductsScreen.swift in Sources */,
80928089
);
80938090
runOnlyForDeploymentPostprocessing = 0;

0 commit comments

Comments
 (0)