diff --git a/Modules/Sources/Yosemite/Model/Extensions/CountryCode+readableCountry.swift b/Modules/Sources/Yosemite/Model/Extensions/CountryCode+readableCountry.swift new file mode 100644 index 00000000000..58fc8152a02 --- /dev/null +++ b/Modules/Sources/Yosemite/Model/Extensions/CountryCode+readableCountry.swift @@ -0,0 +1,315 @@ +import Foundation +import WooFoundation + +// MARK: - Mapping between country codes and readable names +// The country names were extracted from the response to `/wp-json/wc/v3/settings/general` +// The default countries are listed under `woocommerce_default_country` +// in one of the following formats: +// - `"COUNTRY_CODE": "READABALE_COUNTRY_NAME" +// - `"COUNTRY_CODE:COUNTRY_REGION": "READABLE_COUNTRY_NAME - READABLE_COUNTRY_REGION" +public extension CountryCode { + var readableCountry: String { + switch self { + // A + case .AX: return NSLocalizedString("Åland Islands", comment: "Country option for a site address.") + case .AF: return NSLocalizedString("Afghanistan", comment: "Country option for a site address.") + case .AL: return NSLocalizedString("Albania", comment: "Country option for a site address.") + case .DZ: return NSLocalizedString("Algeria", comment: "Country option for a site address.") + case .AS: return NSLocalizedString("American Samoa", comment: "Country option for a site address.") + case .AD: return NSLocalizedString("Andorra", comment: "Country option for a site address.") + case .AO: return NSLocalizedString("Angola", comment: "Country option for a site address.") + case .AI: return NSLocalizedString("Anguilla", comment: "Country option for a site address.") + case .AQ: return NSLocalizedString("Antarctica", comment: "Country option for a site address.") + case .AG: return NSLocalizedString("Antigua and Barbuda", comment: "Country option for a site address.") + case .AR: return NSLocalizedString("Argentina", comment: "Country option for a site address.") + case .AM: return NSLocalizedString("Armenia", comment: "Country option for a site address.") + case .AW: return NSLocalizedString("Aruba", comment: "Country option for a site address.") + case .AU: return NSLocalizedString("Australia", comment: "Country option for a site address.") + case .AT: return NSLocalizedString("Austria", comment: "Country option for a site address.") + case .AZ: return NSLocalizedString("Azerbaijan", comment: "Country option for a site address.") + + // B + case .BS: return NSLocalizedString("Bahamas", comment: "Country option for a site address.") + case .BH: return NSLocalizedString("Bahrain", comment: "Country option for a site address.") + case .BD: return NSLocalizedString("Bangladesh", comment: "Country option for a site address.") + case .BB: return NSLocalizedString("Barbados", comment: "Country option for a site address.") + case .BY: return NSLocalizedString("Belarus", comment: "Country option for a site address.") + case .PW: return NSLocalizedString("Belau", comment: "Country option for a site address.") + case .BE: return NSLocalizedString("Belgium", comment: "Country option for a site address.") + case .BZ: return NSLocalizedString("Belize", comment: "Country option for a site address.") + case .BJ: return NSLocalizedString("Benin", comment: "Country option for a site address.") + case .BM: return NSLocalizedString("Bermuda", comment: "Country option for a site address.") + case .BT: return NSLocalizedString("Bhutan", comment: "Country option for a site address.") + case .BO: return NSLocalizedString("Bolivia", comment: "Country option for a site address.") + case .BQ: return NSLocalizedString("Bonaire, Saint Eustatius and Saba", comment: "Country option for a site address.") + case .BA: return NSLocalizedString("Bosnia and Herzegovina", comment: "Country option for a site address.") + case .BW: return NSLocalizedString("Botswana", comment: "Country option for a site address.") + case .BV: return NSLocalizedString("Bouvet Island", comment: "Country option for a site address.") + case .BR: return NSLocalizedString("Brazil", comment: "Country option for a site address.") + case .IO: return NSLocalizedString("British Indian Ocean Territory", comment: "Country option for a site address.") + case .VG: return NSLocalizedString("British Virgin Islands", comment: "Country option for a site address.") + case .BN: return NSLocalizedString("Brunei", comment: "Country option for a site address.") + case .BG: return NSLocalizedString("Bulgaria", comment: "Country option for a site address.") + case .BF: return NSLocalizedString("Burkina Faso", comment: "Country option for a site address.") + case .BI: return NSLocalizedString("Burundi", comment: "Country option for a site address.") + + // C + case .KH: return NSLocalizedString("Cambodia", comment: "Country option for a site address.") + case .CM: return NSLocalizedString("Cameroon", comment: "Country option for a site address.") + case .CA: return NSLocalizedString("Canada", comment: "Country option for a site address.") + case .CV: return NSLocalizedString("Cape Verde", comment: "Country option for a site address.") + case .KY: return NSLocalizedString("Cayman Islands", comment: "Country option for a site address.") + case .CF: return NSLocalizedString("Central African Republic", comment: "Country option for a site address.") + case .TD: return NSLocalizedString("Chad", comment: "Country option for a site address.") + case .CL: return NSLocalizedString("Chile", comment: "Country option for a site address.") + case .CN: return NSLocalizedString("China", comment: "Country option for a site address.") + case .CX: return NSLocalizedString("Christmas Island", comment: "Country option for a site address.") + case .CC: return NSLocalizedString("Cocos (Keeling) Islands", comment: "Country option for a site address.") + case .CO: return NSLocalizedString("Colombia", comment: "Country option for a site address.") + case .KM: return NSLocalizedString("Comoros", comment: "Country option for a site address.") + case .CG: return NSLocalizedString("Congo (Brazzaville)", comment: "Country option for a site address.") + case .CD: return NSLocalizedString("Congo (Kinshasa)", comment: "Country option for a site address.") + case .CK: return NSLocalizedString("Cook Islands", comment: "Country option for a site address.") + case .CR: return NSLocalizedString("Costa Rica", comment: "Country option for a site address.") + case .HR: return NSLocalizedString("Croatia", comment: "Country option for a site address.") + case .CU: return NSLocalizedString("Cuba", comment: "Country option for a site address.") + case .CW: return NSLocalizedString("Curacao", comment: "Country option for a site address.") + case .CY: return NSLocalizedString("Cyprus", comment: "Country option for a site address.") + case .CZ: return NSLocalizedString("Czech Republic", comment: "Country option for a site address.") + + // D + case .DK: return NSLocalizedString("Denmark", comment: "Country option for a site address.") + case .DJ: return NSLocalizedString("Djibouti", comment: "Country option for a site address.") + case .DM: return NSLocalizedString("Dominica", comment: "Country option for a site address.") + case .DO: return NSLocalizedString("Dominican Republic", comment: "Country option for a site address.") + + // E + case .EC: return NSLocalizedString("Ecuador", comment: "Country option for a site address.") + case .EG: return NSLocalizedString("Egypt", comment: "Country option for a site address.") + case .SV: return NSLocalizedString("El Salvador", comment: "Country option for a site address.") + case .GQ: return NSLocalizedString("Equatorial Guinea", comment: "Country option for a site address.") + case .ER: return NSLocalizedString("Eritrea", comment: "Country option for a site address.") + case .EE: return NSLocalizedString("Estonia", comment: "Country option for a site address.") + case .ET: return NSLocalizedString("Ethiopia", comment: "Country option for a site address.") + + // F + case .FK: return NSLocalizedString("Falkland Islands", comment: "Country option for a site address.") + case .FO: return NSLocalizedString("Faroe Islands", comment: "Country option for a site address.") + case .FJ: return NSLocalizedString("Fiji", comment: "Country option for a site address.") + case .FI: return NSLocalizedString("Finland", comment: "Country option for a site address.") + case .FR: return NSLocalizedString("France", comment: "Country option for a site address.") + case .GF: return NSLocalizedString("French Guiana", comment: "Country option for a site address.") + case .PF: return NSLocalizedString("French Polynesia", comment: "Country option for a site address.") + case .TF: return NSLocalizedString("French Southern Territories", comment: "Country option for a site address.") + + // G + case .GA: return NSLocalizedString("Gabon", comment: "Country option for a site address.") + case .GM: return NSLocalizedString("Gambia", comment: "Country option for a site address.") + case .GE: return NSLocalizedString("Georgia", comment: "Country option for a site address.") + case .DE: return NSLocalizedString("Germany", comment: "Country option for a site address.") + case .GH: return NSLocalizedString("Ghana", comment: "Country option for a site address.") + case .GI: return NSLocalizedString("Gibraltar", comment: "Country option for a site address.") + case .GR: return NSLocalizedString("Greece", comment: "Country option for a site address.") + case .GL: return NSLocalizedString("Greenland", comment: "Country option for a site address.") + case .GD: return NSLocalizedString("Grenada", comment: "Country option for a site address.") + case .GP: return NSLocalizedString("Guadeloupe", comment: "Country option for a site address.") + case .GU: return NSLocalizedString("Guam", comment: "Country option for a site address.") + case .GT: return NSLocalizedString("Guatemala", comment: "Country option for a site address.") + case .GG: return NSLocalizedString("Guernsey", comment: "Country option for a site address.") + case .GN: return NSLocalizedString("Guinea", comment: "Country option for a site address.") + case .GW: return NSLocalizedString("Guinea-Bissau", comment: "Country option for a site address.") + case .GY: return NSLocalizedString("Guyana", comment: "Country option for a site address.") + + // H + case .HT: return NSLocalizedString("Haiti", comment: "Country option for a site address.") + case .HM: return NSLocalizedString("Heard Island and McDonald Islands", comment: "Country option for a site address.") + case .HN: return NSLocalizedString("Honduras", comment: "Country option for a site address.") + case .HK: return NSLocalizedString("Hong Kong", comment: "Country option for a site address.") + case .HU: return NSLocalizedString("Hungary", comment: "Country option for a site address.") + + // I + case .IS: return NSLocalizedString("Iceland", comment: "Country option for a site address.") + case .IN: return NSLocalizedString("India", comment: "Country option for a site address.") + case .ID: return NSLocalizedString("Indonesia", comment: "Country option for a site address.") + case .IR: return NSLocalizedString("Iran", comment: "Country option for a site address.") + case .IQ: return NSLocalizedString("Iraq", comment: "Country option for a site address.") + case .IE: return NSLocalizedString("Ireland", comment: "Country option for a site address.") + case .IM: return NSLocalizedString("Isle of Man", comment: "Country option for a site address.") + case .IL: return NSLocalizedString("Israel", comment: "Country option for a site address.") + case .IT: return NSLocalizedString("Italy", comment: "Country option for a site address.") + case .CI: return NSLocalizedString("Ivory Coast", comment: "Country option for a site address.") + + // J + case .JM: return NSLocalizedString("Jamaica", comment: "Country option for a site address.") + case .JP: return NSLocalizedString("Japan", comment: "Country option for a site address.") + case .JE: return NSLocalizedString("Jersey", comment: "Country option for a site address.") + case .JO: return NSLocalizedString("Jordan", comment: "Country option for a site address.") + + // K + case .KZ: return NSLocalizedString("Kazakhstan", comment: "Country option for a site address.") + case .KE: return NSLocalizedString("Kenya", comment: "Country option for a site address.") + case .KI: return NSLocalizedString("Kiribati", comment: "Country option for a site address.") + case .KW: return NSLocalizedString("Kuwait", comment: "Country option for a site address.") + case .KG: return NSLocalizedString("Kyrgyzstan", comment: "Country option for a site address.") + + // L + case .LA: return NSLocalizedString("Laos", comment: "Country option for a site address.") + case .LV: return NSLocalizedString("Latvia", comment: "Country option for a site address.") + case .LB: return NSLocalizedString("Lebanon", comment: "Country option for a site address.") + case .LS: return NSLocalizedString("Lesotho", comment: "Country option for a site address.") + case .LR: return NSLocalizedString("Liberia", comment: "Country option for a site address.") + case .LY: return NSLocalizedString("Libya", comment: "Country option for a site address.") + case .LI: return NSLocalizedString("Liechtenstein", comment: "Country option for a site address.") + case .LT: return NSLocalizedString("Lithuania", comment: "Country option for a site address.") + case .LU: return NSLocalizedString("Luxembourg", comment: "Country option for a site address.") + + // M + case .MO: return NSLocalizedString("Macao S.A.R., China", comment: "Country option for a site address.") + case .MK: return NSLocalizedString("Macedonia", comment: "Country option for a site address.") + case .MG: return NSLocalizedString("Madagascar", comment: "Country option for a site address.") + case .MW: return NSLocalizedString("Malawi", comment: "Country option for a site address.") + case .MY: return NSLocalizedString("Malaysia", comment: "Country option for a site address.") + case .MV: return NSLocalizedString("Maldives", comment: "Country option for a site address.") + case .ML: return NSLocalizedString("Mali", comment: "Country option for a site address.") + case .MT: return NSLocalizedString("Malta", comment: "Country option for a site address.") + case .MH: return NSLocalizedString("Marshall Islands", comment: "Country option for a site address.") + case .MQ: return NSLocalizedString("Martinique", comment: "Country option for a site address.") + case .MR: return NSLocalizedString("Mauritania", comment: "Country option for a site address.") + case .MU: return NSLocalizedString("Mauritius", comment: "Country option for a site address.") + case .YT: return NSLocalizedString("Mayotte", comment: "Country option for a site address.") + case .MX: return NSLocalizedString("Mexico", comment: "Country option for a site address.") + case .FM: return NSLocalizedString("Micronesia", comment: "Country option for a site address.") + case .MD: return NSLocalizedString("Moldova", comment: "Country option for a site address.") + case .MC: return NSLocalizedString("Monaco", comment: "Country option for a site address.") + case .MN: return NSLocalizedString("Mongolia", comment: "Country option for a site address.") + case .ME: return NSLocalizedString("Montenegro", comment: "Country option for a site address.") + case .MS: return NSLocalizedString("Montserrat", comment: "Country option for a site address.") + case .MA: return NSLocalizedString("Morocco", comment: "Country option for a site address.") + case .MZ: return NSLocalizedString("Mozambique", comment: "Country option for a site address.") + case .MM: return NSLocalizedString("Myanmar", comment: "Country option for a site address.") + + // N + case .NA: return NSLocalizedString("Namibia", comment: "Country option for a site address.") + case .NR: return NSLocalizedString("Nauru", comment: "Country option for a site address.") + case .NP: return NSLocalizedString("Nepal", comment: "Country option for a site address.") + case .NL: return NSLocalizedString("Netherlands", comment: "Country option for a site address.") + case .NC: return NSLocalizedString("New Caledonia", comment: "Country option for a site address.") + case .NZ: return NSLocalizedString("New Zealand", comment: "Country option for a site address.") + case .NI: return NSLocalizedString("Nicaragua", comment: "Country option for a site address.") + case .NE: return NSLocalizedString("Niger", comment: "Country option for a site address.") + case .NG: return NSLocalizedString("Nigeria", comment: "Country option for a site address.") + case .NU: return NSLocalizedString("Niue", comment: "Country option for a site address.") + case .NF: return NSLocalizedString("Norfolk Island", comment: "Country option for a site address.") + case .KP: return NSLocalizedString("North Korea", comment: "Country option for a site address.") + case .MP: return NSLocalizedString("Northern Mariana Islands", comment: "Country option for a site address.") + case .NO: return NSLocalizedString("Norway", comment: "Country option for a site address.") + + // O + case .OM: return NSLocalizedString("Oman", comment: "Country option for a site address.") + + // P + case .PK: return NSLocalizedString("Pakistan", comment: "Country option for a site address.") + case .PS: return NSLocalizedString("Palestinian Territory", comment: "Country option for a site address.") + case .PA: return NSLocalizedString("Panama", comment: "Country option for a site address.") + case .PG: return NSLocalizedString("Papua New Guinea", comment: "Country option for a site address.") + case .PY: return NSLocalizedString("Paraguay", comment: "Country option for a site address.") + case .PE: return NSLocalizedString("Peru", comment: "Country option for a site address.") + case .PH: return NSLocalizedString("Philippines", comment: "Country option for a site address.") + case .PN: return NSLocalizedString("Pitcairn", comment: "Country option for a site address.") + case .PL: return NSLocalizedString("Poland", comment: "Country option for a site address.") + case .PT: return NSLocalizedString("Portugal", comment: "Country option for a site address.") + case .PR: return NSLocalizedString("Puerto Rico", comment: "Country option for a site address.") + + // Q + case .QA: return NSLocalizedString("Qatar", comment: "Country option for a site address.") + + // R + case .RE: return NSLocalizedString("Reunion", comment: "Country option for a site address.") + case .RO: return NSLocalizedString("Romania", comment: "Country option for a site address.") + case .RU: return NSLocalizedString("Russia", comment: "Country option for a site address.") + case .RW: return NSLocalizedString("Rwanda", comment: "Country option for a site address.") + + // S + case .ST: return NSLocalizedString("São Tomé and Príncipe", comment: "Country option for a site address.") + case .BL: return NSLocalizedString("Saint Barthélemy", comment: "Country option for a site address.") + case .SH: return NSLocalizedString("Saint Helena", comment: "Country option for a site address.") + case .KN: return NSLocalizedString("Saint Kitts and Nevis", comment: "Country option for a site address.") + case .LC: return NSLocalizedString("Saint Lucia", comment: "Country option for a site address.") + case .SX: return NSLocalizedString("Saint Martin (Dutch part)", comment: "Country option for a site address.") + case .MF: return NSLocalizedString("Saint Martin (French part)", comment: "Country option for a site address.") + case .PM: return NSLocalizedString("Saint Pierre and Miquelon", comment: "Country option for a site address.") + case .VC: return NSLocalizedString("Saint Vincent and the Grenadines", comment: "Country option for a site address.") + case .WS: return NSLocalizedString("Samoa", comment: "Country option for a site address.") + case .SM: return NSLocalizedString("San Marino", comment: "Country option for a site address.") + case .SA: return NSLocalizedString("Saudi Arabia", comment: "Country option for a site address.") + case .SN: return NSLocalizedString("Senegal", comment: "Country option for a site address.") + case .RS: return NSLocalizedString("Serbia", comment: "Country option for a site address.") + case .SC: return NSLocalizedString("Seychelles", comment: "Country option for a site address.") + case .SL: return NSLocalizedString("Sierra Leone", comment: "Country option for a site address.") + case .SG: return NSLocalizedString("Singapore", comment: "Country option for a site address.") + case .SK: return NSLocalizedString("Slovakia", comment: "Country option for a site address.") + case .SI: return NSLocalizedString("Slovenia", comment: "Country option for a site address.") + case .SB: return NSLocalizedString("Solomon Islands", comment: "Country option for a site address.") + case .SO: return NSLocalizedString("Somalia", comment: "Country option for a site address.") + case .ZA: return NSLocalizedString("South Africa", comment: "Country option for a site address.") + case .GS: return NSLocalizedString("South Georgia/Sandwich Islands", comment: "Country option for a site address.") + case .KR: return NSLocalizedString("South Korea", comment: "Country option for a site address.") + case .SS: return NSLocalizedString("South Sudan", comment: "Country option for a site address.") + case .ES: return NSLocalizedString("Spain", comment: "Country option for a site address.") + case .LK: return NSLocalizedString("Sri Lanka", comment: "Country option for a site address.") + case .SD: return NSLocalizedString("Sudan", comment: "Country option for a site address.") + case .SR: return NSLocalizedString("Suriname", comment: "Country option for a site address.") + case .SJ: return NSLocalizedString("Svalbard and Jan Mayen", comment: "Country option for a site address.") + case .SZ: return NSLocalizedString("Swaziland", comment: "Country option for a site address.") + case .SE: return NSLocalizedString("Sweden", comment: "Country option for a site address.") + case .CH: return NSLocalizedString("Switzerland", comment: "Country option for a site address.") + case .SY: return NSLocalizedString("Syria", comment: "Country option for a site address.") + + // T + case .TW: return NSLocalizedString("Taiwan", comment: "Country option for a site address.") + case .TJ: return NSLocalizedString("Tajikistan", comment: "Country option for a site address.") + case .TZ: return NSLocalizedString("Tanzania", comment: "Country option for a site address.") + case .TH: return NSLocalizedString("Thailand", comment: "Country option for a site address.") + case .TL: return NSLocalizedString("Timor-Leste", comment: "Country option for a site address.") + case .TG: return NSLocalizedString("Togo", comment: "Country option for a site address.") + case .TK: return NSLocalizedString("Tokelau", comment: "Country option for a site address.") + case .TO: return NSLocalizedString("Tonga", comment: "Country option for a site address.") + case .TT: return NSLocalizedString("Trinidad and Tobago", comment: "Country option for a site address.") + case .TN: return NSLocalizedString("Tunisia", comment: "Country option for a site address.") + case .TR: return NSLocalizedString("Turkey", comment: "Country option for a site address.") + case .TM: return NSLocalizedString("Turkmenistan", comment: "Country option for a site address.") + case .TC: return NSLocalizedString("Turks and Caicos Islands", comment: "Country option for a site address.") + case .TV: return NSLocalizedString("Tuvalu", comment: "Country option for a site address.") + + // U + case .UG: return NSLocalizedString("Uganda", comment: "Country option for a site address.") + case .UA: return NSLocalizedString("Ukraine", comment: "Country option for a site address.") + case .AE: return NSLocalizedString("United Arab Emirates", comment: "Country option for a site address.") + case .GB: return NSLocalizedString("United Kingdom", comment: "Country option for a site address.") + case .US: return NSLocalizedString("United States", comment: "Country option for a site address.") + case .UM: return NSLocalizedString("United States Minor Outlying Islands", comment: "Country option for a site address.") + case .VI: return NSLocalizedString("United States Virgin Islands", comment: "Country option for a site address.") + case .UY: return NSLocalizedString("Uruguay", comment: "Country option for a site address.") + case .UZ: return NSLocalizedString("Uzbekistan", comment: "Country option for a site address.") + + // V + case .VU: return NSLocalizedString("Vanuatu", comment: "Country option for a site address.") + case .VA: return NSLocalizedString("Vatican", comment: "Country option for a site address.") + case .VE: return NSLocalizedString("Venezuela", comment: "Country option for a site address.") + case .VN: return NSLocalizedString("Vietnam", comment: "Country option for a site address.") + + // W + case .WF: return NSLocalizedString("Wallis and Futuna", comment: "Country option for a site address.") + case .EH: return NSLocalizedString("Western Sahara", comment: "Country option for a site address.") + + // Y + case .YE: return NSLocalizedString("Yemen", comment: "Country option for a site address.") + + // Z + case .ZM: return NSLocalizedString("Zambia", comment: "Country option for a site address.") + case .ZW: return NSLocalizedString("Zimbabwe", comment: "Country option for a site address.") + + case .unknown: return NSLocalizedString("Unknown country", comment: "Fallback country option for a site address.") + } + } +} diff --git a/Modules/Sources/Yosemite/Stores/CollectOrderPaymentUseCaseError.swift b/Modules/Sources/Yosemite/Stores/CollectOrderPaymentUseCaseError.swift new file mode 100644 index 00000000000..18b12e00f02 --- /dev/null +++ b/Modules/Sources/Yosemite/Stores/CollectOrderPaymentUseCaseError.swift @@ -0,0 +1,53 @@ +import Foundation + +public enum CollectOrderPaymentUseCaseError: LocalizedError { + case flowCanceledByUser + case paymentGatewayNotFound + case orderTotalChanged + case couldNotRefreshOrder(Error) + case orderAlreadyPaid + + public var errorDescription: String? { + switch self { + case .flowCanceledByUser: + return Localization.paymentCancelledLocalizedDescription + case .paymentGatewayNotFound: + return Localization.paymentGatewayNotFoundLocalizedDescription + case .orderTotalChanged: + return Localization.orderTotalChangedLocalizedDescription + case .couldNotRefreshOrder(let error as LocalizedError): + return error.errorDescription + case .couldNotRefreshOrder(let error): + return String.localizedStringWithFormat(Localization.couldNotRefreshOrderLocalizedDescription, error.localizedDescription) + case .orderAlreadyPaid: + return Localization.orderAlreadyPaidLocalizedDescription + } + } + + private enum Localization { + static let couldNotRefreshOrderLocalizedDescription = NSLocalizedString( + "Unable to process payment. We could not fetch the latest order details. Please check your network " + + "connection and try again. Underlying error: %1$@", + comment: "Error message when collecting an In-Person Payment and unable to update the order. %!$@ will " + + "be replaced with further error details.") + + static let orderTotalChangedLocalizedDescription = NSLocalizedString( + "collectOrderPaymentUseCase.error.message.orderTotalChanged", + value: "Order total has changed since the beginning of payment. Please go back and check the order is " + + "correct, then try the payment again.", + comment: "Error message when collecting an In-Person Payment and the order total has changed remotely.") + + static let orderAlreadyPaidLocalizedDescription = NSLocalizedString( + "Unable to process payment. This order is already paid, taking a further payment would result in the " + + "customer being charged twice for their order.", + comment: "Error message shown during In-Person Payments when the order is found to be paid after it's refreshed.") + + static let paymentGatewayNotFoundLocalizedDescription = NSLocalizedString( + "Unable to process payment. We could not connect to the payment system. Please contact support if this " + + "error continues.", + comment: "Error message shown during In-Person Payments when the payment gateway is not available.") + + static let paymentCancelledLocalizedDescription = NSLocalizedString( + "The payment was cancelled.", comment: "Message shown if a payment cancellation is shown as an error.") + } +} diff --git a/WooCommerce/Classes/Tools/InfiniteScroll/AsyncPaginationTracker.swift b/Modules/Sources/Yosemite/Tools/AsyncPaginationTracker.swift similarity index 85% rename from WooCommerce/Classes/Tools/InfiniteScroll/AsyncPaginationTracker.swift rename to Modules/Sources/Yosemite/Tools/AsyncPaginationTracker.swift index b58c1e2048d..91539cb821f 100644 --- a/WooCommerce/Classes/Tools/InfiniteScroll/AsyncPaginationTracker.swift +++ b/Modules/Sources/Yosemite/Tools/AsyncPaginationTracker.swift @@ -1,21 +1,20 @@ import Foundation -import Yosemite /// Async/await version of `PaginationTracker`, consider renaming `PaginationTracker` as deprecated and this class to `PaginationTracker`. /// Keeps track of the pagination for API syncing to support infinite scroll and pull-to-refresh. -final class AsyncPaginationTracker { - typealias SyncFunction = (_ pageNumber: Int) async throws -> Bool +public final class AsyncPaginationTracker { + public typealias SyncFunction = (_ pageNumber: Int) async throws -> Bool /// State of loading the next page in `ensureNextPageIsSynced`. - enum NextPageSyncState { + public enum NextPageSyncState { case syncing case synced case noNextPage } /// Default pagination settings. - enum Defaults { - static let pageFirstIndex = Store.Default.firstPageNumber + public enum Defaults { + public static let pageFirstIndex = Store.Default.firstPageNumber } /// The index of the first page in the API. So far, both Woo and WP.com API have the first page index at 1. @@ -28,7 +27,7 @@ final class AsyncPaginationTracker { private var pagesBeingSynced = IndexSet() /// Whether there might be more pages to fetch from the API, set by the sync function. - private(set) var hasNextPage: Bool = true + private(set) public var hasNextPage: Bool = true /// Returns the highest page number that has been successfully synced, if any. private var highestPageSynced: Int? { @@ -41,7 +40,7 @@ final class AsyncPaginationTracker { } /// Designated Initializer - init(pageFirstIndex: Int = Defaults.pageFirstIndex) { + public init(pageFirstIndex: Int = Defaults.pageFirstIndex) { self.pageFirstIndex = pageFirstIndex } @@ -50,7 +49,7 @@ final class AsyncPaginationTracker { /// 1. Proceed only if there is next page to sync. /// 2. Verify if the next page isn't currently being synced. /// 3. Proceed syncing the next page. - func ensureNextPageIsSynced(syncFunction: @escaping SyncFunction) async throws -> NextPageSyncState { + public func ensureNextPageIsSynced(syncFunction: @escaping SyncFunction) async throws -> NextPageSyncState { guard hasNextPage else { return .noNextPage } @@ -69,14 +68,14 @@ final class AsyncPaginationTracker { /// Resets internal states and resyncs the first page of results. /// - func resync(syncFunction: @escaping SyncFunction) async throws { + public func resync(syncFunction: @escaping SyncFunction) async throws { resetInternalState() try await syncFirstPage(syncFunction: syncFunction) } /// Syncs the first page of results. /// - func syncFirstPage(syncFunction: @escaping SyncFunction) async throws { + public func syncFirstPage(syncFunction: @escaping SyncFunction) async throws { try await sync(pageNumber: pageFirstIndex, syncFunction: syncFunction) } } diff --git a/WooCommerce/Classes/ViewModels/CardPresentPayments/PaymentCaptureCelebration.swift b/Modules/Sources/Yosemite/Tools/Payments/PaymentCaptureCelebration.swift similarity index 82% rename from WooCommerce/Classes/ViewModels/CardPresentPayments/PaymentCaptureCelebration.swift rename to Modules/Sources/Yosemite/Tools/Payments/PaymentCaptureCelebration.swift index fb629d98df7..cfd3920e18a 100644 --- a/WooCommerce/Classes/ViewModels/CardPresentPayments/PaymentCaptureCelebration.swift +++ b/Modules/Sources/Yosemite/Tools/Payments/PaymentCaptureCelebration.swift @@ -2,16 +2,20 @@ import AudioToolbox import UIKit /// Allows mocking payment capture celebration UX so that the cha-ching sounds aren't played in unit testing. -protocol PaymentCaptureCelebrationProtocol { +public protocol PaymentCaptureCelebrationProtocol { /// Called when a payment is captured successfully. func celebrate() } /// Plays a sound and provides haptic feedback when a payment capture has been completed successfully -final class PaymentCaptureCelebration: NSObject, PaymentCaptureCelebrationProtocol { +public final class PaymentCaptureCelebration: NSObject, PaymentCaptureCelebrationProtocol { private var soundID: SystemSoundID = 0 - func celebrate() { + public override init() { + super.init() + } + + public func celebrate() { playSound() shakeDevice() } diff --git a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentsAlertPresenterAdaptor.swift b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentsAlertPresenterAdaptor.swift index a6784c69142..8e7a64508f3 100644 --- a/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentsAlertPresenterAdaptor.swift +++ b/WooCommerce/Classes/POS/Adaptors/Card Present Payments/CardPresentPaymentsAlertPresenterAdaptor.swift @@ -2,6 +2,7 @@ import Foundation import Combine import enum Yosemite.ServerSidePaymentCaptureError import enum Yosemite.CardReaderServiceError +import enum Yosemite.CollectOrderPaymentUseCaseError final class CardPresentPaymentsAlertPresenterAdaptor: CardPresentPaymentAlertsPresenting { typealias AlertDetails = CardPresentPaymentEventDetails diff --git a/WooCommerce/Classes/POS/Adaptors/POSServiceLocatorAdaptor.swift b/WooCommerce/Classes/POS/Adaptors/POSServiceLocatorAdaptor.swift index 5eaf6d3fa7c..2e019e83a76 100644 --- a/WooCommerce/Classes/POS/Adaptors/POSServiceLocatorAdaptor.swift +++ b/WooCommerce/Classes/POS/Adaptors/POSServiceLocatorAdaptor.swift @@ -115,4 +115,8 @@ private struct POSExternalViewAdaptor: POSExternalViewProviding { onSelection: onSelection )) } + + func createWCWebView(adminUrl: URL, completion: @escaping () -> Void) -> AnyView { + AnyView(WCSettingsWebView(adminUrl: adminUrl, completion: completion)) + } } diff --git a/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift b/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift index ee93978e17b..5e82188b6ce 100644 --- a/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift +++ b/WooCommerce/Classes/POS/Analytics/WooAnalyticsEvent+PointOfSale.swift @@ -125,7 +125,7 @@ extension WooAnalyticsEvent { Key.cardReaderModel: readerModel(for: cardReaderModel), Key.countryCode: countryCode.rawValue, Key.gatewayID: safeGatewayID(for: forGatewayID), - Key.paymentMethodType: paymentMethod.analyticsValue, + Key.paymentMethodType: analyticsValue(for: paymentMethod), Key.millisecondsSinceCustomerInteractionStarted: "\(millisecondsSinceCustomerIteractionStarted)", Key.millisecondsSinceOrderSyncSuccess: "\(millisecondsSinceOrderSyncSuccess)", Key.millisecondsSinceReaderReadyToCollect: "\(millisecondsSinceReaderReadyToCollect)", @@ -134,6 +134,17 @@ extension WooAnalyticsEvent { ]) } + static func analyticsValue(for paymentMethod: PaymentMethod) -> String { + switch paymentMethod { + case .card, .cardPresent: + return "card" + case .interacPresent: + return "card_interac" + case .unknown: + return "unknown" + } + } + static func cashCollectPaymentSuccess(millisecondsSinceCustomerIteractionStarted: Double) -> WooAnalyticsEvent { WooAnalyticsEvent(statName: .pointOfSaleCashCollectPaymentSuccess, properties: [ Key.millisecondsSinceCustomerInteractionStarted: "\(millisecondsSinceCustomerIteractionStarted)", diff --git a/WooCommerce/Classes/POS/Controllers/POSOrderListController.swift b/WooCommerce/Classes/POS/Controllers/POSOrderListController.swift index 6ab3ef8d471..9b7911ece26 100644 --- a/WooCommerce/Classes/POS/Controllers/POSOrderListController.swift +++ b/WooCommerce/Classes/POS/Controllers/POSOrderListController.swift @@ -8,6 +8,7 @@ import struct Yosemite.POSOrder import struct Yosemite.POSOrderItem import struct Yosemite.POSOrderRefund import class Yosemite.Store +import class Yosemite.AsyncPaginationTracker protocol POSOrderListControllerProtocol { var ordersViewState: POSOrderListState { get } diff --git a/WooCommerce/Classes/POS/Controllers/PointOfSaleCouponsController.swift b/WooCommerce/Classes/POS/Controllers/PointOfSaleCouponsController.swift index abfd33d16ee..84ae60688aa 100644 --- a/WooCommerce/Classes/POS/Controllers/PointOfSaleCouponsController.swift +++ b/WooCommerce/Classes/POS/Controllers/PointOfSaleCouponsController.swift @@ -5,6 +5,7 @@ import protocol Yosemite.PointOfSaleItemServiceProtocol import protocol Yosemite.PointOfSaleCouponServiceProtocol import struct Yosemite.PointOfSaleCouponFetchStrategyFactory import protocol Yosemite.PointOfSaleCouponFetchStrategy +import class Yosemite.AsyncPaginationTracker protocol PointOfSaleCouponsControllerProtocol: PointOfSaleSearchingItemsControllerProtocol { /// Enables coupons in store settings diff --git a/WooCommerce/Classes/POS/Controllers/PointOfSaleItemsController.swift b/WooCommerce/Classes/POS/Controllers/PointOfSaleItemsController.swift index 9abb678812d..6d621aa470d 100644 --- a/WooCommerce/Classes/POS/Controllers/PointOfSaleItemsController.swift +++ b/WooCommerce/Classes/POS/Controllers/PointOfSaleItemsController.swift @@ -9,6 +9,7 @@ import enum Yosemite.PointOfSaleItemServiceError import struct Yosemite.POSVariableParentProduct import class Yosemite.Store import enum Yosemite.POSItemType +import class Yosemite.AsyncPaginationTracker protocol PointOfSaleItemsControllerProtocol { /// diff --git a/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift b/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift index fdc704ad42a..a2041ed5bac 100644 --- a/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift +++ b/WooCommerce/Classes/POS/Controllers/PointOfSaleOrderController.swift @@ -5,6 +5,8 @@ import class WooFoundation.VersionHelpers import protocol Yosemite.POSOrderServiceProtocol import protocol Yosemite.POSReceiptServiceProtocol import protocol Yosemite.PluginsServiceProtocol +import protocol Yosemite.PaymentCaptureCelebrationProtocol +import class Yosemite.PaymentCaptureCelebration import struct Yosemite.Order import struct Yosemite.POSCart import struct Yosemite.POSCartItem diff --git a/WooCommerce/Classes/POS/Presentation/Card Present Payments/PointOfSaleCardPresentPaymentEventPresentationStyle.swift b/WooCommerce/Classes/POS/Presentation/Card Present Payments/PointOfSaleCardPresentPaymentEventPresentationStyle.swift index c6cbc5825e8..304b7aeba54 100644 --- a/WooCommerce/Classes/POS/Presentation/Card Present Payments/PointOfSaleCardPresentPaymentEventPresentationStyle.swift +++ b/WooCommerce/Classes/POS/Presentation/Card Present Payments/PointOfSaleCardPresentPaymentEventPresentationStyle.swift @@ -1,4 +1,5 @@ import Foundation +import enum Yosemite.CollectOrderPaymentUseCaseError enum PointOfSaleCardPresentPaymentEventPresentationStyle { case message(PointOfSaleCardPresentPaymentMessageType) diff --git a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView.swift b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView.swift index 5413cf3897b..afb003c6fcc 100644 --- a/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView.swift +++ b/WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView.swift @@ -3,6 +3,7 @@ import SwiftUI struct PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView: View { @StateObject var viewModel: PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressAlertViewModel let animation: POSCardPresentPaymentAlertAnimation + @Environment(\.posExternalViews) private var externalViews var body: some View { VStack(spacing: PointOfSaleReaderConnectionModalLayout.contentButtonSpacing) { @@ -29,8 +30,8 @@ struct PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView: View { .multilineTextAlignment(.center) .accessibilityElement(children: .contain) .posSheet(isPresented: $viewModel.shouldShowSettingsWebView) { - WCSettingsWebView(adminUrl: viewModel.settingsAdminUrl, - completion: viewModel.settingsWebViewWasDismissed) + externalViews.createWCWebView(adminUrl: viewModel.settingsAdminUrl, + completion: viewModel.settingsWebViewWasDismissed) } } } diff --git a/WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsHardwareDetailView.swift b/WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsHardwareDetailView.swift index 4fb6ec1a9f8..e4355edb426 100644 --- a/WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsHardwareDetailView.swift +++ b/WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsHardwareDetailView.swift @@ -156,7 +156,9 @@ struct PointOfSaleSettingsHardwareDetailView: View { } .navigationBarBackButtonHidden(true) .posFullScreenCover(isPresented: $showCardReaderDocumentationModal) { - SafariView(url: WooConstants.URLs.inPersonPaymentsLearnMoreWCPay.asURL()) + if let url = URL(string: Constants.inPersonPaymentsLearnMoreWCPay.rawValue) { + SafariView(url: url) + } } } @@ -383,6 +385,13 @@ private extension PointOfSaleSettingsHardwareDetailView { } } +private extension PointOfSaleSettingsHardwareDetailView { + enum Constants: String { + case inPersonPaymentsLearnMoreWCPay = + "https://woocommerce.com/document/woocommerce-payments/in-person-payments/getting-started-with-in-person-payments/" + } +} + #if DEBUG #Preview { PointOfSaleSettingsHardwareDetailView(settingsController: PointOfSaleSettingsPreviewController()) diff --git a/WooCommerce/Classes/POS/Protocols/POSDependencyProviding.swift b/WooCommerce/Classes/POS/Protocols/POSDependencyProviding.swift index 095c0efd186..2388ea2d38e 100644 --- a/WooCommerce/Classes/POS/Protocols/POSDependencyProviding.swift +++ b/WooCommerce/Classes/POS/Protocols/POSDependencyProviding.swift @@ -59,6 +59,7 @@ protocol POSExternalViewProviding { title: String, cancelButtonTitle: String, onSelection: @escaping (Coupon.DiscountType) -> Void) -> AnyView + func createWCWebView(adminUrl: URL, completion: @escaping () -> Void) -> AnyView } /// Main protocol that combines all POS dependency providers diff --git a/WooCommerce/Classes/POS/TabBar/POSIneligibleView.swift b/WooCommerce/Classes/POS/TabBar/POSIneligibleView.swift index 6d7e4190372..dd52102442c 100644 --- a/WooCommerce/Classes/POS/TabBar/POSIneligibleView.swift +++ b/WooCommerce/Classes/POS/TabBar/POSIneligibleView.swift @@ -1,4 +1,5 @@ import SwiftUI +import Yosemite /// A view that displays when the Point of Sale (POS) feature is not available for the current store. /// Shows the specific reason why POS is ineligible and provides a button to re-check eligibility. diff --git a/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift b/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift index 7dab8f52bb1..90d16b721c9 100644 --- a/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift +++ b/WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift @@ -142,5 +142,8 @@ struct EmptyPOSExternalView: POSExternalViewProviding { onSelection: @escaping (Coupon.DiscountType) -> Void) -> AnyView { AnyView(EmptyView()) } + func createWCWebView(adminUrl: URL, completion: @escaping () -> Void) -> AnyView { + AnyView(EmptyView()) + } init() {} } diff --git a/WooCommerce/Classes/Tools/SiteAddress.swift b/WooCommerce/Classes/Tools/SiteAddress.swift index e303769ad62..73026d52ba3 100644 --- a/WooCommerce/Classes/Tools/SiteAddress.swift +++ b/WooCommerce/Classes/Tools/SiteAddress.swift @@ -79,316 +79,3 @@ private extension SiteAddress { static let countryAndState = "woocommerce_default_country" } } - -// MARK: - Mapping between country codes and readable names -// The country names were extracted from the response to `/wp-json/wc/v3/settings/general` -// The default countries are listed under `woocommerce_default_country` -// in one of the following formats: -// - `"COUNTRY_CODE": "READABALE_COUNTRY_NAME" -// - `"COUNTRY_CODE:COUNTRY_REGION": "READABLE_COUNTRY_NAME - READABLE_COUNTRY_REGION" -extension CountryCode { - var readableCountry: String { - switch self { - // A - case .AX: return NSLocalizedString("Åland Islands", comment: "Country option for a site address.") - case .AF: return NSLocalizedString("Afghanistan", comment: "Country option for a site address.") - case .AL: return NSLocalizedString("Albania", comment: "Country option for a site address.") - case .DZ: return NSLocalizedString("Algeria", comment: "Country option for a site address.") - case .AS: return NSLocalizedString("American Samoa", comment: "Country option for a site address.") - case .AD: return NSLocalizedString("Andorra", comment: "Country option for a site address.") - case .AO: return NSLocalizedString("Angola", comment: "Country option for a site address.") - case .AI: return NSLocalizedString("Anguilla", comment: "Country option for a site address.") - case .AQ: return NSLocalizedString("Antarctica", comment: "Country option for a site address.") - case .AG: return NSLocalizedString("Antigua and Barbuda", comment: "Country option for a site address.") - case .AR: return NSLocalizedString("Argentina", comment: "Country option for a site address.") - case .AM: return NSLocalizedString("Armenia", comment: "Country option for a site address.") - case .AW: return NSLocalizedString("Aruba", comment: "Country option for a site address.") - case .AU: return NSLocalizedString("Australia", comment: "Country option for a site address.") - case .AT: return NSLocalizedString("Austria", comment: "Country option for a site address.") - case .AZ: return NSLocalizedString("Azerbaijan", comment: "Country option for a site address.") - - // B - case .BS: return NSLocalizedString("Bahamas", comment: "Country option for a site address.") - case .BH: return NSLocalizedString("Bahrain", comment: "Country option for a site address.") - case .BD: return NSLocalizedString("Bangladesh", comment: "Country option for a site address.") - case .BB: return NSLocalizedString("Barbados", comment: "Country option for a site address.") - case .BY: return NSLocalizedString("Belarus", comment: "Country option for a site address.") - case .PW: return NSLocalizedString("Belau", comment: "Country option for a site address.") - case .BE: return NSLocalizedString("Belgium", comment: "Country option for a site address.") - case .BZ: return NSLocalizedString("Belize", comment: "Country option for a site address.") - case .BJ: return NSLocalizedString("Benin", comment: "Country option for a site address.") - case .BM: return NSLocalizedString("Bermuda", comment: "Country option for a site address.") - case .BT: return NSLocalizedString("Bhutan", comment: "Country option for a site address.") - case .BO: return NSLocalizedString("Bolivia", comment: "Country option for a site address.") - case .BQ: return NSLocalizedString("Bonaire, Saint Eustatius and Saba", comment: "Country option for a site address.") - case .BA: return NSLocalizedString("Bosnia and Herzegovina", comment: "Country option for a site address.") - case .BW: return NSLocalizedString("Botswana", comment: "Country option for a site address.") - case .BV: return NSLocalizedString("Bouvet Island", comment: "Country option for a site address.") - case .BR: return NSLocalizedString("Brazil", comment: "Country option for a site address.") - case .IO: return NSLocalizedString("British Indian Ocean Territory", comment: "Country option for a site address.") - case .VG: return NSLocalizedString("British Virgin Islands", comment: "Country option for a site address.") - case .BN: return NSLocalizedString("Brunei", comment: "Country option for a site address.") - case .BG: return NSLocalizedString("Bulgaria", comment: "Country option for a site address.") - case .BF: return NSLocalizedString("Burkina Faso", comment: "Country option for a site address.") - case .BI: return NSLocalizedString("Burundi", comment: "Country option for a site address.") - - // C - case .KH: return NSLocalizedString("Cambodia", comment: "Country option for a site address.") - case .CM: return NSLocalizedString("Cameroon", comment: "Country option for a site address.") - case .CA: return NSLocalizedString("Canada", comment: "Country option for a site address.") - case .CV: return NSLocalizedString("Cape Verde", comment: "Country option for a site address.") - case .KY: return NSLocalizedString("Cayman Islands", comment: "Country option for a site address.") - case .CF: return NSLocalizedString("Central African Republic", comment: "Country option for a site address.") - case .TD: return NSLocalizedString("Chad", comment: "Country option for a site address.") - case .CL: return NSLocalizedString("Chile", comment: "Country option for a site address.") - case .CN: return NSLocalizedString("China", comment: "Country option for a site address.") - case .CX: return NSLocalizedString("Christmas Island", comment: "Country option for a site address.") - case .CC: return NSLocalizedString("Cocos (Keeling) Islands", comment: "Country option for a site address.") - case .CO: return NSLocalizedString("Colombia", comment: "Country option for a site address.") - case .KM: return NSLocalizedString("Comoros", comment: "Country option for a site address.") - case .CG: return NSLocalizedString("Congo (Brazzaville)", comment: "Country option for a site address.") - case .CD: return NSLocalizedString("Congo (Kinshasa)", comment: "Country option for a site address.") - case .CK: return NSLocalizedString("Cook Islands", comment: "Country option for a site address.") - case .CR: return NSLocalizedString("Costa Rica", comment: "Country option for a site address.") - case .HR: return NSLocalizedString("Croatia", comment: "Country option for a site address.") - case .CU: return NSLocalizedString("Cuba", comment: "Country option for a site address.") - case .CW: return NSLocalizedString("Curacao", comment: "Country option for a site address.") - case .CY: return NSLocalizedString("Cyprus", comment: "Country option for a site address.") - case .CZ: return NSLocalizedString("Czech Republic", comment: "Country option for a site address.") - - // D - case .DK: return NSLocalizedString("Denmark", comment: "Country option for a site address.") - case .DJ: return NSLocalizedString("Djibouti", comment: "Country option for a site address.") - case .DM: return NSLocalizedString("Dominica", comment: "Country option for a site address.") - case .DO: return NSLocalizedString("Dominican Republic", comment: "Country option for a site address.") - - // E - case .EC: return NSLocalizedString("Ecuador", comment: "Country option for a site address.") - case .EG: return NSLocalizedString("Egypt", comment: "Country option for a site address.") - case .SV: return NSLocalizedString("El Salvador", comment: "Country option for a site address.") - case .GQ: return NSLocalizedString("Equatorial Guinea", comment: "Country option for a site address.") - case .ER: return NSLocalizedString("Eritrea", comment: "Country option for a site address.") - case .EE: return NSLocalizedString("Estonia", comment: "Country option for a site address.") - case .ET: return NSLocalizedString("Ethiopia", comment: "Country option for a site address.") - - // F - case .FK: return NSLocalizedString("Falkland Islands", comment: "Country option for a site address.") - case .FO: return NSLocalizedString("Faroe Islands", comment: "Country option for a site address.") - case .FJ: return NSLocalizedString("Fiji", comment: "Country option for a site address.") - case .FI: return NSLocalizedString("Finland", comment: "Country option for a site address.") - case .FR: return NSLocalizedString("France", comment: "Country option for a site address.") - case .GF: return NSLocalizedString("French Guiana", comment: "Country option for a site address.") - case .PF: return NSLocalizedString("French Polynesia", comment: "Country option for a site address.") - case .TF: return NSLocalizedString("French Southern Territories", comment: "Country option for a site address.") - - // G - case .GA: return NSLocalizedString("Gabon", comment: "Country option for a site address.") - case .GM: return NSLocalizedString("Gambia", comment: "Country option for a site address.") - case .GE: return NSLocalizedString("Georgia", comment: "Country option for a site address.") - case .DE: return NSLocalizedString("Germany", comment: "Country option for a site address.") - case .GH: return NSLocalizedString("Ghana", comment: "Country option for a site address.") - case .GI: return NSLocalizedString("Gibraltar", comment: "Country option for a site address.") - case .GR: return NSLocalizedString("Greece", comment: "Country option for a site address.") - case .GL: return NSLocalizedString("Greenland", comment: "Country option for a site address.") - case .GD: return NSLocalizedString("Grenada", comment: "Country option for a site address.") - case .GP: return NSLocalizedString("Guadeloupe", comment: "Country option for a site address.") - case .GU: return NSLocalizedString("Guam", comment: "Country option for a site address.") - case .GT: return NSLocalizedString("Guatemala", comment: "Country option for a site address.") - case .GG: return NSLocalizedString("Guernsey", comment: "Country option for a site address.") - case .GN: return NSLocalizedString("Guinea", comment: "Country option for a site address.") - case .GW: return NSLocalizedString("Guinea-Bissau", comment: "Country option for a site address.") - case .GY: return NSLocalizedString("Guyana", comment: "Country option for a site address.") - - // H - case .HT: return NSLocalizedString("Haiti", comment: "Country option for a site address.") - case .HM: return NSLocalizedString("Heard Island and McDonald Islands", comment: "Country option for a site address.") - case .HN: return NSLocalizedString("Honduras", comment: "Country option for a site address.") - case .HK: return NSLocalizedString("Hong Kong", comment: "Country option for a site address.") - case .HU: return NSLocalizedString("Hungary", comment: "Country option for a site address.") - - // I - case .IS: return NSLocalizedString("Iceland", comment: "Country option for a site address.") - case .IN: return NSLocalizedString("India", comment: "Country option for a site address.") - case .ID: return NSLocalizedString("Indonesia", comment: "Country option for a site address.") - case .IR: return NSLocalizedString("Iran", comment: "Country option for a site address.") - case .IQ: return NSLocalizedString("Iraq", comment: "Country option for a site address.") - case .IE: return NSLocalizedString("Ireland", comment: "Country option for a site address.") - case .IM: return NSLocalizedString("Isle of Man", comment: "Country option for a site address.") - case .IL: return NSLocalizedString("Israel", comment: "Country option for a site address.") - case .IT: return NSLocalizedString("Italy", comment: "Country option for a site address.") - case .CI: return NSLocalizedString("Ivory Coast", comment: "Country option for a site address.") - - // J - case .JM: return NSLocalizedString("Jamaica", comment: "Country option for a site address.") - case .JP: return NSLocalizedString("Japan", comment: "Country option for a site address.") - case .JE: return NSLocalizedString("Jersey", comment: "Country option for a site address.") - case .JO: return NSLocalizedString("Jordan", comment: "Country option for a site address.") - - // K - case .KZ: return NSLocalizedString("Kazakhstan", comment: "Country option for a site address.") - case .KE: return NSLocalizedString("Kenya", comment: "Country option for a site address.") - case .KI: return NSLocalizedString("Kiribati", comment: "Country option for a site address.") - case .KW: return NSLocalizedString("Kuwait", comment: "Country option for a site address.") - case .KG: return NSLocalizedString("Kyrgyzstan", comment: "Country option for a site address.") - - // L - case .LA: return NSLocalizedString("Laos", comment: "Country option for a site address.") - case .LV: return NSLocalizedString("Latvia", comment: "Country option for a site address.") - case .LB: return NSLocalizedString("Lebanon", comment: "Country option for a site address.") - case .LS: return NSLocalizedString("Lesotho", comment: "Country option for a site address.") - case .LR: return NSLocalizedString("Liberia", comment: "Country option for a site address.") - case .LY: return NSLocalizedString("Libya", comment: "Country option for a site address.") - case .LI: return NSLocalizedString("Liechtenstein", comment: "Country option for a site address.") - case .LT: return NSLocalizedString("Lithuania", comment: "Country option for a site address.") - case .LU: return NSLocalizedString("Luxembourg", comment: "Country option for a site address.") - - // M - case .MO: return NSLocalizedString("Macao S.A.R., China", comment: "Country option for a site address.") - case .MK: return NSLocalizedString("Macedonia", comment: "Country option for a site address.") - case .MG: return NSLocalizedString("Madagascar", comment: "Country option for a site address.") - case .MW: return NSLocalizedString("Malawi", comment: "Country option for a site address.") - case .MY: return NSLocalizedString("Malaysia", comment: "Country option for a site address.") - case .MV: return NSLocalizedString("Maldives", comment: "Country option for a site address.") - case .ML: return NSLocalizedString("Mali", comment: "Country option for a site address.") - case .MT: return NSLocalizedString("Malta", comment: "Country option for a site address.") - case .MH: return NSLocalizedString("Marshall Islands", comment: "Country option for a site address.") - case .MQ: return NSLocalizedString("Martinique", comment: "Country option for a site address.") - case .MR: return NSLocalizedString("Mauritania", comment: "Country option for a site address.") - case .MU: return NSLocalizedString("Mauritius", comment: "Country option for a site address.") - case .YT: return NSLocalizedString("Mayotte", comment: "Country option for a site address.") - case .MX: return NSLocalizedString("Mexico", comment: "Country option for a site address.") - case .FM: return NSLocalizedString("Micronesia", comment: "Country option for a site address.") - case .MD: return NSLocalizedString("Moldova", comment: "Country option for a site address.") - case .MC: return NSLocalizedString("Monaco", comment: "Country option for a site address.") - case .MN: return NSLocalizedString("Mongolia", comment: "Country option for a site address.") - case .ME: return NSLocalizedString("Montenegro", comment: "Country option for a site address.") - case .MS: return NSLocalizedString("Montserrat", comment: "Country option for a site address.") - case .MA: return NSLocalizedString("Morocco", comment: "Country option for a site address.") - case .MZ: return NSLocalizedString("Mozambique", comment: "Country option for a site address.") - case .MM: return NSLocalizedString("Myanmar", comment: "Country option for a site address.") - - // N - case .NA: return NSLocalizedString("Namibia", comment: "Country option for a site address.") - case .NR: return NSLocalizedString("Nauru", comment: "Country option for a site address.") - case .NP: return NSLocalizedString("Nepal", comment: "Country option for a site address.") - case .NL: return NSLocalizedString("Netherlands", comment: "Country option for a site address.") - case .NC: return NSLocalizedString("New Caledonia", comment: "Country option for a site address.") - case .NZ: return NSLocalizedString("New Zealand", comment: "Country option for a site address.") - case .NI: return NSLocalizedString("Nicaragua", comment: "Country option for a site address.") - case .NE: return NSLocalizedString("Niger", comment: "Country option for a site address.") - case .NG: return NSLocalizedString("Nigeria", comment: "Country option for a site address.") - case .NU: return NSLocalizedString("Niue", comment: "Country option for a site address.") - case .NF: return NSLocalizedString("Norfolk Island", comment: "Country option for a site address.") - case .KP: return NSLocalizedString("North Korea", comment: "Country option for a site address.") - case .MP: return NSLocalizedString("Northern Mariana Islands", comment: "Country option for a site address.") - case .NO: return NSLocalizedString("Norway", comment: "Country option for a site address.") - - // O - case .OM: return NSLocalizedString("Oman", comment: "Country option for a site address.") - - // P - case .PK: return NSLocalizedString("Pakistan", comment: "Country option for a site address.") - case .PS: return NSLocalizedString("Palestinian Territory", comment: "Country option for a site address.") - case .PA: return NSLocalizedString("Panama", comment: "Country option for a site address.") - case .PG: return NSLocalizedString("Papua New Guinea", comment: "Country option for a site address.") - case .PY: return NSLocalizedString("Paraguay", comment: "Country option for a site address.") - case .PE: return NSLocalizedString("Peru", comment: "Country option for a site address.") - case .PH: return NSLocalizedString("Philippines", comment: "Country option for a site address.") - case .PN: return NSLocalizedString("Pitcairn", comment: "Country option for a site address.") - case .PL: return NSLocalizedString("Poland", comment: "Country option for a site address.") - case .PT: return NSLocalizedString("Portugal", comment: "Country option for a site address.") - case .PR: return NSLocalizedString("Puerto Rico", comment: "Country option for a site address.") - - // Q - case .QA: return NSLocalizedString("Qatar", comment: "Country option for a site address.") - - // R - case .RE: return NSLocalizedString("Reunion", comment: "Country option for a site address.") - case .RO: return NSLocalizedString("Romania", comment: "Country option for a site address.") - case .RU: return NSLocalizedString("Russia", comment: "Country option for a site address.") - case .RW: return NSLocalizedString("Rwanda", comment: "Country option for a site address.") - - // S - case .ST: return NSLocalizedString("São Tomé and Príncipe", comment: "Country option for a site address.") - case .BL: return NSLocalizedString("Saint Barthélemy", comment: "Country option for a site address.") - case .SH: return NSLocalizedString("Saint Helena", comment: "Country option for a site address.") - case .KN: return NSLocalizedString("Saint Kitts and Nevis", comment: "Country option for a site address.") - case .LC: return NSLocalizedString("Saint Lucia", comment: "Country option for a site address.") - case .SX: return NSLocalizedString("Saint Martin (Dutch part)", comment: "Country option for a site address.") - case .MF: return NSLocalizedString("Saint Martin (French part)", comment: "Country option for a site address.") - case .PM: return NSLocalizedString("Saint Pierre and Miquelon", comment: "Country option for a site address.") - case .VC: return NSLocalizedString("Saint Vincent and the Grenadines", comment: "Country option for a site address.") - case .WS: return NSLocalizedString("Samoa", comment: "Country option for a site address.") - case .SM: return NSLocalizedString("San Marino", comment: "Country option for a site address.") - case .SA: return NSLocalizedString("Saudi Arabia", comment: "Country option for a site address.") - case .SN: return NSLocalizedString("Senegal", comment: "Country option for a site address.") - case .RS: return NSLocalizedString("Serbia", comment: "Country option for a site address.") - case .SC: return NSLocalizedString("Seychelles", comment: "Country option for a site address.") - case .SL: return NSLocalizedString("Sierra Leone", comment: "Country option for a site address.") - case .SG: return NSLocalizedString("Singapore", comment: "Country option for a site address.") - case .SK: return NSLocalizedString("Slovakia", comment: "Country option for a site address.") - case .SI: return NSLocalizedString("Slovenia", comment: "Country option for a site address.") - case .SB: return NSLocalizedString("Solomon Islands", comment: "Country option for a site address.") - case .SO: return NSLocalizedString("Somalia", comment: "Country option for a site address.") - case .ZA: return NSLocalizedString("South Africa", comment: "Country option for a site address.") - case .GS: return NSLocalizedString("South Georgia/Sandwich Islands", comment: "Country option for a site address.") - case .KR: return NSLocalizedString("South Korea", comment: "Country option for a site address.") - case .SS: return NSLocalizedString("South Sudan", comment: "Country option for a site address.") - case .ES: return NSLocalizedString("Spain", comment: "Country option for a site address.") - case .LK: return NSLocalizedString("Sri Lanka", comment: "Country option for a site address.") - case .SD: return NSLocalizedString("Sudan", comment: "Country option for a site address.") - case .SR: return NSLocalizedString("Suriname", comment: "Country option for a site address.") - case .SJ: return NSLocalizedString("Svalbard and Jan Mayen", comment: "Country option for a site address.") - case .SZ: return NSLocalizedString("Swaziland", comment: "Country option for a site address.") - case .SE: return NSLocalizedString("Sweden", comment: "Country option for a site address.") - case .CH: return NSLocalizedString("Switzerland", comment: "Country option for a site address.") - case .SY: return NSLocalizedString("Syria", comment: "Country option for a site address.") - - // T - case .TW: return NSLocalizedString("Taiwan", comment: "Country option for a site address.") - case .TJ: return NSLocalizedString("Tajikistan", comment: "Country option for a site address.") - case .TZ: return NSLocalizedString("Tanzania", comment: "Country option for a site address.") - case .TH: return NSLocalizedString("Thailand", comment: "Country option for a site address.") - case .TL: return NSLocalizedString("Timor-Leste", comment: "Country option for a site address.") - case .TG: return NSLocalizedString("Togo", comment: "Country option for a site address.") - case .TK: return NSLocalizedString("Tokelau", comment: "Country option for a site address.") - case .TO: return NSLocalizedString("Tonga", comment: "Country option for a site address.") - case .TT: return NSLocalizedString("Trinidad and Tobago", comment: "Country option for a site address.") - case .TN: return NSLocalizedString("Tunisia", comment: "Country option for a site address.") - case .TR: return NSLocalizedString("Turkey", comment: "Country option for a site address.") - case .TM: return NSLocalizedString("Turkmenistan", comment: "Country option for a site address.") - case .TC: return NSLocalizedString("Turks and Caicos Islands", comment: "Country option for a site address.") - case .TV: return NSLocalizedString("Tuvalu", comment: "Country option for a site address.") - - // U - case .UG: return NSLocalizedString("Uganda", comment: "Country option for a site address.") - case .UA: return NSLocalizedString("Ukraine", comment: "Country option for a site address.") - case .AE: return NSLocalizedString("United Arab Emirates", comment: "Country option for a site address.") - case .GB: return NSLocalizedString("United Kingdom", comment: "Country option for a site address.") - case .US: return NSLocalizedString("United States", comment: "Country option for a site address.") - case .UM: return NSLocalizedString("United States Minor Outlying Islands", comment: "Country option for a site address.") - case .VI: return NSLocalizedString("United States Virgin Islands", comment: "Country option for a site address.") - case .UY: return NSLocalizedString("Uruguay", comment: "Country option for a site address.") - case .UZ: return NSLocalizedString("Uzbekistan", comment: "Country option for a site address.") - - // V - case .VU: return NSLocalizedString("Vanuatu", comment: "Country option for a site address.") - case .VA: return NSLocalizedString("Vatican", comment: "Country option for a site address.") - case .VE: return NSLocalizedString("Venezuela", comment: "Country option for a site address.") - case .VN: return NSLocalizedString("Vietnam", comment: "Country option for a site address.") - - // W - case .WF: return NSLocalizedString("Wallis and Futuna", comment: "Country option for a site address.") - case .EH: return NSLocalizedString("Western Sahara", comment: "Country option for a site address.") - - // Y - case .YE: return NSLocalizedString("Yemen", comment: "Country option for a site address.") - - // Z - case .ZM: return NSLocalizedString("Zambia", comment: "Country option for a site address.") - case .ZW: return NSLocalizedString("Zimbabwe", comment: "Country option for a site address.") - - case .unknown: return NSLocalizedString("Unknown country", comment: "Fallback country option for a site address.") - } - } -} diff --git a/WooCommerce/Classes/ViewRelated/Orders/Collect Payments/CollectOrderPaymentUseCase.swift b/WooCommerce/Classes/ViewRelated/Orders/Collect Payments/CollectOrderPaymentUseCase.swift index 7886b3ab5e4..3fe21604238 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Collect Payments/CollectOrderPaymentUseCase.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Collect Payments/CollectOrderPaymentUseCase.swift @@ -919,58 +919,6 @@ enum CollectOrderPaymentUseCaseNotValidAmountError: Error, LocalizedError, Equat } } -enum CollectOrderPaymentUseCaseError: LocalizedError { - case flowCanceledByUser - case paymentGatewayNotFound - case orderTotalChanged - case couldNotRefreshOrder(Error) - case orderAlreadyPaid - - var errorDescription: String? { - switch self { - case .flowCanceledByUser: - return Localization.paymentCancelledLocalizedDescription - case .paymentGatewayNotFound: - return Localization.paymentGatewayNotFoundLocalizedDescription - case .orderTotalChanged: - return Localization.orderTotalChangedLocalizedDescription - case .couldNotRefreshOrder(let error as LocalizedError): - return error.errorDescription - case .couldNotRefreshOrder(let error): - return String.localizedStringWithFormat(Localization.couldNotRefreshOrderLocalizedDescription, error.localizedDescription) - case .orderAlreadyPaid: - return Localization.orderAlreadyPaidLocalizedDescription - } - } - - private enum Localization { - static let couldNotRefreshOrderLocalizedDescription = NSLocalizedString( - "Unable to process payment. We could not fetch the latest order details. Please check your network " + - "connection and try again. Underlying error: %1$@", - comment: "Error message when collecting an In-Person Payment and unable to update the order. %!$@ will " + - "be replaced with further error details.") - - static let orderTotalChangedLocalizedDescription = NSLocalizedString( - "collectOrderPaymentUseCase.error.message.orderTotalChanged", - value: "Order total has changed since the beginning of payment. Please go back and check the order is " + - "correct, then try the payment again.", - comment: "Error message when collecting an In-Person Payment and the order total has changed remotely.") - - static let orderAlreadyPaidLocalizedDescription = NSLocalizedString( - "Unable to process payment. This order is already paid, taking a further payment would result in the " + - "customer being charged twice for their order.", - comment: "Error message shown during In-Person Payments when the order is found to be paid after it's refreshed.") - - static let paymentGatewayNotFoundLocalizedDescription = NSLocalizedString( - "Unable to process payment. We could not connect to the payment system. Please contact support if this " + - "error continues.", - comment: "Error message shown during In-Person Payments when the payment gateway is not available.") - - static let paymentCancelledLocalizedDescription = NSLocalizedString( - "The payment was cancelled.", comment: "Message shown if a payment cancellation is shown as an error.") - } -} - enum CardPaymentRetryApproach { case reuseIntent case restart diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index 35dcc9f2288..5633e76991a 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -270,7 +270,6 @@ 0230B4D62C33454900F2F660 /* PointOfSaleCardPresentPaymentCaptureErrorMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0230B4D52C33454900F2F660 /* PointOfSaleCardPresentPaymentCaptureErrorMessageView.swift */; }; 0230B4D82C3345DF00F2F660 /* PointOfSaleCardPresentPaymentCaptureFailedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0230B4D72C3345DF00F2F660 /* PointOfSaleCardPresentPaymentCaptureFailedView.swift */; }; 02312797277D4F650060E180 /* StoreStatsPeriodViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02312796277D4F640060E180 /* StoreStatsPeriodViewModel.swift */; }; - 02335E492D13BA42000B6ECE /* AsyncPaginationTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02335E482D13BA42000B6ECE /* AsyncPaginationTracker.swift */; }; 023453F22579DA1A00A6BB20 /* ShippingLabelPrintingInstructionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023453F12579DA1A00A6BB20 /* ShippingLabelPrintingInstructionsViewController.swift */; }; 0234680A282CEA5F00CFC503 /* LegacyReceiptViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02346809282CEA5F00CFC503 /* LegacyReceiptViewModelTests.swift */; }; 0235595024496853004BE2B8 /* BottomSheetListSelectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0235594E24496853004BE2B8 /* BottomSheetListSelectorViewController.swift */; }; @@ -1646,7 +1645,6 @@ 68A38DF52B293B030090C263 /* MockProductListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A38DF42B293B030090C263 /* MockProductListViewModel.swift */; }; 68A5221B2BA1804900A6A584 /* PluginDetailsViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A5221A2BA1804900A6A584 /* PluginDetailsViewModelTests.swift */; }; 68A905012ACCFC13004C71D3 /* CollapsibleProductCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A905002ACCFC13004C71D3 /* CollapsibleProductCard.swift */; }; - 68AC9D292ACE598B0042F784 /* ProductImageThumbnail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68AC9D282ACE598B0042F784 /* ProductImageThumbnail.swift */; }; 68B3BA262D9147480000B2F2 /* AISettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B3BA252D9147440000B2F2 /* AISettingsView.swift */; }; 68B681162D9257810098D5CD /* PointOfSaleCouponsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B681152D92577F0098D5CD /* PointOfSaleCouponsController.swift */; }; 68B6F22B2ADE7ED500D171FC /* TooltipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68B6F22A2ADE7ED500D171FC /* TooltipView.swift */; }; @@ -2522,7 +2520,6 @@ D8736B5322EF4F5900A14A29 /* NotificationsBadgeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8736B5222EF4F5900A14A29 /* NotificationsBadgeController.swift */; }; D8736B5A22F07D7100A14A29 /* MainTabViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8736B5922F07D7100A14A29 /* MainTabViewModel.swift */; }; D8736B7522F1FE1600A14A29 /* BadgeLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8736B7422F1FE1600A14A29 /* BadgeLabel.swift */; }; - D8752EF7265E60F4008ACC80 /* PaymentCaptureCelebration.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8752EF6265E60F4008ACC80 /* PaymentCaptureCelebration.swift */; }; D88100D3257DD060008DE6F2 /* WordPressComSiteInfoWooTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D88100D2257DD060008DE6F2 /* WordPressComSiteInfoWooTests.swift */; }; D8815ADF26383EE700EDAD62 /* CardPresentPaymentsModalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8815ADD26383EE600EDAD62 /* CardPresentPaymentsModalViewController.swift */; }; D8815AE026383EE700EDAD62 /* CardPresentPaymentsModalViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D8815ADE26383EE700EDAD62 /* CardPresentPaymentsModalViewController.xib */; }; @@ -3486,7 +3483,6 @@ 0230B4D52C33454900F2F660 /* PointOfSaleCardPresentPaymentCaptureErrorMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointOfSaleCardPresentPaymentCaptureErrorMessageView.swift; sourceTree = ""; }; 0230B4D72C3345DF00F2F660 /* PointOfSaleCardPresentPaymentCaptureFailedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointOfSaleCardPresentPaymentCaptureFailedView.swift; sourceTree = ""; }; 02312796277D4F640060E180 /* StoreStatsPeriodViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreStatsPeriodViewModel.swift; sourceTree = ""; }; - 02335E482D13BA42000B6ECE /* AsyncPaginationTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncPaginationTracker.swift; sourceTree = ""; }; 023453F12579DA1A00A6BB20 /* ShippingLabelPrintingInstructionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelPrintingInstructionsViewController.swift; sourceTree = ""; }; 02346809282CEA5F00CFC503 /* LegacyReceiptViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyReceiptViewModelTests.swift; sourceTree = ""; }; 0235594E24496853004BE2B8 /* BottomSheetListSelectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomSheetListSelectorViewController.swift; sourceTree = ""; }; @@ -4846,7 +4842,6 @@ 68A38DF42B293B030090C263 /* MockProductListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockProductListViewModel.swift; sourceTree = ""; }; 68A5221A2BA1804900A6A584 /* PluginDetailsViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PluginDetailsViewModelTests.swift; sourceTree = ""; }; 68A905002ACCFC13004C71D3 /* CollapsibleProductCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollapsibleProductCard.swift; sourceTree = ""; }; - 68AC9D282ACE598B0042F784 /* ProductImageThumbnail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductImageThumbnail.swift; sourceTree = ""; }; 68B3BA252D9147440000B2F2 /* AISettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AISettingsView.swift; sourceTree = ""; }; 68B681152D92577F0098D5CD /* PointOfSaleCouponsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointOfSaleCouponsController.swift; sourceTree = ""; }; 68B6F22A2ADE7ED500D171FC /* TooltipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipView.swift; sourceTree = ""; }; @@ -5757,7 +5752,6 @@ D8736B5222EF4F5900A14A29 /* NotificationsBadgeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsBadgeController.swift; sourceTree = ""; }; D8736B5922F07D7100A14A29 /* MainTabViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabViewModel.swift; sourceTree = ""; }; D8736B7422F1FE1600A14A29 /* BadgeLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeLabel.swift; sourceTree = ""; }; - D8752EF6265E60F4008ACC80 /* PaymentCaptureCelebration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentCaptureCelebration.swift; sourceTree = ""; }; D88100D2257DD060008DE6F2 /* WordPressComSiteInfoWooTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressComSiteInfoWooTests.swift; sourceTree = ""; }; D8815ADD26383EE600EDAD62 /* CardPresentPaymentsModalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardPresentPaymentsModalViewController.swift; sourceTree = ""; }; D8815ADE26383EE700EDAD62 /* CardPresentPaymentsModalViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CardPresentPaymentsModalViewController.xib; sourceTree = ""; }; @@ -7653,7 +7647,6 @@ children = ( 02ECD1DE24FF48D000735BE5 /* PaginationTracker.swift */, 029700EB24FE38C900D242F8 /* ScrollWatcher.swift */, - 02335E482D13BA42000B6ECE /* AsyncPaginationTracker.swift */, ); path = InfiniteScroll; sourceTree = ""; @@ -13140,7 +13133,6 @@ 036CA6B8291E8D4B00E4DF4F /* CardPresentModalPreparingForPayment.swift */, 03BB9EA6292E50B600251E9E /* CardPresentModalSelectSearchType.swift */, D8EE9697264D3CCB0033B2F9 /* LegacyReceiptViewModel.swift */, - D8752EF6265E60F4008ACC80 /* PaymentCaptureCelebration.swift */, 03AA165D2719B7EF005CCB7B /* ReceiptActionCoordinator.swift */, 02C1853C27FF153A00ABD764 /* CardPresentRefundOrchestrator.swift */, ); @@ -16170,7 +16162,6 @@ 268D7C9C2984752A00D38709 /* SupportForm.swift in Sources */, 02A275BA23FE50AA005C560F /* ProductUIImageLoader.swift in Sources */, 02305353237454C700487A64 /* AztecInsertMoreFormatBarCommand.swift in Sources */, - 02335E492D13BA42000B6ECE /* AsyncPaginationTracker.swift in Sources */, B5D6DC54214802740003E48A /* SyncCoordinator.swift in Sources */, 205B7EBD2C19FB6600D14A36 /* PointOfSaleCardPresentPaymentFoundReaderAlertViewModel.swift in Sources */, 018D5C7E2CA6B4A60085EBEE /* CurrencySettings+Sanitized.swift in Sources */, @@ -16356,7 +16347,6 @@ 01FB19582C6E901800A44FF0 /* DynamicHStack.swift in Sources */, AEB73C0C25CD734200A8454A /* AttributePickerViewModel.swift in Sources */, 2005D3F32DC13D6900E12021 /* PointOfSaleItemListAnalyticsTracker.swift in Sources */, - D8752EF7265E60F4008ACC80 /* PaymentCaptureCelebration.swift in Sources */, B98BA12D2AE90023006F1E4A /* OrderCustomAmountsSection.swift in Sources */, 205B7EC72C19FCA700D14A36 /* PointOfSaleCardPresentPaymentPreparingForPaymentMessageViewModel.swift in Sources */, 26DDA4A92C4839B8005FBEBF /* DashboardTimestampStore.swift in Sources */, diff --git a/WooCommerce/WooCommerceTests/Mocks/PaymentCaptureCelebration.swift b/WooCommerce/WooCommerceTests/Mocks/PaymentCaptureCelebration.swift index 65051ac42ee..f5db2d02e6e 100644 --- a/WooCommerce/WooCommerceTests/Mocks/PaymentCaptureCelebration.swift +++ b/WooCommerce/WooCommerceTests/Mocks/PaymentCaptureCelebration.swift @@ -1,4 +1,5 @@ @testable import WooCommerce +import protocol Yosemite.PaymentCaptureCelebrationProtocol final class MockPaymentCaptureCelebration: PaymentCaptureCelebrationProtocol { private(set) var celebrationWasCalled: Bool = false