Skip to content

Commit d74d11c

Browse files
committed
Add feature flag & toggle for Tap to Pay on iPhone
1 parent 207ea58 commit d74d11c

File tree

8 files changed

+44
-0
lines changed

8 files changed

+44
-0
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
5353
return buildConfig == .localDeveloper || buildConfig == .alpha
5454
case .analyticsHub:
5555
return buildConfig == .localDeveloper || buildConfig == .alpha
56+
case .tapToPayOnIPhone:
57+
return buildConfig == .localDeveloper || buildConfig == .alpha
5658
default:
5759
return true
5860
}

Experiments/Experiments/FeatureFlag.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public enum FeatureFlag: Int {
7070
///
7171
case inAppPurchases
7272

73+
/// Enables Tap to Pay on iPhone flow in In-Person Payments, on eligible devices.
74+
///
75+
case tapToPayOnIPhone
76+
7377
/// Store creation MVP.
7478
///
7579
case storeCreationMVP

Storage/Storage/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extension Storage.GeneralAppSettings {
2727
isProductSKUInputScannerSwitchEnabled: CopiableProp<Bool> = .copy,
2828
isCouponManagementSwitchEnabled: CopiableProp<Bool> = .copy,
2929
isInAppPurchasesSwitchEnabled: CopiableProp<Bool> = .copy,
30+
isTapToPayOnIPhoneSwitchEnabled: CopiableProp<Bool> = .copy,
3031
knownCardReaders: CopiableProp<[String]> = .copy,
3132
lastEligibilityErrorInfo: NullableCopiableProp<EligibilityErrorInfo> = .copy,
3233
lastJetpackBenefitsBannerDismissedTime: NullableCopiableProp<Date> = .copy,
@@ -38,6 +39,7 @@ extension Storage.GeneralAppSettings {
3839
let isProductSKUInputScannerSwitchEnabled = isProductSKUInputScannerSwitchEnabled ?? self.isProductSKUInputScannerSwitchEnabled
3940
let isCouponManagementSwitchEnabled = isCouponManagementSwitchEnabled ?? self.isCouponManagementSwitchEnabled
4041
let isInAppPurchasesSwitchEnabled = isInAppPurchasesSwitchEnabled ?? self.isInAppPurchasesSwitchEnabled
42+
let isTapToPayOnIPhoneSwitchEnabled = isTapToPayOnIPhoneSwitchEnabled ?? self.isTapToPayOnIPhoneSwitchEnabled
4143
let knownCardReaders = knownCardReaders ?? self.knownCardReaders
4244
let lastEligibilityErrorInfo = lastEligibilityErrorInfo ?? self.lastEligibilityErrorInfo
4345
let lastJetpackBenefitsBannerDismissedTime = lastJetpackBenefitsBannerDismissedTime ?? self.lastJetpackBenefitsBannerDismissedTime
@@ -50,6 +52,7 @@ extension Storage.GeneralAppSettings {
5052
isProductSKUInputScannerSwitchEnabled: isProductSKUInputScannerSwitchEnabled,
5153
isCouponManagementSwitchEnabled: isCouponManagementSwitchEnabled,
5254
isInAppPurchasesSwitchEnabled: isInAppPurchasesSwitchEnabled,
55+
isTapToPayOnIPhoneSwitchEnabled: isTapToPayOnIPhoneSwitchEnabled,
5356
knownCardReaders: knownCardReaders,
5457
lastEligibilityErrorInfo: lastEligibilityErrorInfo,
5558
lastJetpackBenefitsBannerDismissedTime: lastJetpackBenefitsBannerDismissedTime,

Storage/Storage/Model/GeneralAppSettings.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public struct GeneralAppSettings: Codable, Equatable, GeneratedCopiable {
3636
///
3737
public var isInAppPurchasesSwitchEnabled: Bool
3838

39+
/// The state for the Tap to Pay on iPhone feature switch.
40+
///
41+
public var isTapToPayOnIPhoneSwitchEnabled: Bool
42+
3943
/// A list (possibly empty) of known card reader IDs - i.e. IDs of card readers that should be reconnected to automatically
4044
/// e.g. ["CHB204909005931"]
4145
///
@@ -58,6 +62,7 @@ public struct GeneralAppSettings: Codable, Equatable, GeneratedCopiable {
5862
isProductSKUInputScannerSwitchEnabled: Bool,
5963
isCouponManagementSwitchEnabled: Bool,
6064
isInAppPurchasesSwitchEnabled: Bool,
65+
isTapToPayOnIPhoneSwitchEnabled: Bool,
6166
knownCardReaders: [String],
6267
lastEligibilityErrorInfo: EligibilityErrorInfo? = nil,
6368
lastJetpackBenefitsBannerDismissedTime: Date? = nil,
@@ -72,6 +77,7 @@ public struct GeneralAppSettings: Codable, Equatable, GeneratedCopiable {
7277
self.lastJetpackBenefitsBannerDismissedTime = lastJetpackBenefitsBannerDismissedTime
7378
self.featureAnnouncementCampaignSettings = featureAnnouncementCampaignSettings
7479
self.isInAppPurchasesSwitchEnabled = isInAppPurchasesSwitchEnabled
80+
self.isTapToPayOnIPhoneSwitchEnabled = isTapToPayOnIPhoneSwitchEnabled
7581
}
7682

7783
public static var `default`: Self {
@@ -81,6 +87,7 @@ public struct GeneralAppSettings: Codable, Equatable, GeneratedCopiable {
8187
isProductSKUInputScannerSwitchEnabled: false,
8288
isCouponManagementSwitchEnabled: false,
8389
isInAppPurchasesSwitchEnabled: false,
90+
isTapToPayOnIPhoneSwitchEnabled: false,
8491
knownCardReaders: [],
8592
lastEligibilityErrorInfo: nil,
8693
featureAnnouncementCampaignSettings: [:])
@@ -110,6 +117,7 @@ public struct GeneralAppSettings: Codable, Equatable, GeneratedCopiable {
110117
isProductSKUInputScannerSwitchEnabled: isProductSKUInputScannerSwitchEnabled,
111118
isCouponManagementSwitchEnabled: isCouponManagementSwitchEnabled,
112119
isInAppPurchasesSwitchEnabled: isInAppPurchasesSwitchEnabled,
120+
isTapToPayOnIPhoneSwitchEnabled: isTapToPayOnIPhoneSwitchEnabled,
113121
knownCardReaders: knownCardReaders,
114122
lastEligibilityErrorInfo: lastEligibilityErrorInfo,
115123
featureAnnouncementCampaignSettings: featureAnnouncementCampaignSettings
@@ -130,6 +138,7 @@ public struct GeneralAppSettings: Codable, Equatable, GeneratedCopiable {
130138
isProductSKUInputScannerSwitchEnabled: isProductSKUInputScannerSwitchEnabled,
131139
isCouponManagementSwitchEnabled: isCouponManagementSwitchEnabled,
132140
isInAppPurchasesSwitchEnabled: isInAppPurchasesSwitchEnabled,
141+
isTapToPayOnIPhoneSwitchEnabled: isTapToPayOnIPhoneSwitchEnabled,
133142
knownCardReaders: knownCardReaders,
134143
lastEligibilityErrorInfo: lastEligibilityErrorInfo,
135144
featureAnnouncementCampaignSettings: updatedSettings
@@ -150,6 +159,7 @@ extension GeneralAppSettings {
150159
self.isProductSKUInputScannerSwitchEnabled = try container.decodeIfPresent(Bool.self, forKey: .isProductSKUInputScannerSwitchEnabled) ?? false
151160
self.isCouponManagementSwitchEnabled = try container.decodeIfPresent(Bool.self, forKey: .isCouponManagementSwitchEnabled) ?? false
152161
self.isInAppPurchasesSwitchEnabled = try container.decodeIfPresent(Bool.self, forKey: .isInAppPurchasesSwitchEnabled) ?? false
162+
self.isTapToPayOnIPhoneSwitchEnabled = try container.decodeIfPresent(Bool.self, forKey: .isTapToPayOnIPhoneSwitchEnabled) ?? false
153163
self.knownCardReaders = try container.decodeIfPresent([String].self, forKey: .knownCardReaders) ?? []
154164
self.lastEligibilityErrorInfo = try container.decodeIfPresent(EligibilityErrorInfo.self, forKey: .lastEligibilityErrorInfo)
155165
self.lastJetpackBenefitsBannerDismissedTime = try container.decodeIfPresent(Date.self, forKey: .lastJetpackBenefitsBannerDismissedTime)

Storage/StorageTests/Model/AppSettings/GeneralAppSettingsTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ final class GeneralAppSettingsTests: XCTestCase {
6767
isProductSKUInputScannerSwitchEnabled: true,
6868
isCouponManagementSwitchEnabled: true,
6969
isInAppPurchasesSwitchEnabled: false,
70+
isTapToPayOnIPhoneSwitchEnabled: false,
7071
knownCardReaders: readers,
7172
lastEligibilityErrorInfo: eligibilityInfo,
7273
lastJetpackBenefitsBannerDismissedTime: jetpackBannerDismissedDate,
@@ -103,6 +104,7 @@ private extension GeneralAppSettingsTests {
103104
isProductSKUInputScannerSwitchEnabled: Bool = false,
104105
isCouponManagementSwitchEnabled: Bool = false,
105106
isInAppPurchasesSwitchEnabled: Bool = false,
107+
isTapToPayOnIPhoneSwitchEnabled: Bool = false,
106108
knownCardReaders: [String] = [],
107109
lastEligibilityErrorInfo: EligibilityErrorInfo? = nil,
108110
lastJetpackBenefitsBannerDismissedTime: Date? = nil,
@@ -114,6 +116,7 @@ private extension GeneralAppSettingsTests {
114116
isProductSKUInputScannerSwitchEnabled: isProductSKUInputScannerSwitchEnabled,
115117
isCouponManagementSwitchEnabled: isCouponManagementSwitchEnabled,
116118
isInAppPurchasesSwitchEnabled: isInAppPurchasesSwitchEnabled,
119+
isTapToPayOnIPhoneSwitchEnabled: isTapToPayOnIPhoneSwitchEnabled,
117120
knownCardReaders: knownCardReaders,
118121
lastEligibilityErrorInfo: lastEligibilityErrorInfo,
119122
lastJetpackBenefitsBannerDismissedTime: lastJetpackBenefitsBannerDismissedTime,

WooCommerce/Classes/Model/BetaFeature.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ enum BetaFeature: String, CaseIterable {
55
case productSKUScanner
66
case couponManagement
77
case inAppPurchases
8+
case tapToPayOnIPhone
89
}
910

1011
extension BetaFeature {
@@ -18,6 +19,8 @@ extension BetaFeature {
1819
return Localization.couponManagementTitle
1920
case .inAppPurchases:
2021
return Localization.inAppPurchasesManagementTitle
22+
case .tapToPayOnIPhone:
23+
return Localization.tapToPayOnIPhoneTitle
2124
}
2225
}
2326

@@ -31,6 +34,8 @@ extension BetaFeature {
3134
return Localization.couponManagementDescription
3235
case .inAppPurchases:
3336
return Localization.inAppPurchasesManagementDescription
37+
case .tapToPayOnIPhone:
38+
return Localization.tapToPayOnIPhoneDescription
3439
}
3540
}
3641

@@ -44,6 +49,8 @@ extension BetaFeature {
4449
return \.isCouponManagementSwitchEnabled
4550
case .inAppPurchases:
4651
return \.isInAppPurchasesSwitchEnabled
52+
case .tapToPayOnIPhone:
53+
return \.isTapToPayOnIPhoneSwitchEnabled
4754
}
4855
}
4956

@@ -62,6 +69,8 @@ extension BetaFeature {
6269
switch self {
6370
case .inAppPurchases:
6471
return ServiceLocator.featureFlagService.isFeatureFlagEnabled(.inAppPurchases)
72+
case .tapToPayOnIPhone:
73+
return ServiceLocator.featureFlagService.isFeatureFlagEnabled(.tapToPayOnIPhone)
6574
default:
6675
return true
6776
}
@@ -139,5 +148,14 @@ private extension BetaFeature {
139148
static let inAppPurchasesManagementDescription = NSLocalizedString(
140149
"Test out in-app purchases as we get ready to launch",
141150
comment: "Cell description on beta features screen to enable in-app purchases")
151+
152+
static let tapToPayOnIPhoneTitle = NSLocalizedString(
153+
"Tap to Pay on iPhone",
154+
comment: "Cell tytle on beta features screen to enable Tap to Pay on iPhone: card payments with the " +
155+
"phone's built in reader")
156+
static let tapToPayOnIPhoneDescription = NSLocalizedString(
157+
"Test out In-Person Payments using your phone's built-in card reader, as we get ready to launch. " +
158+
"Supported on iPhone XS and newer phones, running iOS 15.5 or above.",
159+
comment: "Cell description on beta features screen to enable in-app purchases")
142160
}
143161
}

Yosemite/YosemiteTests/Stores/AppSettings/InAppFeedbackCardVisibilityUseCaseTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ final class InAppFeedbackCardVisibilityUseCaseTests: XCTestCase {
162162
isProductSKUInputScannerSwitchEnabled: false,
163163
isCouponManagementSwitchEnabled: false,
164164
isInAppPurchasesSwitchEnabled: false,
165+
isTapToPayOnIPhoneSwitchEnabled: false,
165166
knownCardReaders: [],
166167
featureAnnouncementCampaignSettings: [:])
167168
let useCase = InAppFeedbackCardVisibilityUseCase(settings: settings, feedbackType: .ordersCreation)
@@ -230,6 +231,7 @@ private extension InAppFeedbackCardVisibilityUseCaseTests {
230231
isProductSKUInputScannerSwitchEnabled: false,
231232
isCouponManagementSwitchEnabled: false,
232233
isInAppPurchasesSwitchEnabled: false,
234+
isTapToPayOnIPhoneSwitchEnabled: false,
233235
knownCardReaders: [],
234236
featureAnnouncementCampaignSettings: [:]
235237
)

Yosemite/YosemiteTests/Stores/AppSettingsStoreTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ private extension AppSettingsStoreTests {
10071007
isProductSKUInputScannerSwitchEnabled: false,
10081008
isCouponManagementSwitchEnabled: false,
10091009
isInAppPurchasesSwitchEnabled: false,
1010+
isTapToPayOnIPhoneSwitchEnabled: false,
10101011
knownCardReaders: [],
10111012
featureAnnouncementCampaignSettings: [:]
10121013
)
@@ -1021,6 +1022,7 @@ private extension AppSettingsStoreTests {
10211022
isProductSKUInputScannerSwitchEnabled: false,
10221023
isCouponManagementSwitchEnabled: false,
10231024
isInAppPurchasesSwitchEnabled: false,
1025+
isTapToPayOnIPhoneSwitchEnabled: false,
10241026
knownCardReaders: [],
10251027
featureAnnouncementCampaignSettings: featureAnnouncementCampaignSettings
10261028
)

0 commit comments

Comments
 (0)