Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename BuiltInReader / LocalMobileReader references to TapToPay #15380

Merged
merged 5 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Foundation

public struct CardReaderConnectionOptions {
public let builtInOptions: BuiltInCardReaderConnectionOptions?
public let tapToPayOptions: TapToPayCardReaderConnectionOptions?

public init(builtInOptions: BuiltInCardReaderConnectionOptions?) {
self.builtInOptions = builtInOptions
public init(tapToPayOptions: TapToPayCardReaderConnectionOptions?) {
self.tapToPayOptions = tapToPayOptions
}
}

public struct BuiltInCardReaderConnectionOptions {
public struct TapToPayCardReaderConnectionOptions {
public let termsOfServiceAcceptancePermitted: Bool

public init(termsOfServiceAcceptancePermitted: Bool) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public enum CardReaderDiscoveryMethod {
case localMobile
case tapToPay
case bluetoothScan
}
2 changes: 1 addition & 1 deletion Hardware/Hardware/CardReader/CardReaderService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public protocol CardReaderService {
var softwareUpdateEvents: AnyPublisher<CardReaderSoftwareUpdateState, Never> { get }

/// The Publisher that emits when TTP Terms and Services are accepted
var builtInCardReaderAcceptToSEvents: AnyPublisher<Void, Never> { get }
var tapToPayCardReaderAcceptToSEvents: AnyPublisher<Void, Never> { get }

// MARK: - Commands

Expand Down
4 changes: 2 additions & 2 deletions Hardware/Hardware/CardReader/CardReaderType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public enum CardReaderType: String, CaseIterable {
/// BBPOS WisePad 3
case wisepad3
/// Tap on Mobile: Apple built in reader
case appleBuiltIn
case tapToPay
/// Other
case other
}
Expand All @@ -28,7 +28,7 @@ extension CardReaderType {
return "STRIPE_M2"
case .wisepad3:
return "WISEPAD_3"
case .appleBuiltIn:
case .tapToPay:
return "COTS_DEVICE"
default:
return "UNKNOWN"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Foundation
public extension CardReader {
var discoveryMethod: CardReaderDiscoveryMethod? {
switch readerType {
case .appleBuiltIn:
return .localMobile
case .tapToPay:
return .tapToPay
case .chipper, .stripeM2, .wisepad3:
return .bluetoothScan
case .other:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import StripeTerminal
public extension CardReaderDiscoveryMethod {
func toStripe() -> DiscoveryMethod {
switch self {
case .localMobile:
case .tapToPay:
return .tapToPay
case .bluetoothScan:
return .bluetoothScan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension CardReaderType {
case .wisePad3:
return .wisepad3
case .tapToPay:
return appleBuiltIn
return tapToPay
default:
return .other
}
Expand All @@ -28,7 +28,7 @@ extension CardReaderType {
return .stripeM2
case .wisepad3:
return .wisePad3
case .appleBuiltIn:
case .tapToPay:
return .tapToPay
case .other:
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct NoOpCardReaderService: CardReaderService {
= CurrentValueSubject<CardReaderSoftwareUpdateState, Never>(.none).eraseToAnyPublisher()

/// The Publisher that emits the when when TTP Terms and Services are accepted
public var builtInCardReaderAcceptToSEvents: AnyPublisher<Void, Never>
public var tapToPayCardReaderAcceptToSEvents: AnyPublisher<Void, Never>
= PassthroughSubject<Void, Never>().eraseToAnyPublisher()

public init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class StripeCardReaderService: NSObject {
private let discoveryStatusSubject = CurrentValueSubject<CardReaderServiceDiscoveryStatus, Never>(.idle)
private let readerEventsSubject = PassthroughSubject<CardReaderEvent, Never>()
private let softwareUpdateSubject = CurrentValueSubject<CardReaderSoftwareUpdateState, Never>(.none)
private let builtInCardReaderAcceptToSSubject = PassthroughSubject<Void, Never>()
private let tapToPayCardReaderAcceptToSSubject = PassthroughSubject<Void, Never>()

private var connectionAttemptInvalidated: Bool = false

Expand Down Expand Up @@ -64,8 +64,8 @@ extension StripeCardReaderService: CardReaderService {
softwareUpdateSubject.eraseToAnyPublisher()
}

public var builtInCardReaderAcceptToSEvents: AnyPublisher<Void, Never> {
builtInCardReaderAcceptToSSubject.eraseToAnyPublisher()
public var tapToPayCardReaderAcceptToSEvents: AnyPublisher<Void, Never> {
tapToPayCardReaderAcceptToSSubject.eraseToAnyPublisher()
}

// MARK: - CardReaderService conformance. Commands
Expand Down Expand Up @@ -141,7 +141,7 @@ extension StripeCardReaderService: CardReaderService {
DDLogError("\(error)")
throw error
}
case .localMobile:
case .tapToPay:
let tapToPayConfig = TapToPayDiscoveryConfigurationBuilder()
do {
config = try tapToPayConfig.setSimulated(shouldUseSimulatedCardReader).build()
Expand Down Expand Up @@ -452,7 +452,7 @@ extension StripeCardReaderService: CardReaderService {
connectionAttemptInvalidated = false
switch stripeReader.deviceType {
case .tapToPay:
return getLocalMobileConfiguration(stripeReader, options: options).flatMap { configuration in
return getTapToPayConfiguration(stripeReader, options: options).flatMap { configuration in
self.connect(stripeReader, configuration: configuration)
}
.share()
Expand Down Expand Up @@ -494,7 +494,7 @@ extension StripeCardReaderService: CardReaderService {
}
}

private func getLocalMobileConfiguration(_ reader: StripeTerminal.Reader,
private func getTapToPayConfiguration(_ reader: StripeTerminal.Reader,
options: CardReaderConnectionOptions?) -> Future<TapToPayConnectionConfiguration, Error> {
return Future() { [weak self] promise in
guard let self = self else {
Expand All @@ -507,12 +507,12 @@ extension StripeCardReaderService: CardReaderService {
self.readerLocationProvider?.fetchDefaultLocationID { result in
switch result {
case .success(let locationId):
let localMobileConfig = TapToPayConnectionConfigurationBuilder(delegate: self, locationId: locationId)
localMobileConfig.setMerchantDisplayName(nil)
localMobileConfig.setOnBehalfOf(nil)
localMobileConfig.setTosAcceptancePermitted(options?.builtInOptions?.termsOfServiceAcceptancePermitted ?? true)
let tapToPayConfig = TapToPayConnectionConfigurationBuilder(delegate: self, locationId: locationId)
tapToPayConfig.setMerchantDisplayName(nil)
tapToPayConfig.setOnBehalfOf(nil)
tapToPayConfig.setTosAcceptancePermitted(options?.tapToPayOptions?.termsOfServiceAcceptancePermitted ?? true)
do {
let config = try localMobileConfig.build()
let config = try tapToPayConfig.build()
return promise(.success(config))
} catch {
let underlyingError = Self.logAndDecodeError(error)
Expand Down Expand Up @@ -1005,7 +1005,7 @@ extension StripeCardReaderService: TapToPayReaderDelegate {
}

public func tapToPayReaderDidAcceptTermsOfService(_ reader: Reader) {
builtInCardReaderAcceptToSSubject.send(())
tapToPayCardReaderAcceptToSSubject.send(())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ extension UnderlyingError {
case .passcodeNotEnabled:
self = .passcodeNotEnabled
case .tapToPayReaderTOSAcceptanceRequiresiCloudSignIn:
self = .appleBuiltInReaderTOSAcceptanceRequiresiCloudSignIn
self = .tapToPayReaderTOSAcceptanceRequiresiCloudSignIn
case .nfcDisabled:
self = .nfcDisabled
case .tapToPayReaderFailedToPrepare:
self = .appleBuiltInReaderFailedToPrepare
self = .tapToPayReaderFailedToPrepare
case .tapToPayReaderTOSAcceptanceCanceled:
self = .appleBuiltInReaderTOSAcceptanceCanceled
self = .tapToPayReaderTOSAcceptanceCanceled
case .tapToPayReaderTOSNotYetAccepted:
self = .appleBuiltInReaderTOSNotYetAccepted
self = .tapToPayReaderTOSNotYetAccepted
case .tapToPayReaderTOSAcceptanceFailed:
self = .appleBuiltInReaderTOSAcceptanceFailed
self = .tapToPayReaderTOSAcceptanceFailed
case .tapToPayReaderMerchantBlocked:
self = .appleBuiltInReaderMerchantBlocked
self = .tapToPayReaderMerchantBlocked
case .tapToPayReaderInvalidMerchant:
self = .appleBuiltInReaderInvalidMerchant
self = .tapToPayReaderInvalidMerchant
case .tapToPayReaderDeviceBanned:
self = .appleBuiltInReaderDeviceBanned
self = .tapToPayReaderDeviceBanned
case .unsupportedMobileDeviceConfiguration:
self = .unsupportedMobileDeviceConfiguration
case .readerNotAccessibleInBackground:
Expand Down Expand Up @@ -171,7 +171,7 @@ extension UnderlyingError {
case .bluetoothReconnectStarted:
self = .bluetoothReconnectStarted
case .tapToPayReaderAccountDeactivated:
self = .appleBuiltInReaderAccountDeactivated
self = .tapToPayReaderAccountDeactivated
case .readerMissingEncryptionKeys:
self = .readerMissingEncryptionKeys
case .unexpectedReaderError:
Expand Down
48 changes: 24 additions & 24 deletions Hardware/Hardware/CardReader/UnderlyingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,41 +161,41 @@ public enum UnderlyingError: Error, Equatable {

/// The phone must have a signed-in iCloud account in order to accept the TOS for the built in reader.
/// The signed-in account does not need to be the one used to connect the reader.
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderTOSAcceptanceRequiresiCloudSignIn
case appleBuiltInReaderTOSAcceptanceRequiresiCloudSignIn
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderTOSAcceptanceRequiresiCloudSignIn
case tapToPayReaderTOSAcceptanceRequiresiCloudSignIn

/// NFC is disabled on the device. This could be a permissions issue, in particular due to a device management profile.
/// It's unlikely that the user can directly correct this issue
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorNFCDisabled
case nfcDisabled

/// Preparing Tap to Pay on iPhone failed. This is a retriable error
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderFailedToPrepare
case appleBuiltInReaderFailedToPrepare
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderFailedToPrepare
case tapToPayReaderFailedToPrepare

/// The user cancelled Tap to Pay on iPhone Terms of Service acceptance
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderTOSAcceptanceCanceled
case appleBuiltInReaderTOSAcceptanceCanceled
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderTOSAcceptanceCanceled
case tapToPayReaderTOSAcceptanceCanceled

/// Tap to Pay on iPhone Terms of Service have not been accepted. This error is retriable
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderTOSNotYetAccepted
case appleBuiltInReaderTOSNotYetAccepted
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderTOSNotYetAccepted
case tapToPayReaderTOSNotYetAccepted

/// Tap to Pay on iPhone Terms of Service could not be accepted. This may indicate an issue with the Apple ID used.
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderTOSAcceptanceFailed
case appleBuiltInReaderTOSAcceptanceFailed
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderTOSAcceptanceFailed
case tapToPayReaderTOSAcceptanceFailed

/// This (Stripe) merchant account cannot be used with Tap to Pay on iPhone as it has been blocked
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderMerchantBlocked
case appleBuiltInReaderMerchantBlocked
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderMerchantBlocked
case tapToPayReaderMerchantBlocked

/// The merchant account is invalid and cannot be used with Tap to Pay on iPhone
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderInvalidMerchant
case appleBuiltInReaderInvalidMerchant
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderInvalidMerchant
case tapToPayReaderInvalidMerchant

/// Tap to Pay on iPhone on this device cannot be used because it has been banned
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorAppleBuiltInReaderDeviceBanned
case appleBuiltInReaderDeviceBanned
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderDeviceBanned
case tapToPayReaderDeviceBanned

/// The device does not meet the minimum requirements for using Tap to Pay on iPhone
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorUnsupportedMobileDeviceConfiguration
Expand Down Expand Up @@ -317,7 +317,7 @@ public enum UnderlyingError: Error, Equatable {

/// The Apple built-in reader account is deactivated.
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorTapToPayReaderAccountDeactivated
case appleBuiltInReaderAccountDeactivated
case tapToPayReaderAccountDeactivated

/// The reader is missing encryption keys.
/// https://stripe.dev/stripe-terminal-ios/docs/Enums/SCPError.html#/c:@E@SCPError@SCPErrorReaderMissingEncryptionKeys
Expand Down Expand Up @@ -629,7 +629,7 @@ extension UnderlyingError: LocalizedError {
comment: "Error message shown when Tap to Pay on iPhone cannot be used because " +
"the device does not have a passcode set.")

case .appleBuiltInReaderTOSAcceptanceRequiresiCloudSignIn:
case .tapToPayReaderTOSAcceptanceRequiresiCloudSignIn:
return NSLocalizedString("Please sign in to iCloud on this device to use Tap to Pay on iPhone.",
comment: "Error message shown when Tap to Pay on iPhone cannot be used because " +
"the device is not signed in to iCloud.")
Expand All @@ -640,25 +640,25 @@ extension UnderlyingError: LocalizedError {
comment: "Error message shown when Tap to Pay on iPhone cannot be used because " +
"the device's NFC chipset has been disabled by a device management policy.")

case .appleBuiltInReaderFailedToPrepare, .readerNotAccessibleInBackground:
case .tapToPayReaderFailedToPrepare, .readerNotAccessibleInBackground:
return NSLocalizedString("There was an issue preparing to use Tap to Pay on iPhone – please try again.",
comment: "Error message shown when Tap to Pay on iPhone cannot be used because " +
"there was some issue with the connection. Retryable.")

case .appleBuiltInReaderTOSAcceptanceCanceled, .appleBuiltInReaderTOSNotYetAccepted:
case .tapToPayReaderTOSAcceptanceCanceled, .tapToPayReaderTOSNotYetAccepted:
return NSLocalizedString("Please try again, and accept Apple's Terms of Service, so you can use Tap to " +
"Pay on iPhone.",
comment: "Error message shown when Tap to Pay on iPhone cannot be used because " +
"the merchant cancelled or did not complete the Terms of Service acceptance flow")

case .appleBuiltInReaderTOSAcceptanceFailed:
case .tapToPayReaderTOSAcceptanceFailed:
return NSLocalizedString("Please check your Apple ID is valid, and then try again. A valid Apple ID is " +
"required to accept Apple's Terms of Service.",
comment: "Error message shown when Tap to Pay on iPhone cannot be used because " +
"the Terms of Service acceptance flow failed, possibly due to issues with " +
"the Apple ID")

case .appleBuiltInReaderMerchantBlocked, .appleBuiltInReaderInvalidMerchant, .appleBuiltInReaderDeviceBanned:
case .tapToPayReaderMerchantBlocked, .tapToPayReaderInvalidMerchant, .tapToPayReaderDeviceBanned:
return NSLocalizedString("Please contact support – there was an issue starting Tap to Pay on iPhone",
comment: "Error message shown when Tap to Pay on iPhone cannot be used because " +
"there is an issue with the merchant account or device.")
Expand Down Expand Up @@ -861,9 +861,9 @@ extension UnderlyingError: LocalizedError {
comment: "Error message when Bluetooth reconnect has started."
)

case .appleBuiltInReaderAccountDeactivated:
case .tapToPayReaderAccountDeactivated:
return NSLocalizedString(
"hardware.cardReader.underlyingError.appleBuiltInReaderAccountDeactivated",
"hardware.cardReader.underlyingError.tapToPayReaderAccountDeactivated",
value: "The linked Apple ID account has been deactivated.",
comment: "Error message when the Apple built-in reader account is deactivated."
)
Expand Down
Loading