Skip to content

Commit 4d97b8b

Browse files
committed
Use CIAB eligibility checker in OrderCardPresentPaymentEligibilityStore
1 parent 6d4a5d2 commit 4d97b8b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Modules/Sources/Yosemite/Stores/OrderCardPresentPaymentEligibilityStore.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,27 @@ private extension OrderCardPresentPaymentEligibilityStore {
5353
cardPresentPaymentsConfiguration: CardPresentPaymentsConfiguration,
5454
onCompletion: (Result<Bool, Error>) -> Void) {
5555
let storage = storageManager.viewStorage
56+
57+
guard let site = storage.loadSite(siteID: siteID)?.toReadOnly() else {
58+
return onCompletion(
59+
.failure(
60+
OrderIsEligibleForCardPresentPaymentError.siteNotFoundInStorage
61+
)
62+
)
63+
}
64+
65+
guard siteCIABEligibilityChecker.isFeatureSupported(.cardReader, for: site) else {
66+
return onCompletion(
67+
.failure(
68+
OrderIsEligibleForCardPresentPaymentError.cardReaderPaymentOptionIsNotSupportedForCIABSites
69+
)
70+
)
71+
}
72+
5673
guard let order = storage.loadOrder(siteID: siteID, orderID: orderID)?.toReadOnly() else {
5774
return onCompletion(.failure(OrderIsEligibleForCardPresentPaymentError.orderNotFoundInStorage))
5875
}
5976

60-
6177
let orderProductsIDs = order.items.map(\.productID)
6278
let products = storage.loadProducts(siteID: siteID, productsIDs: orderProductsIDs).map { $0.toReadOnly() }
6379

@@ -68,5 +84,7 @@ private extension OrderCardPresentPaymentEligibilityStore {
6884
extension OrderCardPresentPaymentEligibilityStore {
6985
enum OrderIsEligibleForCardPresentPaymentError: Error {
7086
case orderNotFoundInStorage
87+
case siteNotFoundInStorage
88+
case cardReaderPaymentOptionIsNotSupportedForCIABSites
7189
}
7290
}

Modules/Sources/Yosemite/Tools/CIAB/CIABAffectedFeature.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public enum CIABAffectedFeature: CaseIterable {
1010
case giftCardEditing
1111
case productsStockDashboardCard
1212
case pointOfSale
13+
case cardReader
1314
}
1415

1516
extension CIABAffectedFeature {

0 commit comments

Comments
 (0)