From 65eb3f67cf133b4c73f483508c4beb66f1b0584e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=8A=E5=8E=9F=E6=98=8C=E5=BD=A6?= Date: Sun, 11 Aug 2024 22:55:24 +0900 Subject: [PATCH] fmt --- .../stripe/terminal/StripeTerminal.java | 57 ++++--- .../stripe/terminal/StripeTerminalPlugin.java | 2 - .../terminal/ios/Plugin/StripeTerminal.swift | 59 ++++--- .../ios/Plugin/StripeTerminalPlugin.swift | 2 +- packages/terminal/src/definitions.ts | 110 ++++++++----- packages/terminal/src/stripe.enum.ts | 150 +++++++++--------- packages/terminal/src/web.ts | 2 +- 7 files changed, 206 insertions(+), 176 deletions(-) diff --git a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.java b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.java index 4d19edfa..b4f3acf3 100644 --- a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.java +++ b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminal.java @@ -104,12 +104,18 @@ public void initialize(final PluginCall call) throws TerminalException { TerminalListener listener = new TerminalListener() { @Override public void onUnexpectedReaderDisconnect(@NonNull Reader reader) { - notifyListeners(TerminalEnumEvent.UnexpectedReaderDisconnect.getWebEventName(), new JSObject().put("reader", convertReaderInterface(reader))); + notifyListeners( + TerminalEnumEvent.UnexpectedReaderDisconnect.getWebEventName(), + new JSObject().put("reader", convertReaderInterface(reader)) + ); } @Override public void onConnectionStatusChange(@NonNull ConnectionStatus status) { - notifyListeners(TerminalEnumEvent.ConnectionStatusChange.getWebEventName(), new JSObject().put("status", status.toString())); + notifyListeners( + TerminalEnumEvent.ConnectionStatusChange.getWebEventName(), + new JSObject().put("status", status.toString()) + ); } @Override @@ -132,11 +138,15 @@ public void setConnectionToken(PluginCall call) { public void setSimulatorConfiguration(PluginCall call) { try { - Terminal.getInstance().setSimulatorConfiguration(new SimulatorConfiguration( - SimulateReaderUpdate.valueOf(call.getString("update", "UPDATE_AVAILABLE")), - new SimulatedCard(SimulatedCardType.valueOf(call.getString("simulatedCard", "VISA"))), - call.getLong("simulatedTipAmount", null) - )); + Terminal + .getInstance() + .setSimulatorConfiguration( + new SimulatorConfiguration( + SimulateReaderUpdate.valueOf(call.getString("update", "UPDATE_AVAILABLE")), + new SimulatedCard(SimulatedCardType.valueOf(call.getString("simulatedCard", "VISA"))), + call.getLong("simulatedTipAmount", null) + ) + ); call.resolve(); } catch (Exception ex) { @@ -466,7 +476,10 @@ private ReaderListener readerListener() { @Override public void onStartInstallingUpdate(@NotNull ReaderSoftwareUpdate update, @NotNull Cancelable cancelable) { // Show UI communicating that a required update has started installing - notifyListeners(TerminalEnumEvent.StartInstallingUpdate.getWebEventName(), new JSObject().put("update", convertReaderSoftwareUpdate(update))); + notifyListeners( + TerminalEnumEvent.StartInstallingUpdate.getWebEventName(), + new JSObject().put("update", convertReaderSoftwareUpdate(update)) + ); } @Override @@ -492,11 +505,10 @@ public void onFinishInstallingUpdate(@Nullable ReaderSoftwareUpdate update, @Nul @Override public void onBatteryLevelUpdate(float batteryLevel, @NonNull BatteryStatus batteryStatus, boolean isCharging) { - notifyListeners(TerminalEnumEvent.BatteryLevel.getWebEventName(), new JSObject() - .put("level", batteryLevel) - .put("charging", isCharging) - .put("status", batteryStatus.toString() - )); + notifyListeners( + TerminalEnumEvent.BatteryLevel.getWebEventName(), + new JSObject().put("level", batteryLevel).put("charging", isCharging).put("status", batteryStatus.toString()) + ); } @Override @@ -515,9 +527,9 @@ public void onReportReaderEvent(@NotNull ReaderEvent event) { @Override public void onRequestReaderDisplayMessage(@NotNull ReaderDisplayMessage message) { - notifyListeners(TerminalEnumEvent.RequestDisplayMessage.getWebEventName(), new JSObject() - .put("messageType", message.name()) - .put("message", message.toString()) + notifyListeners( + TerminalEnumEvent.RequestDisplayMessage.getWebEventName(), + new JSObject().put("messageType", message.name()).put("message", message.toString()) ); } @@ -529,23 +541,20 @@ public void onRequestReaderInput(@NotNull ReaderInputOptions options) { jsOptions.put(optionType.name()); } - notifyListeners(TerminalEnumEvent.RequestReaderInput.getWebEventName(), new JSObject() - .put("options", jsOptions) - .put("message", options.toString()) + notifyListeners( + TerminalEnumEvent.RequestReaderInput.getWebEventName(), + new JSObject().put("options", jsOptions).put("message", options.toString()) ); } public void onDisconnect(@NotNull DisconnectReason reason) { - notifyListeners(TerminalEnumEvent.DisconnectedReader.getWebEventName(), new JSObject() - .put("reason", reason.toString()) - ); + notifyListeners(TerminalEnumEvent.DisconnectedReader.getWebEventName(), new JSObject().put("reason", reason.toString())); } }; } private JSObject convertReaderInterface(Reader reader) { - return new JSObject() - .put("serialNumber", reader.getSerialNumber()); + return new JSObject().put("serialNumber", reader.getSerialNumber()); } private JSObject convertReaderSoftwareUpdate(ReaderSoftwareUpdate update) { diff --git a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminalPlugin.java b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminalPlugin.java index 969ad781..e52cd7a9 100644 --- a/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminalPlugin.java +++ b/packages/terminal/android/src/main/java/com/getcapacitor/community/stripe/terminal/StripeTerminalPlugin.java @@ -3,7 +3,6 @@ import android.Manifest; import android.os.Build; import android.util.Log; - import androidx.annotation.RequiresApi; import com.getcapacitor.PermissionState; import com.getcapacitor.Plugin; @@ -13,7 +12,6 @@ import com.getcapacitor.annotation.Permission; import com.getcapacitor.annotation.PermissionCallback; import com.stripe.stripeterminal.external.models.TerminalException; - import java.util.Objects; @RequiresApi(api = Build.VERSION_CODES.S) diff --git a/packages/terminal/ios/Plugin/StripeTerminal.swift b/packages/terminal/ios/Plugin/StripeTerminal.swift index 81cd6db7..429af046 100644 --- a/packages/terminal/ios/Plugin/StripeTerminal.swift +++ b/packages/terminal/ios/Plugin/StripeTerminal.swift @@ -239,17 +239,17 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg call.reject("PaymentIntent not found for confirmPaymentIntent. Use collect method first and try again.") } } - + public func setSimulatorConfiguration(_ call: CAPPluginCall) { // { update?: SimulateReaderUpdate; simulatedCard?: SimulatedCardType; simulatedTipAmount?: number; } Terminal.shared.simulatorConfiguration.availableReaderUpdate = self.mapToSimulateReaderUpdate(call.getString("update", "UPDATE_AVAILABLE")) - Terminal.shared.simulatorConfiguration.simulatedCard = SimulatedCard(type: SimulatedCardType(rawValue: self.mapToCardType(type: call.getString("simulatedCard", "VISA")))!); + Terminal.shared.simulatorConfiguration.simulatedCard = SimulatedCard(type: SimulatedCardType(rawValue: self.mapToCardType(type: call.getString("simulatedCard", "VISA")))!) if let tipAmount = call.getInt("simulatedTipAmount") { - Terminal.shared.simulatorConfiguration.simulatedTipAmount = (tipAmount) as NSNumber; + Terminal.shared.simulatorConfiguration.simulatedTipAmount = (tipAmount) as NSNumber } call.resolve([:]) } - + private func mapToSimulateReaderUpdate(_ update: String) -> SimulateReaderUpdate { switch update { case "UpdateAvailable": return SimulateReaderUpdate.available @@ -261,7 +261,7 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg default: return SimulateReaderUpdate.none } } - + private func mapToCardType(type: String) -> UInt { switch type { case "VISA": return 0 @@ -296,20 +296,20 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg return 0 } } - + /* * Terminal */ public func terminal(_ terminal: Terminal, didChangePaymentStatus status: PaymentStatus) { self.plugin?.notifyListeners(TerminalEvents.PaymentStatusChange.rawValue, data: ["status": status.rawValue]) } - + public func terminal(_ terminal: Terminal, didChangeConnectionStatus status: ConnectionStatus) { self.plugin?.notifyListeners(TerminalEvents.ConnectionStatusChange.rawValue, data: ["status": status.rawValue]) } - + public func terminal(_ terminal: Terminal, didReportUnexpectedReaderDisconnect reader: Reader) { - self.plugin?.notifyListeners(TerminalEvents.UnexpectedReaderDisconnect.rawValue, data: ["reader":self.convertReaderInterface(reader: reader)]) + self.plugin?.notifyListeners(TerminalEvents.UnexpectedReaderDisconnect.rawValue, data: ["reader": self.convertReaderInterface(reader: reader)]) } /* @@ -325,14 +325,14 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg } public func localMobileReader(_ reader: Reader, didFinishInstallingUpdate update: ReaderSoftwareUpdate?, error: Error?) { - if ((error) != nil) { + if (error) != nil { self.plugin?.notifyListeners(TerminalEvents.FinishInstallingUpdate.rawValue, data: [ - "error": error!.localizedDescription, + "error": error!.localizedDescription ]) - return; + return } self.plugin?.notifyListeners(TerminalEvents.FinishInstallingUpdate.rawValue, data: [ - "update":self.convertReaderSoftwareUpdate(update: update!) + "update": self.convertReaderSoftwareUpdate(update: update!) ]) } @@ -348,18 +348,17 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg if inputOptions.contains(.tapCard) { readersJSObject.append(String(ReaderInputOptions.tapCard.rawValue)) } - + self.plugin?.notifyListeners(TerminalEvents.RequestReaderInput.rawValue, data: ["options": [:], "message": inputOptions.rawValue]) } public func localMobileReader(_ reader: Reader, didRequestReaderDisplayMessage displayMessage: ReaderDisplayMessage) { self.plugin?.notifyListeners(TerminalEvents.RequestDisplayMessage.rawValue, data: [ "messageType": displayMessage.rawValue, - "message": displayMessage.rawValue, + "message": displayMessage.rawValue ]) } - /* * bluetooth */ @@ -377,14 +376,14 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg } public func reader(_: Reader, didFinishInstallingUpdate update: ReaderSoftwareUpdate?, error: Error?) { - if ((error) != nil) { + if (error) != nil { self.plugin?.notifyListeners(TerminalEvents.FinishInstallingUpdate.rawValue, data: [ - "error": error!.localizedDescription, + "error": error!.localizedDescription ]) - return; + return } self.plugin?.notifyListeners(TerminalEvents.FinishInstallingUpdate.rawValue, data: [ - "update":self.convertReaderSoftwareUpdate(update: update!) + "update": self.convertReaderSoftwareUpdate(update: update!) ]) } @@ -400,17 +399,17 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg if inputOptions.contains(.tapCard) { readersJSObject.append(String(ReaderInputOptions.tapCard.rawValue)) } - + self.plugin?.notifyListeners(TerminalEvents.RequestReaderInput.rawValue, data: ["options": readersJSObject, "message": inputOptions.rawValue]) } public func reader(_: Reader, didRequestReaderDisplayMessage displayMessage: ReaderDisplayMessage) { self.plugin?.notifyListeners(TerminalEvents.RequestDisplayMessage.rawValue, data: [ "messageType": displayMessage.rawValue, - "message": displayMessage.rawValue, + "message": displayMessage.rawValue ]) } - + public func reader(_ reader: Reader, didReportBatteryLevel batteryLevel: Float, status: BatteryStatus, isCharging: Bool) { self.plugin?.notifyListeners(TerminalEvents.BatteryLevel.rawValue, data: [ "level": batteryLevel, @@ -418,15 +417,15 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg "status": status.rawValue ]) } - - public func reader(_ reader: Reader, didReportReaderEvent event: ReaderEvent, info: [AnyHashable : Any]?) { + + public func reader(_ reader: Reader, didReportReaderEvent event: ReaderEvent, info: [AnyHashable: Any]?) { self.plugin?.notifyListeners(TerminalEvents.ReaderEvent.rawValue, data: [ - "event": event.rawValue, + "event": event.rawValue ]) } - + private func convertReaderInterface(reader: Reader) -> [String: String] { - return ["serialNumber": reader.serialNumber]; + return ["serialNumber": reader.serialNumber] } private func convertReaderSoftwareUpdate(update: ReaderSoftwareUpdate) -> [String: String] { @@ -434,8 +433,8 @@ public class StripeTerminal: NSObject, DiscoveryDelegate, LocalMobileReaderDeleg "version": update.deviceSoftwareVersion, "settingsVersion": update.deviceSoftwareVersion, "requiredAt": update.requiredAt.description, - "timeEstimate": String(update.estimatedUpdateTime.rawValue), - ]; + "timeEstimate": String(update.estimatedUpdateTime.rawValue) + ] } } diff --git a/packages/terminal/ios/Plugin/StripeTerminalPlugin.swift b/packages/terminal/ios/Plugin/StripeTerminalPlugin.swift index dd004b96..32822010 100644 --- a/packages/terminal/ios/Plugin/StripeTerminalPlugin.swift +++ b/packages/terminal/ios/Plugin/StripeTerminalPlugin.swift @@ -32,7 +32,7 @@ public class StripeTerminalPlugin: CAPPlugin { call.reject("discoverReaders throw error.") } } - + @objc func setSimulatorConfiguration(_ call: CAPPluginCall) { self.implementation.setSimulatorConfiguration(call) } diff --git a/packages/terminal/src/definitions.ts b/packages/terminal/src/definitions.ts index 943b4b65..c0028dcf 100644 --- a/packages/terminal/src/definitions.ts +++ b/packages/terminal/src/definitions.ts @@ -45,9 +45,9 @@ export interface StripeTerminalPlugin { * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-simulator-configuration/index.html) */ setSimulatorConfiguration(options: { - update?: SimulateReaderUpdate, - simulatedCard?: SimulatedCardType, - simulatedTipAmount?: number, + update?: SimulateReaderUpdate; + simulatedCard?: SimulatedCardType; + simulatedTipAmount?: number; }): Promise; connectReader(options: { reader: ReaderInterface }): Promise; getConnectedReader(): Promise<{ reader: ReaderInterface | null }>; @@ -80,12 +80,12 @@ export interface StripeTerminalPlugin { /** * Emitted when the reader is disconnected, either in response to [`disconnectReader()`](#disconnectreader) * or some connection error. - * + * * For all reader types, this is emitted in response to [`disconnectReader()`](#disconnectreader) * without a `reason` property. - * + * * For Bluetooth and USB readers, this is emitted with a `reason` property when the reader disconnects. - * + * * **Note:** For Bluetooth and USB readers, when you call [`disconnectReader()`](#disconnectreader), this event * will be emitted twice: one without a `reason` in acknowledgement of your call, and again with a `reason` when the reader * finishes disconnecting. @@ -97,13 +97,13 @@ export interface StripeTerminalPlugin { /** * Emitted when the Terminal's connection status changed. - * + * * Note: You should *not* use this method to detect when a reader unexpectedly disconnects from your app, * as it cannot be used to accurately distinguish between expected and unexpected disconnect events. - * + * * To detect unexpected disconnects (e.g. to automatically notify your user), you should instead use * the UnexpectedReaderDisconnect event. - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-terminal-listener/on-connection-status-change.html) */ addListener( @@ -113,15 +113,15 @@ export interface StripeTerminalPlugin { /** * The Terminal disconnected unexpectedly from the reader. - * + * * In your implementation of this method, you may want to notify your user that the reader disconnected. * You may also call [`discoverReaders()`](#discoverreaders) to begin scanning for readers, and attempt * to automatically reconnect to the disconnected reader. Be sure to either set a timeout or make it * possible to cancel calls to `discoverReaders()` - * + * * When connected to a Bluetooth or USB reader, you can get more information about the disconnect by * implementing the DisconnectedReader event. - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-terminal-listener/on-unexpected-reader-disconnect.html) */ addListener( @@ -159,35 +159,39 @@ export interface StripeTerminalPlugin { /** * **Only applicable to Bluetooth and USB readers.** - * + * * Emitted when the connected reader begins installing a software update. * If a mandatory software update is available when a reader first connects, that update is * automatically installed. The update will be installed before ConnectedReader is emitted and * before the Promise returned by [`connectReader()`](#connectreader) resolves. * In this case, you will receive this sequence of events: - * + * * 1. StartInstallingUpdate * 2. ReaderSoftwareUpdateProgress (repeatedly) * 3. FinishInstallingUpdates * 4. ConnectedReader * 5. `connectReader()` Promise resolves - * + * * Your app should show UI to the user indiciating that a software update is being installed * to explain why connecting is taking longer than usual. - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-listener/on-start-installing-update.html) */ addListener( eventName: TerminalEventsEnum.StartInstallingUpdate, - listenerFunc: ({ update }: { update: ReaderSoftwareUpdateInterface }) => void, + listenerFunc: ({ + update, + }: { + update: ReaderSoftwareUpdateInterface; + }) => void, ): Promise; /** * **Only applicable to Bluetooth and USB readers.** - * + * * Emitted periodically while reader software is updating to inform of the installation progress. * `progress` is a float between 0 and 1. - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-listener/on-report-reader-software-update-progress.html) */ addListener( @@ -197,69 +201,89 @@ export interface StripeTerminalPlugin { /** * **Only applicable to Bluetooth and USB readers.** - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-listener/on-finish-installing-update.html) */ addListener( eventName: TerminalEventsEnum.FinishInstallingUpdate, - listenerFunc: (args: { - update: ReaderSoftwareUpdateInterface, - } | { - error: string, - }) => void, + listenerFunc: ( + args: + | { + update: ReaderSoftwareUpdateInterface; + } + | { + error: string; + }, + ) => void, ): Promise; /** * **Only applicable to Bluetooth and USB readers.** - * + * * Emitted upon connection and every 10 minutes. - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-listener/on-battery-level-update.html) */ addListener( eventName: TerminalEventsEnum.BatteryLevel, - listenerFunc: ({ level, charging, status }: { - level: number, - charging: boolean, - status: BatteryStatus + listenerFunc: ({ + level, + charging, + status, + }: { + level: number; + charging: boolean; + status: BatteryStatus; }) => void, - ): Promise, + ): Promise; /** * **Only applicable to Bluetooth and USB readers.** - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-listenable/on-report-reader-event.html) */ addListener( eventName: TerminalEventsEnum.ReaderEvent, listenerFunc: ({ event }: { event: ReaderEvent }) => void, - ): Promise, + ): Promise; /** * **Only applicable to Bluetooth and USB readers.** - * + * * Emitted when the Terminal requests that a message be displayed in your app. - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-listener/on-request-reader-display-message.html) */ addListener( eventName: TerminalEventsEnum.RequestDisplayMessage, - listenerFunc: ({ messageType, message }: { messageType: ReaderDisplayMessage, message: string }) => void, - ): Promise, + listenerFunc: ({ + messageType, + message, + }: { + messageType: ReaderDisplayMessage; + message: string; + }) => void, + ): Promise; /** * **Only applicable to Bluetooth and USB readers.** - * + * * Emitted when the reader begins waiting for input. Your app should prompt the customer * to present a source using one of the given input options. If the reader emits a message, * the RequestDisplayMessage event will be emitted. - * + * * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-reader-listener/on-request-reader-input.html) */ addListener( eventName: TerminalEventsEnum.RequestReaderInput, - listenerFunc: ({ options, message }: { options: ReaderInputOption[], message: string }) => void, - ): Promise, + listenerFunc: ({ + options, + message, + }: { + options: ReaderInputOption[]; + message: string; + }) => void, + ): Promise; /** * [*Stripe docs reference*](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.callable/-terminal-listener/on-payment-status-change.html) @@ -267,7 +291,7 @@ export interface StripeTerminalPlugin { addListener( eventName: TerminalEventsEnum.PaymentStatusChange, listenerFunc: ({ status }: { status: PaymentStatus }) => void, - ): Promise, + ): Promise; /** * @deprecated diff --git a/packages/terminal/src/stripe.enum.ts b/packages/terminal/src/stripe.enum.ts index 43d29b45..9f15bbe0 100644 --- a/packages/terminal/src/stripe.enum.ts +++ b/packages/terminal/src/stripe.enum.ts @@ -1,106 +1,106 @@ export enum TerminalConnectTypes { - Simulated = 'simulated', - Internet = 'internet', - Bluetooth = 'bluetooth', - Usb = 'usb', - TapToPay = 'tap-to-pay', + Simulated = 'simulated', + Internet = 'internet', + Bluetooth = 'bluetooth', + Usb = 'usb', + TapToPay = 'tap-to-pay', } export enum UpdateTimeEstimate { - LessThanOneMinute = 'LESS_THAN_ONE_MINUTE', - OneToTwoMinutes = 'ONE_TO_TWO_MINUTES', - TwoToFiveMinutes = 'TWO_TO_FIVE_MINUTES', - FiveToFifteenMinutes = 'FIVE_TO_FIFTEEN_MINUTES', + LessThanOneMinute = 'LESS_THAN_ONE_MINUTE', + OneToTwoMinutes = 'ONE_TO_TWO_MINUTES', + TwoToFiveMinutes = 'TWO_TO_FIVE_MINUTES', + FiveToFifteenMinutes = 'FIVE_TO_FIFTEEN_MINUTES', } export enum SimulateReaderUpdate { - UpdateAvailable = 'UPDATE_AVAILABLE', - None = 'NONE', - Required = 'REQUIRED', - Random = 'RANDOM', - LowBattery = 'LOW_BATTERY', - LowBatterySucceedConnect = 'LOW_BATTERY_SUCCEED_CONNECT', + UpdateAvailable = 'UPDATE_AVAILABLE', + None = 'NONE', + Required = 'REQUIRED', + Random = 'RANDOM', + LowBattery = 'LOW_BATTERY', + LowBatterySucceedConnect = 'LOW_BATTERY_SUCCEED_CONNECT', } export enum SimulatedCardType { - Visa = 'VISA', - VisaDebit = 'VISA_DEBIT', - Mastercard = 'MASTERCARD', - MastercardDebit = 'MASTERCARD_DEBIT', - MastercardPrepaid = 'MASTERCARD_PREPAID', - Amex = 'AMEX', - Amex2 = 'AMEX_2', - Discover = 'DISCOVER', - Discover2 = 'DISCOVER_2', - DinersClub = 'DINERS', - DinersClulb14Digits = 'DINERS_14_DIGITS', - JCB = 'JCB', - UnionPay = 'UNION_PAY', - Interac = 'INTERAC', - EftposAustraliaDebit = 'EFTPOS_AU_DEBIT', - VisaUsCommonDebit = 'VISA_US_COMMON_DEBIT', - ChargeDeclined = 'CHARGE_DECLINED', - ChargeDeclinedInsufficientFunds = 'CHARGE_DECLINED_INSUFFICIENT_FUNDS', - ChargeDeclinedLostCard = 'CHARGE_DECLINED_LOST_CARD', - ChargeDeclinedStolenCard = 'CHARGE_DECLINED_STOLEN_CARD', - ChargeDeclinedExpiredCard = 'CHARGE_DECLINED_EXPIRED_CARD', - ChargeDeclinedProcessingError = 'CHARGE_DECLINED_PROCESSING_ERROR', - EftposAustraliaVisaDebit = 'EFTPOS_AU_VISA_DEBIT', - EftposAustraliaMastercardDebit = 'EFTPOS_AU_DEBIT_MASTERCARD', - OfflinePinCVM = 'OFFLINE_PIN_CVM', - OfflinePinSCARetry = 'OFFLINE_PIN_SCA_RETRY', - OnlinePinCVM = 'ONLINE_PIN_CVM', - OnlinePinSCARetry = 'ONLINE_PIN_SCA_RETRY', + Visa = 'VISA', + VisaDebit = 'VISA_DEBIT', + Mastercard = 'MASTERCARD', + MastercardDebit = 'MASTERCARD_DEBIT', + MastercardPrepaid = 'MASTERCARD_PREPAID', + Amex = 'AMEX', + Amex2 = 'AMEX_2', + Discover = 'DISCOVER', + Discover2 = 'DISCOVER_2', + DinersClub = 'DINERS', + DinersClulb14Digits = 'DINERS_14_DIGITS', + JCB = 'JCB', + UnionPay = 'UNION_PAY', + Interac = 'INTERAC', + EftposAustraliaDebit = 'EFTPOS_AU_DEBIT', + VisaUsCommonDebit = 'VISA_US_COMMON_DEBIT', + ChargeDeclined = 'CHARGE_DECLINED', + ChargeDeclinedInsufficientFunds = 'CHARGE_DECLINED_INSUFFICIENT_FUNDS', + ChargeDeclinedLostCard = 'CHARGE_DECLINED_LOST_CARD', + ChargeDeclinedStolenCard = 'CHARGE_DECLINED_STOLEN_CARD', + ChargeDeclinedExpiredCard = 'CHARGE_DECLINED_EXPIRED_CARD', + ChargeDeclinedProcessingError = 'CHARGE_DECLINED_PROCESSING_ERROR', + EftposAustraliaVisaDebit = 'EFTPOS_AU_VISA_DEBIT', + EftposAustraliaMastercardDebit = 'EFTPOS_AU_DEBIT_MASTERCARD', + OfflinePinCVM = 'OFFLINE_PIN_CVM', + OfflinePinSCARetry = 'OFFLINE_PIN_SCA_RETRY', + OnlinePinCVM = 'ONLINE_PIN_CVM', + OnlinePinSCARetry = 'ONLINE_PIN_SCA_RETRY', } export enum BatteryStatus { - Unknown = 'UNKNOWN', - Critical = 'CRITICAL', - Low = 'LOW', - Nominal = 'NOMINAL', + Unknown = 'UNKNOWN', + Critical = 'CRITICAL', + Low = 'LOW', + Nominal = 'NOMINAL', } export enum ReaderEvent { - CardInserted = 'CARD_INSERTED', - CardRemoved = 'CARD_REMOVED', + CardInserted = 'CARD_INSERTED', + CardRemoved = 'CARD_REMOVED', } export enum ReaderDisplayMessage { - CheckMobileDevice = 'CHECK_MOBILE_DEVICE', - RetryCard = 'RETRY_CARD', - InsertCard = 'INSERT_CARD', - InsertOrSwipeCard = 'INSERT_OR_SWIPE_CARD', - SwipeCard = 'SWIPE_CARD', - RemoveCard = 'REMOVE_CARD', - MultipleContactlessCardsDetected = 'MULTIPLE_CONTACTLESS_CARDS_DETECTED', - TryAnotherReadMethod = 'TRY_ANOTHER_READ_METHOD', - TryAnotherCard = 'TRY_ANOTHER_CARD', - CardRemovedTooEarly = 'CARD_REMOVED_TOO_EARLY', + CheckMobileDevice = 'CHECK_MOBILE_DEVICE', + RetryCard = 'RETRY_CARD', + InsertCard = 'INSERT_CARD', + InsertOrSwipeCard = 'INSERT_OR_SWIPE_CARD', + SwipeCard = 'SWIPE_CARD', + RemoveCard = 'REMOVE_CARD', + MultipleContactlessCardsDetected = 'MULTIPLE_CONTACTLESS_CARDS_DETECTED', + TryAnotherReadMethod = 'TRY_ANOTHER_READ_METHOD', + TryAnotherCard = 'TRY_ANOTHER_CARD', + CardRemovedTooEarly = 'CARD_REMOVED_TOO_EARLY', } export enum ReaderInputOption { - None = 'NONE', - Insert = 'INSERT', - Swipe = 'SWIPE', - Tap = 'TAP', - ManualEntry = 'MANUAL_ENTRY', + None = 'NONE', + Insert = 'INSERT', + Swipe = 'SWIPE', + Tap = 'TAP', + ManualEntry = 'MANUAL_ENTRY', } export enum PaymentStatus { - NotReady = 'NOT_READY', - Ready = 'READY', - WaitingForInput = 'WAITING_FOR_INPUT', - Processing = 'PROCESSING', + NotReady = 'NOT_READY', + Ready = 'READY', + WaitingForInput = 'WAITING_FOR_INPUT', + Processing = 'PROCESSING', } export enum DisconnectReason { - Unknown = 'UNKNOWN', - DisconnectRequested = 'DISCONNECT_REQUESTED', - RebootRequested = 'REBOOT_REQUESTED', - SecurityReboot = 'SECURITY_REBOOT', - CriticallyLowBattery = 'CRITICALLY_LOW_BATTERY', - PoweredOff = 'POWERED_OFF', - BluetoothDisabled = 'BLUETOOTH_DISABLED', + Unknown = 'UNKNOWN', + DisconnectRequested = 'DISCONNECT_REQUESTED', + RebootRequested = 'REBOOT_REQUESTED', + SecurityReboot = 'SECURITY_REBOOT', + CriticallyLowBattery = 'CRITICALLY_LOW_BATTERY', + PoweredOff = 'POWERED_OFF', + BluetoothDisabled = 'BLUETOOTH_DISABLED', } export enum ConnectionStatus { diff --git a/packages/terminal/src/web.ts b/packages/terminal/src/web.ts index 0d82d100..d4ba0fff 100644 --- a/packages/terminal/src/web.ts +++ b/packages/terminal/src/web.ts @@ -44,7 +44,7 @@ export class StripeTerminalWeb async setConnectionToken(): Promise { console.log('setConnectionToken'); } - + async setSimulatorConfiguration(options: { update?: SimulateReaderUpdate | undefined; simulatedCard?: SimulatedCardType | undefined;