Skip to content

Commit 2365bb9

Browse files
authored
Merge pull request #5930 from woocommerce/issue/5529-stripe-extension-too-old
[Mobile Payments] Prompt user to update the specific out of date plugin
2 parents db455cd + 8ec47c8 commit 2365bb9

File tree

15 files changed

+106
-45
lines changed

15 files changed

+106
-45
lines changed

WooCommerce/Classes/Extensions/UIImage+Woo.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,15 @@ extension UIImage {
585585
return UIImage(named: "woo-payments-loading")!
586586
}
587587

588-
/// Payments plugin
588+
/// WooCommerce Stripe Gateway plugin
589589
///
590-
static var paymentsPlugin: UIImage {
590+
static var stripePlugin: UIImage {
591+
return UIImage(named: "stripe-payments-plugin")!
592+
}
593+
594+
/// WooCommerce Payments plugin
595+
///
596+
static var wcPayPlugin: UIImage {
591597
return UIImage(named: "woo-payments-plugin")!
592598
}
593599

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

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
178178
return .pluginNotInstalled
179179
}
180180
guard isWCPayVersionSupported(plugin: plugin) else {
181-
return .pluginUnsupportedVersion
181+
return .pluginUnsupportedVersion(plugin: .wcPay)
182182
}
183183
guard plugin.active else {
184184
return .pluginNotActivated
@@ -190,7 +190,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
190190

191191
func stripeGatewayOnlyOnboardingState(plugin: SystemPlugin) -> CardPresentPaymentOnboardingState {
192192
guard isStripeVersionSupported(plugin: plugin) else {
193-
return .pluginUnsupportedVersion
193+
return .pluginUnsupportedVersion(plugin: .stripe)
194194
}
195195
return accountChecks()
196196
}
@@ -244,15 +244,15 @@ private extension CardPresentPaymentsOnboardingUseCase {
244244
}
245245

246246
func isCountrySupported(countryCode: String) -> Bool {
247-
return Constants.WCPay.supportedCountryCodes.contains(countryCode)
247+
return CardPresentPaymentsPlugins.wcPay.supportedCountryCodes.contains(countryCode)
248248
}
249249

250250
func getWCPayPlugin() -> SystemPlugin? {
251251
guard let siteID = siteID else {
252252
return nil
253253
}
254254
return storageManager.viewStorage
255-
.loadSystemPlugin(siteID: siteID, name: Constants.WCPay.pluginName)?
255+
.loadSystemPlugin(siteID: siteID, name: CardPresentPaymentsPlugins.wcPay.pluginName)?
256256
.toReadOnly()
257257
}
258258

@@ -261,7 +261,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
261261
return nil
262262
}
263263
return storageManager.viewStorage
264-
.loadSystemPlugin(siteID: siteID, name: Constants.Stripe.pluginName)?
264+
.loadSystemPlugin(siteID: siteID, name: CardPresentPaymentsPlugins.stripe.pluginName)?
265265
.toReadOnly()
266266
}
267267

@@ -282,11 +282,11 @@ private extension CardPresentPaymentsOnboardingUseCase {
282282
}
283283

284284
func isWCPayVersionSupported(plugin: SystemPlugin) -> Bool {
285-
VersionHelpers.isVersionSupported(version: plugin.version, minimumRequired: Constants.WCPay.minimumSupportedPluginVersion)
285+
VersionHelpers.isVersionSupported(version: plugin.version, minimumRequired: CardPresentPaymentsPlugins.wcPay.minimumSupportedPluginVersion)
286286
}
287287

288288
func isStripeVersionSupported(plugin: SystemPlugin) -> Bool {
289-
VersionHelpers.isVersionSupported(version: plugin.version, minimumRequired: Constants.Stripe.minimumSupportedPluginVersion)
289+
VersionHelpers.isVersionSupported(version: plugin.version, minimumRequired: CardPresentPaymentsPlugins.stripe.minimumSupportedPluginVersion)
290290
}
291291

