Skip to content

Commit 4d4b764

Browse files
authored
Merge pull request #7598 from woocommerce/issue/7596-cod-learn-more-link-correction-for-wcpay
[Mobile Payments] Cash on Delivery Learn More link correction for WCPay
2 parents 5d0cef8 + 2ac242b commit 4d4b764

25 files changed

+121
-75
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
10.2
44
-----
55
- [*] Help center: Added help center web page with FAQs for "Enter Store Credentials" and "Enter WordPress.com email "screens. [https://github.com/woocommerce/woocommerce-ios/pull/7588, https://github.com/woocommerce/woocommerce-ios/pull/7590]
6-
6+
- [*] In-Person Payments: Fixed the Learn More link from the `Enable Pay in Person` onboarding screen for WCPay [https://github.com/woocommerce/woocommerce-ios/pull/7598]
77

88
10.1
99
-----

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: 5 additions & 10 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,
@@ -106,23 +101,23 @@ private extension InPersonPaymentsViewModel {
106101
}
107102

108103
func trackState(_ state: CardPresentPaymentOnboardingState) {
109-
guard let reason = state.reasonForAnalytics else {
104+
guard state.shouldTrackOnboardingStepEvents else {
110105
return
111106
}
112107
ServiceLocator.analytics
113108
.track(event: .InPersonPayments
114-
.cardPresentOnboardingNotCompleted(reason: reason,
115-
countryCode: countryCode))
109+
.cardPresentOnboardingNotCompleted(reason: state.reasonForAnalytics,
110+
countryCode: countryCode))
116111
}
117112

118113
func trackSkipped(state: CardPresentPaymentOnboardingState, remindLater: Bool) {
119-
guard let reason = state.reasonForAnalytics else {
114+
guard state.shouldTrackOnboardingStepEvents else {
120115
return
121116
}
122117

123118
ServiceLocator.analytics.track(
124119
event: .InPersonPayments.cardPresentOnboardingStepSkipped(
125-
reason: reason,
120+
reason: state.reasonForAnalytics,
126121
remindLater: remindLater,
127122
countryCode: countryCode))
128123
}

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/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/Onboarding Errors/InPersonPaymentsCountryNotSupported.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SwiftUI
22

33
struct InPersonPaymentsCountryNotSupported: View {
44
let countryCode: String
5-
let analyticReason: String?
5+
let analyticReason: String
66

77
var body: some View {
88
InPersonPaymentsOnboardingError(
@@ -47,8 +47,8 @@ private enum Localization {
4747
struct InPersonPaymentsCountryNotSupported_Previews: PreviewProvider {
4848
static var previews: some View {
4949
// Valid country code
50-
InPersonPaymentsCountryNotSupported(countryCode: "ES", analyticReason: nil)
50+
InPersonPaymentsCountryNotSupported(countryCode: "ES", analyticReason: "")
5151
// Invalid country code
52-
InPersonPaymentsCountryNotSupported(countryCode: "OO", analyticReason: nil)
52+
InPersonPaymentsCountryNotSupported(countryCode: "OO", analyticReason: "")
5353
}
5454
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SwiftUI
22

33
struct InPersonPaymentsCountryNotSupportedStripe: View {
44
let countryCode: String
5-
let analyticReason: String?
5+
let analyticReason: String
66

77
var body: some View {
88
InPersonPaymentsOnboardingError(
@@ -47,8 +47,8 @@ private enum Localization {
4747
struct InPersonPaymentsCountryNotSupportedStripe_Previews: PreviewProvider {
4848
static var previews: some View {
4949
// Valid country code
50-
InPersonPaymentsCountryNotSupportedStripe(countryCode: "ES", analyticReason: nil)
50+
InPersonPaymentsCountryNotSupportedStripe(countryCode: "ES", analyticReason: "")
5151
// Invalid country code
52-
InPersonPaymentsCountryNotSupportedStripe(countryCode: "OO", analyticReason: nil)
52+
InPersonPaymentsCountryNotSupportedStripe(countryCode: "OO", analyticReason: "")
5353
}
5454
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Yosemite
33

44
struct InPersonPaymentsLiveSiteInTestMode: View {
55
let plugin: CardPresentPaymentsPlugin
6-
let analyticReason: String?
6+
let analyticReason: String
77
let onRefresh: () -> Void
88

99
var body: some View {
@@ -46,6 +46,6 @@ private enum Localization {
4646

4747
struct InPersonPaymentsLiveSiteInTestMode_Previews: PreviewProvider {
4848
static var previews: some View {
49-
InPersonPaymentsLiveSiteInTestMode(plugin: .wcPay, analyticReason: nil, onRefresh: {})
49+
InPersonPaymentsLiveSiteInTestMode(plugin: .wcPay, analyticReason: "", onRefresh: {})
5050
}
5151
}

0 commit comments

Comments
 (0)