import type { Location, LocationStatus } from './'; import type { StripeError } from './StripeError'; export namespace Reader { export type DiscoveryMethod = IOS.DiscoveryMethod | Android.DiscoveryMethod; export type Type = Partial & Partial & { id?: string; label?: string; batteryLevel?: number; isCharging?: boolean; serialNumber?: string; locationId?: string; deviceSoftwareVersion?: string; simulated?: boolean; availableUpdate?: SoftwareUpdate; ipAddress?: string; livemode?: boolean; locationStatus: LocationStatus; location?: Location; deviceType: DeviceType; status: NetworkStatus; }; export namespace IOS { export type Type = { batteryStatus: BatteryStatus; }; /** * Supported DiscoveryMethod for discovering devices. * * @remarks * USB is in private preview for iPads with M-series chips. Contact Stripe support to join the preview if interested. */ export type DiscoveryMethod = | 'bluetoothProximity' | 'bluetoothScan' | 'internet' | 'tapToPay' | 'usb'; } export namespace Android { export type Type = { baseUrl?: string; bootloaderVersion?: string; configVersion?: string; emvKeyProfileId?: string; firmwareVersion?: string; hardwareVersion?: string; macKeyProfileId?: string; pinKeyProfileId?: string; trackKeyProfileId?: string; settingsVersion?: string; pinKeysetId?: string; }; export type DiscoveryMethod = | 'bluetoothScan' | 'internet' | 'tapToPay' | 'appsOnDevices' | 'usb'; } export type BatteryStatus = 'critical' | 'low' | 'nominal' | 'unknown'; export type BatteryLevel = { batteryLevel: number; batteryStatus: BatteryStatus; isCharging: boolean; }; export type NetworkStatus = 'offline' | 'online' | 'unknown'; export type SoftwareUpdate = { deviceSoftwareVersion: string; estimatedUpdateTime: EstimatedUpdateTime; requiredAt: string; /** The update components (firmware, config, keys, incremental) included in this update. */ components: UpdateComponent[]; /** Whether the SDK generated this update for a sandbox or test-mode connection. */ isTestUpdate: boolean; }; export type TapToPayUpdateRequirement = | { type: 'operatingSystem'; apiLevel: number; requiredAt: string; } | { type: 'securityPatch' | 'terminalSdk'; version: string; requiredAt: string; }; export type EstimatedUpdateTime = | 'estimate1To2Minutes' | 'estimate2To5Minutes' | 'estimate5To15Minutes' | 'estimateLessThan1Minute'; export type DeviceType = | 'chipper1X' | 'chipper2X' | 'cotsDevice' | 'etna' | 'stripeM2' | 'stripeS700' | 'stripeS700Devkit' | 'stripeS710' | 'stripeS710Devkit' | 'stripeT600' | 'stripeT600Devkit' | 'stripeT610' | 'stripeT610Devkit' | 'stripeU200' | 'tapToPay' | 'unknown' | 'verifoneM425' | 'verifoneM450' | 'verifoneP630' | 'verifoneUX700' | 'verifoneUX700Devkit' | 'verifoneV660p' | 'verifoneV660pA' | 'verifoneV660pDevkit' | 'verifoneVL110' | 'verifoneVM100' | 'verifoneVM110' | 'verifoneVP100' | 'verifoneVP110' | 'wiseCube' | 'wisePad3' | 'wisePad3s' | 'wisePosE' | 'wisePosEDevkit'; export type InputOptions = 'insertCard' | 'swipeCard' | 'tapCard'; export type DisplayMessage = | 'insertCard' | 'insertOrSwipeCard' | 'multipleContactlessCardsDetected' | 'removeCard' | 'retryCard' | 'swipeCard' | 'tryAnotherCard' | 'tryAnotherReadMethod' | 'checkMobileDevice' | 'cardRemovedTooEarly'; export type DisconnectReason = | 'disconnectRequested' | 'rebootRequested' | 'securityReboot' | 'criticallyLowBattery' | 'poweredOff' | 'bluetoothDisabled' | 'bluetoothSignalLost' | 'peerRemovedPairingInformation' | 'usbDisconnected' | 'idlePowerDown' | 'unknown'; export type ReaderSettings = | { accessibility: Accessibility; buzzerVolume: ReaderBuzzerVolume; error?: undefined; } | { accessibility?: undefined; buzzerVolume?: undefined; error: StripeError; }; export type Accessibility = | { textToSpeechStatus: ReaderTextToSpeechStatus; error?: undefined; } | { textToSpeechStatus?: undefined; error: StripeError; }; export type ReaderTextToSpeechStatus = 'off' | 'headphones' | 'speakers'; /** The current buzzer volume reported by a supported reader. */ export type ReaderBuzzerVolume = | { currentVolume: number; maxVolume: number; error?: undefined; } | { currentVolume?: undefined; maxVolume?: undefined; error: StripeError; }; /** Parameters for setting a reader's buzzer volume. */ export type BuzzerVolumeParameters = | { level: 'low' | 'high'; volume?: never; } | { level: 'custom'; /** A volume between 1 and `ReaderBuzzerVolume.maxVolume`. */ volume: number; }; /** Parameters for updating a reader's accessibility settings. */ export type AccessibilityReaderSettingsParameters = { textToSpeechViaSpeakers: boolean; buzzerVolume?: never; }; /** Parameters for updating a reader's buzzer volume. */ export type BuzzerVolumeReaderSettingsParameters = { textToSpeechViaSpeakers?: never; buzzerVolume: BuzzerVolumeParameters; }; /** * Parameters accepted by `setReaderSettings`. * * Provide exactly one setting category per call. */ export type ReaderSettingsParameters = | AccessibilityReaderSettingsParameters | BuzzerVolumeReaderSettingsParameters; export type ReaderSupportParams = { deviceType: DeviceType; simulated?: boolean; discoveryMethod: Reader.DiscoveryMethod; }; /** * Native reports `true` without an error when the reader type is supported, * and `false` with an error when it is not supported. RN validation or bridge * failures can occur before native reports the boolean, so it remains * optional on the error branch. */ export type ReaderSupportResult = | { readerSupportResult: true; error?: undefined; } | { readerSupportResult?: false; error: StripeError }; } /** The component types that can be included in a reader software update. */ export enum UpdateComponent { FIRMWARE = 'firmware', CONFIG = 'config', KEYS = 'keys', INCREMENTAL = 'incremental', } /** * Configures a simulated reader update for testing purposes. Pass as * `testReaderUpdate` on connection params to exercise update flows in * test mode on both simulated and physical readers. * * - `available` — An optional update is available and will be announced * during connect. * - `required` — A required update will be performed during connect. * - `requiredOffline` — A required update exists. When connecting * offline, connection will fail because the reader's version is not * allowed. When connecting online, the reader will update and connect * normally. * - `lowBattery` — A required update exists but the reader's battery is * too low for the update to begin. The connection will fail. * - `lowBatterySucceedConnect` — A required update exists but the * reader's battery is too low for the update to begin. The update will * fail but connection succeeds because the reader is on a recent * software version. * - `random` — Randomly selects a concrete update scenario to exercise * various states, or no update being available. */ export type TestReaderUpdate = | { type: 'available'; components: UpdateComponent[] } | { type: 'required'; components: UpdateComponent[] } | { type: 'requiredOffline'; components: UpdateComponent[] } | { type: 'lowBattery' } | { type: 'lowBatterySucceedConnect' } | { type: 'random' };