Skip to content

Commit cbbecd9

Browse files
committed
Use correct CoD learnMore url for current plugin
1 parent b3ed08a commit cbbecd9

File tree

9 files changed

+70
-33
lines changed

9 files changed

+70
-33
lines changed

WooCommerce/Classes/System/WooConstants.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,14 @@ extension WooConstants {
180180
#else
181181
case couponManagementFeedback = "https://automattic.survey.fm/woo-app-coupon-management-production"
182182
#endif
183-
/// URL for the Enable Cash on Delivery (or Pay in Person) onboarding step's learn more link.
183+
/// URL for the Enable Cash on Delivery (or Pay in Person) onboarding step's learn more link using the Stripe plugin
184184
///
185-
case cashOnDeliveryLearnMoreUrl = "https://woocommerce.com/document/stripe/accept-in-person-payments-with-stripe/#section-8"
185+
case stripeCashOnDeliveryLearnMoreUrl = "https://woocommerce.com/document/stripe/accept-in-person-payments-with-stripe/#section-8"
186+
187+
/// URL for the Enable Cash on Delivery (or Pay in Person) onboarding step's learn more link using the WCPay plugin
188+
///
189+
case wcPayCashOnDeliveryLearnMoreUrl =
190+
"https://woocommerce.com/document/payments/getting-started-with-in-person-payments-with-woocommerce-payments/#add-cod-payment-method"
186191

187192
/// Returns the URL version of the receiver
188193
///

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ private extension CardPresentPaymentsOnboardingUseCase {
309309
}
310310
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.promptToEnableCodInIppOnboarding) {
311311
if shouldShowCashOnDeliveryStep {
312-
return .codPaymentGatewayNotSetUp
312+
return .codPaymentGatewayNotSetUp(plugin: plugin)
313313
}
314314
}
315315
guard !isInUndefinedState(account: account) else {

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

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

34
final class InPersonPaymentsViewController: UIHostingController<InPersonPaymentsView> {
45
private let onWillDisappear: (() -> ())?
@@ -71,8 +72,12 @@ struct InPersonPaymentsView: View {
7172
InPersonPaymentsStripeAccountReview(analyticReason: viewModel.state.reasonForAnalytics)
7273
case .stripeAccountRejected:
7374
InPersonPaymentsStripeRejected(analyticReason: viewModel.state.reasonForAnalytics)
74-
case .codPaymentGatewayNotSetUp:
75-
InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpView(viewModel: viewModel.codStepViewModel)
75+
case .codPaymentGatewayNotSetUp(let plugin):
76+
InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpView(
77+
viewModel: InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(
78+
plugin: plugin,
79+
analyticReason: viewModel.state.reasonForAnalytics,
80+
completion: viewModel.refresh))
7681
case .completed:
7782
InPersonPaymentsCompleted()
7883
case .noConnectionError:

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ final class InPersonPaymentsViewModel: ObservableObject {
99
private let useCase: CardPresentPaymentsOnboardingUseCase
1010
let stores: StoresManager
1111

12-
lazy var codStepViewModel: InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel = {
13-
InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(configuration: useCase.configurationLoader.configuration,
14-
completion: refresh)
15-
}()
16-
1712
/// Initializes the view model for a specific site
1813
///
1914
init(stores: StoresManager = ServiceLocator.stores,

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpView: View {
2828

2929
Spacer()
3030

31-
InPersonPaymentsLearnMore(url: WooConstants.URLs.cashOnDeliveryLearnMoreUrl.asURL(),
31+
InPersonPaymentsLearnMore(url: viewModel.learnMoreURL,
3232
formatText: Localization.cashOnDeliveryLearnMore,
3333
analyticReason: viewModel.analyticReason)
3434
}
@@ -37,8 +37,11 @@ struct InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpView: View {
3737

3838
struct InPersonPaymentsCodPaymentGatewayNotSetUp_Previews: PreviewProvider {
3939
static var previews: some View {
40-
let viewModel = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(configuration: CardPresentPaymentsConfiguration(country: "US"),
41-
completion: {})
40+
let viewModel = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(
41+
configuration: CardPresentPaymentsConfiguration(country: "US"),
42+
plugin: .wcPay,
43+
analyticReason: "",
44+
completion: {})
4245
return InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpView(viewModel: viewModel)
4346
}
4447
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel: Obser
3636

3737
@Published var awaitingResponse = false
3838

39-
let analyticReason: String = CardPresentPaymentOnboardingState.codPaymentGatewayNotSetUp.reasonForAnalytics
39+
let analyticReason: String
4040

4141
// MARK: - Configuration properties
4242
private let cardPresentPaymentsConfiguration: CardPresentPaymentsConfiguration
@@ -45,11 +45,17 @@ final class InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel: Obser
4545
stores.sessionManager.defaultStoreID
4646
}
4747

48+
let learnMoreURL: URL
49+
4850
init(dependencies: Dependencies = Dependencies(),
49-
configuration: CardPresentPaymentsConfiguration,
51+
configuration: CardPresentPaymentsConfiguration = CardPresentConfigurationLoader().configuration,
52+
plugin: CardPresentPaymentsPlugin,
53+
analyticReason: String,
5054
completion: @escaping () -> Void) {
5155
self.dependencies = dependencies
5256
self.cardPresentPaymentsConfiguration = configuration
57+
self.learnMoreURL = plugin.cashOnDeliveryLearnMoreURL
58+
self.analyticReason = analyticReason
5359
self.completion = completion
5460
}
5561

@@ -169,3 +175,14 @@ private enum Localization {
169175
private enum Constants {
170176
static let cashOnDeliveryGatewayID = "cod"
171177
}
178+
179+
private extension CardPresentPaymentsPlugin {
180+
var cashOnDeliveryLearnMoreURL: URL {
181+
switch self {
182+
case .wcPay:
183+
return WooConstants.URLs.wcPayCashOnDeliveryLearnMoreUrl.asURL()
184+
case .stripe:
185+
return WooConstants.URLs.stripeCashOnDeliveryLearnMoreUrl.asURL()
186+
}
187+
}
188+
}

WooCommerce/WooCommerceTests/ViewRelated/CardPresentPayments/CardPresentPaymentsOnboardingUseCaseTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ class CardPresentPaymentsOnboardingUseCaseTests: XCTestCase {
780780
let state = useCase.state
781781

782782
// Then
783-
assertEqual(.codPaymentGatewayNotSetUp, state)
783+
assertEqual(.codPaymentGatewayNotSetUp(plugin: .wcPay), state)
784784
}
785785

786786
func test_onboarding_returns_complete_when_cod_disabled_and_cod_step_was_skipped() {

WooCommerce/WooCommerceTests/ViewRelated/Dashboard/Settings/In-Person Payments/Onboarding Errors/InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModelTests.swift

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,25 @@ final class InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModelTests:
3131
noticePresenter: noticePresenter,
3232
analytics: analytics
3333
)
34-
sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(dependencies: dependencies,
35-
configuration: configuration,
36-
completion: {})
34+
sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(
35+
dependencies: dependencies,
36+
configuration: configuration,
37+
plugin: .wcPay,
38+
analyticReason: AnalyticProperties.cashOnDeliveryDisabledReason,
39+
completion: {})
3740
}
3841

3942
func test_skip_always_calls_completion() {
4043
// Given
4144
let completionCalled: Bool = waitFor { promise in
42-
let sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(dependencies: self.dependencies,
43-
configuration: self.configuration,
44-
completion: {
45-
promise(true)
46-
})
45+
let sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(
46+
dependencies: self.dependencies,
47+
configuration: self.configuration,
48+
plugin: .wcPay,
49+
analyticReason: AnalyticProperties.cashOnDeliveryDisabledReason,
50+
completion: {
51+
promise(true)
52+
})
4753

4854
// When
4955
sut.skipTapped()
@@ -85,11 +91,14 @@ final class InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModelTests:
8591
}
8692

8793
let completionCalled: Bool = waitFor { promise in
88-
let sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(dependencies: self.dependencies,
89-
configuration: self.configuration,
90-
completion: {
91-
promise(true)
92-
})
94+
let sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(
95+
dependencies: self.dependencies,
96+
configuration: self.configuration,
97+
plugin: .wcPay,
98+
analyticReason: AnalyticProperties.cashOnDeliveryDisabledReason,
99+
completion: {
100+
promise(true)
101+
})
93102
// When
94103
sut.enableTapped()
95104
}
@@ -163,9 +172,12 @@ final class InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModelTests:
163172
}
164173

165174
let _: Void = waitFor { promise in
166-
let sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(dependencies: self.dependencies,
167-
configuration: self.configuration,
168-
completion: {
175+
let sut = InPersonPaymentsCashOnDeliveryPaymentGatewayNotSetUpViewModel(
176+
dependencies: self.dependencies,
177+
configuration: self.configuration,
178+
plugin: .wcPay,
179+
analyticReason: AnalyticProperties.cashOnDeliveryDisabledReason,
180+
completion: {
169181
promise(())
170182
})
171183
// When

Yosemite/Yosemite/Model/Enums/CardPresentPaymentsOnboardingState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public enum CardPresentPaymentOnboardingState: Equatable {
6464
/// The Cash on Delivery payment gateway is missing or disabled
6565
/// Enabling Cash on Delivery is not essential for Card Present Payments, but allows web store customers to place orders and pay by card in person.
6666
///
67-
case codPaymentGatewayNotSetUp
67+
case codPaymentGatewayNotSetUp(plugin: CardPresentPaymentsPlugin)
6868

6969
/// Generic error - for example, one of the requests failed.
7070
///

0 commit comments

Comments
 (0)