292292
// Note: This counts on synchronizeStoreCountryAndPlugins having been called to get
@@ -348,17 +348,3 @@ private extension PaymentGatewayAccount {
348348
.init(rawValue: status)
349349
}
350350
}
351-
352-
private enum Constants {
353-
enum WCPay {
354-
static let pluginName = "WooCommerce Payments"
355-
static let minimumSupportedPluginVersion = "3.2.1"
356-
static let supportedCountryCodes = ["US"]
357-
}
358-
359-
enum Stripe {
360-
static let pluginName = "WooCommerce Stripe Gateway"
361-
static let minimumSupportedPluginVersion = "5.9.0"
362-
static let supportedCountryCodes = ["US"]
363-
}
364-
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ struct InPersonPaymentsView: View {
3333
InPersonPaymentsCountryNotSupported(countryCode: countryCode)
3434
case .pluginNotInstalled:
3535
InPersonPaymentsPluginNotInstalled(onRefresh: viewModel.refresh)
36-
case .pluginUnsupportedVersion:
37-
InPersonPaymentsPluginNotSupportedVersion(onRefresh: viewModel.refresh)
36+
case .pluginUnsupportedVersion(let plugin):
37+
InPersonPaymentsPluginNotSupportedVersion(plugin: plugin, onRefresh: viewModel.refresh)
3838
case .pluginNotActivated:
3939
InPersonPaymentsPluginNotActivated(onRefresh: viewModel.refresh)
4040
case .pluginInTestModeWithLiveStripeAccount:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct InPersonPaymentsLiveSiteInTestMode: View {
88
title: Localization.title,
99
message: Localization.message,
1010
image: InPersonPaymentsOnboardingError.ImageInfo(
11-
image: .paymentsPlugin,
11+
image: .wcPayPlugin,
1212
height: 108.0
1313
),
1414
supportLink: false,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct InPersonPaymentsPluginNotActivated: View {
88
title: Localization.title,
99
message: Localization.message,
1010
image: InPersonPaymentsOnboardingError.ImageInfo(
11-
image: .paymentsPlugin,
11+
image: .wcPayPlugin,
1212
height: 108.0
1313
),
1414
supportLink: false,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct InPersonPaymentsPluginNotInstalled: View {
88
title: Localization.title,
99
message: Localization.message,
1010
image: InPersonPaymentsOnboardingError.ImageInfo(
11-
image: .paymentsPlugin,
11+
image: .wcPayPlugin,
1212
height: 126.0
1313
),
1414
supportLink: false,
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import SwiftUI
2+
import Yosemite
23

34
struct InPersonPaymentsPluginNotSupportedVersion: 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: .paymentsPlugin,
13+
image: image,
1214
height: 108.0
1315
),
1416
supportLink: false,
@@ -19,28 +21,37 @@ struct InPersonPaymentsPluginNotSupportedVersion: View {
1921
)
2022
)
2123
}
24+
25+
var image: UIImage {
26+
switch plugin {
27+
case .wcPay:
28+
return .wcPayPlugin
29+
case .stripe:
30+
return .stripePlugin
31+
}
32+
}
2233
}
2334

2435
private enum Localization {
2536
static let title = NSLocalizedString(
26-
"Unsupported WooCommerce Payments version",
27-
comment: "Title for the error screen when the installed version of WooCommerce Payments is unsupported"
37+
"Unsupported %@ version",
38+
comment: "Title for the error screen when the installed version of a Card Present Payments extension is unsupported"
2839
)
2940

3041
static let message = NSLocalizedString(
31-
"The WooCommerce Payments extension is installed on your store, but needs to be updated for In-Person Payments. "
32-
+ "Please update WooCommerce Payments to the most recent version.",
33-
comment: "Error message when WooCommerce Payments is installed but the version is not supported"
42+
"The %@ extension is installed on your store, but needs to be updated for In-Person Payments. "
43+
+ "Please update it to the most recent version.",
44+
comment: "Error message when a Card Present Payments extension is installed but the version is not supported"
3445
)
3546

3647
static let primaryButton = NSLocalizedString(
3748
"Refresh After Updating",
38-
comment: "Button to reload plugin data after updating the WooCommerce Payments plugin"
49+
comment: "Button to reload plugin data after updating a Card Present Payments extension plugin"
3950
)
4051
}
4152

4253
struct InPersonPaymentsPluginNotSupportedVersion_Previews: PreviewProvider {
4354
static var previews: some View {
44-
InPersonPaymentsPluginNotSupportedVersion(onRefresh: {})
55+
InPersonPaymentsPluginNotSupportedVersion(plugin: .wcPay, onRefresh: {})
4556
}
4657
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct InPersonPaymentsSelectPlugin: View {
1212
title: Localization.title,
1313
message: Localization.message,
1414
image: InPersonPaymentsOnboardingError.ImageInfo(
15-
image: .paymentsPlugin,
15+
image: .wcPayPlugin,
1616
height: Constants.height
1717
),
1818
supportLink: false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct InPersonPaymentsWCPayNotSetup: View {
1212
title: Localization.title,
1313
message: Localization.message,
1414
image: InPersonPaymentsOnboardingError.ImageInfo(
15-
image: .paymentsPlugin,
15+
image: .wcPayPlugin,
1616
height: 108.0
1717
),
1818
supportLink: false
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "stripe-payments-plugin.pdf",
5+
"idiom" : "universal"
6+
},
7+
{
8+
"appearances" : [
9+
{
10+
"appearance" : "luminosity",
11+
"value" : "dark"
12+
}
13+
],
14+
"filename" : "stripe-payments-plugin-1.pdf",
15+
"idiom" : "universal"
16+
}
17+
],
18+
"info" : {
19+
"author" : "xcode",
20+
"version" : 1
21+
}
22+
}

0 commit comments

Comments
 (0)