Skip to content

Commit 2771ec7

Browse files
authored
Merge pull request #5941 from woocommerce/issue/5933-live-stripe-in-test
[Mobile Payments] [Stripe Backend] Prompt merchant to take live account sites out of test mode for IPP
2 parents 645dbbf + 7e31df5 commit 2771ec7

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
185185
}
186186

187187
// Account checks
188-
return accountChecks()
188+
return accountChecks(plugin: .wcPay)
189189
}
190190

191191
func stripeGatewayOnlyOnboardingState(plugin: SystemPlugin) -> CardPresentPaymentOnboardingState {
@@ -196,18 +196,18 @@ private extension CardPresentPaymentsOnboardingUseCase {
196196
return .pluginNotActivated(plugin: .stripe)
197197
}
198198

199-
return accountChecks()
199+
return accountChecks(plugin: .stripe)
200200
}
201201

202-
func accountChecks() -> CardPresentPaymentOnboardingState {
202+
func accountChecks(plugin: CardPresentPaymentsPlugins) -> CardPresentPaymentOnboardingState {
203203
guard let account = getPaymentGatewayAccount() else {
204204
return .genericError
205205
}
206206
guard isPaymentGatewaySetupCompleted(account: account) else {
207207
return .pluginSetupNotCompleted
208208
}
209209
guard !isPluginInTestModeWithLiveStripeAccount(account: account) else {
210-
return .pluginInTestModeWithLiveStripeAccount
210+
return .pluginInTestModeWithLiveStripeAccount(plugin: plugin)
211211
}
212212
guard !isStripeAccountUnderReview(account: account) else {
213213
return .stripeAccountUnderReview

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ struct InPersonPaymentsView: View {
3737
InPersonPaymentsPluginNotSupportedVersion(plugin: plugin, onRefresh: viewModel.refresh)
3838
case .pluginNotActivated(let plugin):
3939
InPersonPaymentsPluginNotActivated(plugin: plugin, onRefresh: viewModel.refresh)
40-
case .pluginInTestModeWithLiveStripeAccount:
41-
InPersonPaymentsLiveSiteInTestMode(onRefresh:
40+
case .pluginInTestModeWithLiveStripeAccount(let plugin):
41+
InPersonPaymentsLiveSiteInTestMode(plugin: plugin, onRefresh:
4242
viewModel.refresh)
4343
case .pluginSetupNotCompleted:
4444
InPersonPaymentsWCPayNotSetup(onRefresh: viewModel.refresh)
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import SwiftUI
2+
import Yosemite
23

34
struct InPersonPaymentsLiveSiteInTestMode: 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,24 +25,24 @@ struct InPersonPaymentsLiveSiteInTestMode: View {
2325

2426
private enum Localization {
2527
static let title = NSLocalizedString(
26-
"WooCommerce Payments is in Test Mode",
27-
comment: "Title for the error screen when WooCommerce Payments is in test mode on a live site"
28+
"%1$@ is in Test Mode",
29+
comment: "Title for the error screen when a card present payments plugin is in test mode on a live site. %1$@ is a placeholder for the plugin name."
2830
)
2931

3032
static let message = NSLocalizedString(
31-
"The WooCommerce Payments extension cannot be in test mode for In-Person Payments. "
33+
"The %1$@ extension cannot be in test mode for In-Person Payments. "
3234
+ "Please disable test mode.",
33-
comment: "Error message when WooCommerce Payments is in test mode on a live site"
35+
comment: "Error message when a card present payments plugin is in test mode on a live site. %1$@ is a placeholder for the plugin name."
3436
)
3537

3638
static let primaryButton = NSLocalizedString(
3739
"Refresh After Updating",
38-
comment: "Button to reload plugin data after updating the WooCommerce Payments plugin settings"
40+
comment: "Button to reload plugin data after updating a card present payments plugin settings"
3941
)
4042
}
4143

4244
struct InPersonPaymentsLiveSiteInTestMode_Previews: PreviewProvider {
4345
static var previews: some View {
44-
InPersonPaymentsLiveSiteInTestMode(onRefresh: {})
46+
InPersonPaymentsLiveSiteInTestMode(plugin: .wcPay, onRefresh: {})
4547
}
4648
}

WooCommerce/WooCommerceTests/ViewRelated/CardPresentPayments/CardPresentPaymentsOnboardingUseCaseTests.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,21 @@ class CardPresentPaymentsOnboardingUseCaseTests: XCTestCase {
141141
let state = useCase.state
142142

143143
// Then
144-
XCTAssertEqual(state, .pluginInTestModeWithLiveStripeAccount)
144+
XCTAssertEqual(state, .pluginInTestModeWithLiveStripeAccount(plugin: .wcPay))
145+
}
146+
147+
func test_onboarding_returns_stripe_in_test_mode_with_live_stripe_account_when_live_account_in_test_mode() {
148+
// Given
149+
setupCountry(country: .us)
150+
setupStripePlugin(status: .active, version: StripePluginVersion.minimumSupportedVersion)
151+
setupPaymentGatewayAccount(status: .complete, isLive: true, isInTestMode: true)
152+
153+
// When
154+
let useCase = CardPresentPaymentsOnboardingUseCase(storageManager: storageManager, stores: stores)
155+
let state = useCase.state
156+
157+
// Then
158+
XCTAssertEqual(state, .pluginInTestModeWithLiveStripeAccount(plugin: .stripe))
145159
}
146160

147161
func test_onboarding_returns_wcpay_unsupported_version_when_patched_wcpay_plugin_outdated() {

Yosemite/Yosemite/Model/Enums/CardPresentPaymentsOnboardingState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public enum CardPresentPaymentOnboardingState: Equatable {
3232
///
3333
case pluginSetupNotCompleted
3434

35-
/// This is a bit special case: WCPay is set to "dev mode" but the connected Stripe account is in live mode.
35+
/// This is a bit special case: The plugin is set to test mode but the connected Stripe account is a real (live) account.
3636
/// Connecting to a reader or accepting payments is not supported in this state.
3737
///
38-
case pluginInTestModeWithLiveStripeAccount
38+
case pluginInTestModeWithLiveStripeAccount(plugin: CardPresentPaymentsPlugins)
3939

4040
/// The connected Stripe account has not been reviewed by Stripe yet. This is a temporary state and the user needs to wait.
4141
///

0 commit comments

Comments
 (0)