Skip to content

Commit

Permalink
fix(android): Fixed Terminal.discoverReaders method errors not bein…
Browse files Browse the repository at this point in the history
…g propagated

fix: Fixed `Terminal.discoverReaders` method errors are not mapped to `TerminalException`
fix: Fixed `Terminal.supportsReadersOfType` to support deviceType to null for UNKNOWN deviceType on android
fix: Fixed `TerminalException.message` was not properly mapped
  • Loading branch information
BreX900 committed Oct 16, 2023
1 parent f4d7c70 commit 315e1ae
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 31 deletions.
10 changes: 9 additions & 1 deletion one_for_all_generator/lib/src/generators/dart_api_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,19 @@ class DartApiBuilder extends ApiBuilder {
final parameters =
e.parameters.map((e) => codecs.encodeSerialization(e.type, e.name)).join(', ');

final errorHandler = hostExceptionHandler != null
? '.handleError((error, _) {'
' if (error is PlatformException) ${hostExceptionHandler.accessor}(error);'
' throw error;'
'})'
: '';

return Method((b) => b
..update((b) => _updateHostApiMethod(e, b))
..body = Code('return _\$${e.name.no_}'
'.receiveBroadcastStream([$parameters])'
'.map((e) => ${codecs.encodeDeserialization(returnType, 'e')});'));
'.map((e) => ${codecs.encodeDeserialization(returnType, 'e')})'
'$errorHandler;'));
}))
..methods.addAll(element.methods.where((e) => e.isHostApiMethod).map((e) {
final returnType = e.returnType.singleTypeArg;
Expand Down
6 changes: 5 additions & 1 deletion stripe_terminal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

## 3.1.1
- fix(android): Fixed `Terminal.discoverReaders` method errors not being propagated
- fix: Fixed `Terminal.discoverReaders` method errors are not mapped to `TerminalException`
- fix: Fixed `Terminal.supportsReadersOfType` to support deviceType to null for UNKNOWN deviceType on android
- fix: Fixed `TerminalException.message` was not properly mapped

## 3.1.0
- feat: Mapped more exception codecs: Android (`collectInputsUnsupported`), IOS (`readerConnectionOfflineNeedsUpdate`,
Expand Down
1 change: 1 addition & 0 deletions stripe_terminal/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- (Not exist on ios) `Reader.device` has been removed and replaced with [`Reader.bluetoothDevice`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-reader/bluetooth-device.html) and [`Reader.usbDevice`](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-reader/usb-device.html).

### Ready
- Feat: Added support to `Terminal.updateSimulatorConfiguration`

### In progress

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.stripe.stripeterminal.external.callable.RefundCallback
import com.stripe.stripeterminal.external.callable.SetupIntentCallback
import com.stripe.stripeterminal.external.models.CollectConfiguration
import com.stripe.stripeterminal.external.models.ConnectionConfiguration
import com.stripe.stripeterminal.external.models.DeviceType
import com.stripe.stripeterminal.external.models.ListLocationsParameters
import com.stripe.stripeterminal.external.models.Location
import com.stripe.stripeterminal.external.models.PaymentIntent
Expand All @@ -27,6 +28,9 @@ import com.stripe.stripeterminal.external.models.SetupIntent
import com.stripe.stripeterminal.external.models.SetupIntentCancellationParameters
import com.stripe.stripeterminal.external.models.SetupIntentConfiguration
import com.stripe.stripeterminal.external.models.SetupIntentParameters
import com.stripe.stripeterminal.external.models.SimulatedCard
import com.stripe.stripeterminal.external.models.SimulatedCardType
import com.stripe.stripeterminal.external.models.SimulatorConfiguration
import com.stripe.stripeterminal.external.models.TerminalException
import com.stripe.stripeterminal.log.LogLevel
import mek.stripeterminal.api.CartApi
Expand Down Expand Up @@ -117,10 +121,11 @@ class TerminalPlugin : FlutterPlugin, ActivityAware, TerminalPlatformApi {
override fun onGetConnectionStatus(): ConnectionStatusApi = _terminal.connectionStatus.toApi()

override fun onSupportsReadersOfType(
deviceType: DeviceTypeApi,
deviceType: DeviceTypeApi?,
discoveryConfiguration: DiscoveryConfigurationApi,
): Boolean {
val hostDeviceType = deviceType.toHost() ?: return false
val hostDeviceType = (if (deviceType != null) deviceType.toHost() else DeviceType.UNKNOWN)
?: return false
val hostDiscoveryConfiguration = discoveryConfiguration.toHost() ?: return false
val result = _terminal.supportsReadersOfType(
deviceType = hostDeviceType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ interface TerminalPlatformApi {
fun onGetConnectionStatus(): ConnectionStatusApi

fun onSupportsReadersOfType(
deviceType: DeviceTypeApi,
deviceType: DeviceTypeApi?,
discoveryConfiguration: DiscoveryConfigurationApi,
): Boolean

Expand Down Expand Up @@ -251,7 +251,7 @@ interface TerminalPlatformApi {
result.success(res.ordinal)
}
"supportsReadersOfType" -> {
val res = onSupportsReadersOfType((args[0] as Int).let { DeviceTypeApi.values()[it] }, (args[1] as List<Any?>).let { DiscoveryConfigurationApi.deserialize(it) })
val res = onSupportsReadersOfType((args[0] as Int?)?.let { DeviceTypeApi.values()[it] }, (args[1] as List<Any?>).let { DiscoveryConfigurationApi.deserialize(it) })
result.success(res)
}
"connectBluetoothReader" -> {
Expand Down Expand Up @@ -1189,7 +1189,7 @@ data class TerminalExceptionApi(
}

enum class TerminalExceptionCodeApi {
UNKNOWN, READER_NOT_RECOVERED, PAYMENT_INTENT_NOT_RECOVERED, SETUP_INTENT_NOT_RECOVERED, CANCEL_FAILED, NOT_CONNECTED_TO_READER, ALREADY_CONNECTED_TO_READER, BLUETOOTH_DISABLED, BLUETOOTH_PERMISSION_DENIED, CONFIRM_INVALID_PAYMENT_INTENT, INVALID_CLIENT_SECRET, INVALID_READER_FOR_UPDATE, UNSUPPORTED_OPERATION, UNEXPECTED_OPERATION, UNSUPPORTED_SDK, FEATURE_NOT_AVAILABLE_WITH_CONNECTED_READER, USB_PERMISSION_DENIED, USB_DISCOVERY_TIMED_OUT, INVALID_PARAMETER, INVALID_REQUIRED_PARAMETER, INVALID_TIP_PARAMETER, LOCAL_MOBILE_UNSUPPORTED_DEVICE, LOCAL_MOBILE_UNSUPPORTED_OPERATING_SYSTEM_VERSION, LOCAL_MOBILE_DEVICE_TAMPERED, LOCAL_MOBILE_DEBUG_NOT_SUPPORTED, OFFLINE_MODE_UNSUPPORTED_OPERATING_SYSTEM_VERSION, CANCELED, LOCATION_SERVICES_DISABLED, BLUETOOTH_SCAN_TIMED_OUT, BLUETOOTH_LOW_ENERGY_UNSUPPORTED, READER_SOFTWARE_UPDATE_FAILED_BATTERY_LOW, READER_SOFTWARE_UPDATE_FAILED_INTERRUPTED, READER_SOFTWARE_UPDATE_FAILED_EXPIRED_UPDATE, BLUETOOTH_CONNECTION_FAILED_BATTERY_CRITICALLY_LOW, CARD_INSERT_NOT_READ, CARD_SWIPE_NOT_READ, CARD_READ_TIMED_OUT, CARD_REMOVED, CUSTOMER_CONSENT_REQUIRED, CARD_LEFT_IN_READER, FEATURE_NOT_ENABLED_ON_ACCOUNT, PASSCODE_NOT_ENABLED, COMMAND_NOT_ALLOWED_DURING_CALL, INVALID_AMOUNT, INVALID_CURRENCY, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_REQUIRESI_CLOUD_SIGN_IN, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_CANCELED, APPLE_BUILT_IN_READER_FAILED_TO_PREPARE, APPLE_BUILT_IN_READER_DEVICE_BANNED, APPLE_BUILT_IN_READER_T_O_S_NOT_YET_ACCEPTED, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_FAILED, APPLE_BUILT_IN_READER_MERCHANT_BLOCKED, APPLE_BUILT_IN_READER_INVALID_MERCHANT, READER_BUSY, INCOMPATIBLE_READER, READER_COMMUNICATION_ERROR, UNKNOWN_READER_IP_ADDRESS, INTERNET_CONNECT_TIME_OUT, CONNECT_FAILED_READER_IS_IN_USE, READER_NOT_ACCESSIBLE_IN_BACKGROUND, BLUETOOTH_ERROR, BLUETOOTH_CONNECT_TIMED_OUT, BLUETOOTH_DISCONNECTED, BLUETOOTH_PEER_REMOVED_PAIRING_INFORMATION, BLUETOOTH_ALREADY_PAIRED_WITH_ANOTHER_DEVICE, BLUETOOTH_RECONNECT_STARTED, USB_DISCONNECTED, USB_RECONNECT_STARTED, READER_CONNECTED_TO_ANOTHER_DEVICE, READER_SOFTWARE_UPDATE_FAILED, READER_SOFTWARE_UPDATE_FAILED_READER_ERROR, READER_SOFTWARE_UPDATE_FAILED_SERVER_ERROR, NFC_DISABLED, UNSUPPORTED_READER_VERSION, UNEXPECTED_SDK_ERROR, UNEXPECTED_READER_ERROR, ENCRYPTION_KEY_FAILURE, ENCRYPTION_KEY_STILL_INITIALIZING, DECLINED_BY_STRIPE_API, DECLINED_BY_READER, OFFLINE_TEST_CARD_IN_LIVEMODE, NOT_CONNECTED_TO_INTERNET, REQUEST_TIMED_OUT, STRIPE_API_CONNECTION_ERROR, STRIPE_API_ERROR, STRIPE_API_RESPONSE_DECODING_ERROR, INTERNAL_NETWORK_ERROR, CONNECTION_TOKEN_PROVIDER_ERROR, SESSION_EXPIRED, UNSUPPORTED_MOBILE_DEVICE_CONFIGURATION, COMMAND_NOT_ALLOWED, AMOUNT_EXCEEDS_MAX_OFFLINE_AMOUNT, OFFLINE_PAYMENTS_DATABASE_TOO_LARGE, READER_CONNECTION_NOT_AVAILABLE_OFFLINE, READER_CONNECTION_OFFLINE_LOCATION_MISMATCH, READER_CONNECTION_OFFLINE_NEEDS_UPDATE, LOCATION_CONNECTION_NOT_AVAILABLE_OFFLINE, NO_LAST_SEEN_ACCOUNT, INVALID_OFFLINE_CURRENCY, REFUND_FAILED, CARD_SWIPE_NOT_AVAILABLE, INTERAC_NOT_SUPPORTED_OFFLINE, ONLINE_PIN_NOT_SUPPORTED_OFFLINE, OFFLINE_AND_CARD_EXPIRED, OFFLINE_TRANSACTION_DECLINED, OFFLINE_COLLECT_AND_CONFIRM_MISMATCH, FORWARDING_TEST_MODE_PAYMENT_IN_LIVE_MODE, FORWARDING_LIVE_MODE_PAYMENT_IN_TEST_MODE, OFFLINE_PAYMENT_INTENT_NOT_FOUND, UPDATE_PAYMENT_INTENT_UNAVAILABLE_WHILE_OFFLINE, UPDATE_PAYMENT_INTENT_UNAVAILABLE_WHILE_OFFLINE_MODE_ENABLED, MISSING_EMV_DATA, CONNECTION_TOKEN_PROVIDER_ERROR_WHILE_FORWARDING, CONNECTION_TOKEN_PROVIDER_TIMED_OUT, ACCOUNT_ID_MISMATCH_WHILE_FORWARDING, OFFLINE_BEHAVIOR_FORCE_OFFLINE_WITH_FEATURE_DISABLED, NOT_CONNECTED_TO_INTERNET_AND_OFFLINE_BEHAVIOR_REQUIRE_ONLINE, TEST_CARD_IN_LIVE_MODE, COLLECT_INPUTS_APPLICATION_ERROR, COLLECT_INPUTS_TIMED_OUT, COLLECT_INPUTS_UNSUPPORTED;
UNKNOWN, READER_NOT_RECOVERED, PAYMENT_INTENT_NOT_RECOVERED, SETUP_INTENT_NOT_RECOVERED, CANCEL_FAILED, NOT_CONNECTED_TO_READER, ALREADY_CONNECTED_TO_READER, BLUETOOTH_DISABLED, BLUETOOTH_PERMISSION_DENIED, CONFIRM_INVALID_PAYMENT_INTENT, INVALID_CLIENT_SECRET, INVALID_READER_FOR_UPDATE, UNSUPPORTED_OPERATION, UNEXPECTED_OPERATION, UNSUPPORTED_SDK, FEATURE_NOT_AVAILABLE_WITH_CONNECTED_READER, USB_PERMISSION_DENIED, USB_DISCOVERY_TIMED_OUT, INVALID_PARAMETER, INVALID_REQUIRED_PARAMETER, INVALID_TIP_PARAMETER, LOCAL_MOBILE_UNSUPPORTED_DEVICE, LOCAL_MOBILE_UNSUPPORTED_OPERATING_SYSTEM_VERSION, LOCAL_MOBILE_DEVICE_TAMPERED, LOCAL_MOBILE_DEBUG_NOT_SUPPORTED, OFFLINE_MODE_UNSUPPORTED_OPERATING_SYSTEM_VERSION, CANCELED, LOCATION_SERVICES_DISABLED, BLUETOOTH_SCAN_TIMED_OUT, BLUETOOTH_LOW_ENERGY_UNSUPPORTED, READER_SOFTWARE_UPDATE_FAILED_BATTERY_LOW, READER_SOFTWARE_UPDATE_FAILED_INTERRUPTED, READER_SOFTWARE_UPDATE_FAILED_EXPIRED_UPDATE, BLUETOOTH_CONNECTION_FAILED_BATTERY_CRITICALLY_LOW, CARD_INSERT_NOT_READ, CARD_SWIPE_NOT_READ, CARD_READ_TIMED_OUT, CARD_REMOVED, CUSTOMER_CONSENT_REQUIRED, CARD_LEFT_IN_READER, FEATURE_NOT_ENABLED_ON_ACCOUNT, PASSCODE_NOT_ENABLED, COMMAND_NOT_ALLOWED_DURING_CALL, INVALID_AMOUNT, INVALID_CURRENCY, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_REQUIRESI_CLOUD_SIGN_IN, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_CANCELED, APPLE_BUILT_IN_READER_FAILED_TO_PREPARE, APPLE_BUILT_IN_READER_DEVICE_BANNED, APPLE_BUILT_IN_READER_T_O_S_NOT_YET_ACCEPTED, APPLE_BUILT_IN_READER_T_O_S_ACCEPTANCE_FAILED, APPLE_BUILT_IN_READER_MERCHANT_BLOCKED, APPLE_BUILT_IN_READER_INVALID_MERCHANT, READER_BUSY, INCOMPATIBLE_READER, READER_COMMUNICATION_ERROR, UNKNOWN_READER_IP_ADDRESS, INTERNET_CONNECT_TIME_OUT, CONNECT_FAILED_READER_IS_IN_USE, READER_NOT_ACCESSIBLE_IN_BACKGROUND, BLUETOOTH_ERROR, BLUETOOTH_CONNECT_TIMED_OUT, BLUETOOTH_DISCONNECTED, BLUETOOTH_PEER_REMOVED_PAIRING_INFORMATION, BLUETOOTH_ALREADY_PAIRED_WITH_ANOTHER_DEVICE, BLUETOOTH_RECONNECT_STARTED, USB_DISCONNECTED, USB_RECONNECT_STARTED, READER_CONNECTED_TO_ANOTHER_DEVICE, READER_SOFTWARE_UPDATE_FAILED, READER_SOFTWARE_UPDATE_FAILED_READER_ERROR, READER_SOFTWARE_UPDATE_FAILED_SERVER_ERROR, NFC_DISABLED, UNSUPPORTED_READER_VERSION, UNEXPECTED_SDK_ERROR, UNEXPECTED_READER_ERROR, ENCRYPTION_KEY_FAILURE, ENCRYPTION_KEY_STILL_INITIALIZING, DECLINED_BY_STRIPE_API, DECLINED_BY_READER, NOT_CONNECTED_TO_INTERNET, REQUEST_TIMED_OUT, STRIPE_API_CONNECTION_ERROR, STRIPE_API_ERROR, STRIPE_API_RESPONSE_DECODING_ERROR, INTERNAL_NETWORK_ERROR, CONNECTION_TOKEN_PROVIDER_ERROR, SESSION_EXPIRED, UNSUPPORTED_MOBILE_DEVICE_CONFIGURATION, COMMAND_NOT_ALLOWED, AMOUNT_EXCEEDS_MAX_OFFLINE_AMOUNT, OFFLINE_PAYMENTS_DATABASE_TOO_LARGE, READER_CONNECTION_NOT_AVAILABLE_OFFLINE, READER_CONNECTION_OFFLINE_LOCATION_MISMATCH, READER_CONNECTION_OFFLINE_NEEDS_UPDATE, LOCATION_CONNECTION_NOT_AVAILABLE_OFFLINE, NO_LAST_SEEN_ACCOUNT, INVALID_OFFLINE_CURRENCY, REFUND_FAILED, CARD_SWIPE_NOT_AVAILABLE, INTERAC_NOT_SUPPORTED_OFFLINE, ONLINE_PIN_NOT_SUPPORTED_OFFLINE, OFFLINE_AND_CARD_EXPIRED, OFFLINE_TRANSACTION_DECLINED, OFFLINE_COLLECT_AND_CONFIRM_MISMATCH, FORWARDING_TEST_MODE_PAYMENT_IN_LIVE_MODE, FORWARDING_LIVE_MODE_PAYMENT_IN_TEST_MODE, OFFLINE_PAYMENT_INTENT_NOT_FOUND, UPDATE_PAYMENT_INTENT_UNAVAILABLE_WHILE_OFFLINE, UPDATE_PAYMENT_INTENT_UNAVAILABLE_WHILE_OFFLINE_MODE_ENABLED, MISSING_EMV_DATA, CONNECTION_TOKEN_PROVIDER_ERROR_WHILE_FORWARDING, CONNECTION_TOKEN_PROVIDER_TIMED_OUT, ACCOUNT_ID_MISMATCH_WHILE_FORWARDING, OFFLINE_BEHAVIOR_FORCE_OFFLINE_WITH_FEATURE_DISABLED, NOT_CONNECTED_TO_INTERNET_AND_OFFLINE_BEHAVIOR_REQUIRE_ONLINE, TEST_CARD_IN_LIVE_MODE, COLLECT_INPUTS_APPLICATION_ERROR, COLLECT_INPUTS_TIMED_OUT, COLLECT_INPUTS_UNSUPPORTED;
}

data class TippingConfigurationApi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ class DiscoverReadersSubject {
runOnMainThread { sink.success(readers.map { it.toApi() }) }
}
},
callback = object : TerminalErrorHandler(sink::error), Callback {
callback = object : Callback {
override fun onFailure(e: TerminalException) = runOnMainThread {
if (_cancelable == null) return@runOnMainThread
if (e.errorCode == TerminalException.TerminalErrorCode.CANCELED) return@runOnMainThread

_cancelable = null
super.onFailure(e)
sink.error(e.toPlatformError())
sink.endOfStream()
}

Expand Down
4 changes: 2 additions & 2 deletions stripe_terminal/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Flutter (1.0.0)
- mek_stripe_terminal (3.1.0):
- mek_stripe_terminal (3.1.1):
- Flutter
- StripeTerminal (~> 3.1.0)
- permission_handler_apple (9.1.1):
Expand All @@ -26,7 +26,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
mek_stripe_terminal: 83c57b917dc236752c47758613dc9c249c146883
mek_stripe_terminal: 28fb87151cb2d580c02e33532ef483d5da855213
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
StripeTerminal: fa064cf68a7a3df7c2ee1b2e6d33c8866d1e6aef

Expand Down
7 changes: 5 additions & 2 deletions stripe_terminal/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _MyAppState extends State<MyApp> {
}

final terminal = await Terminal.getInstance(
shouldPrintLogs: true,
shouldPrintLogs: false,
fetchToken: _fetchConnectionToken,
);
setState(() => _terminal = terminal);
Expand Down Expand Up @@ -355,7 +355,10 @@ class _MyAppState extends State<MyApp> {
child: const Text('Stop Scanning'),
),
const Divider(),
..._readers.map((e) {
...[
..._readers,
if (_reader != null) _reader!,
].map((e) {
return ListTile(
selected: e.serialNumber == _reader?.serialNumber,
enabled: terminal != null &&
Expand Down
2 changes: 1 addition & 1 deletion stripe_terminal/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.1.0"
version: "3.1.1"
meta:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions stripe_terminal/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:

permission_handler: ^10.4.3
mek_stripe_terminal:
path: ..
path: ./..

shelf: ^1.4.1
shelf_router: ^1.1.4
Expand All @@ -27,7 +27,7 @@ dev_dependencies:

dependency_overrides:
one_for_all:
path: ../../one_for_all
path: ./../../one_for_all

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
5 changes: 2 additions & 3 deletions stripe_terminal/ios/Classes/Api/TerminalApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protocol TerminalPlatformApi {
func onGetConnectionStatus() throws -> ConnectionStatusApi

func onSupportsReadersOfType(
_ deviceType: DeviceTypeApi,
_ deviceType: DeviceTypeApi?,
_ discoveryConfiguration: DiscoveryConfigurationApi
) throws -> Bool

Expand Down Expand Up @@ -298,7 +298,7 @@ func setTerminalPlatformApiHandler(
let res = try hostApi.onGetConnectionStatus()
result(res.rawValue)
case "supportsReadersOfType":
let res = try hostApi.onSupportsReadersOfType(DeviceTypeApi(rawValue: args[0] as! Int)!, deserializeDiscoveryConfigurationApi(args[1] as! [Any?]))
let res = try hostApi.onSupportsReadersOfType(!(args[0] is NSNull) ? DeviceTypeApi(rawValue: args[0] as! Int)! : nil, deserializeDiscoveryConfigurationApi(args[1] as! [Any?]))
result(res)
case "connectBluetoothReader":
runAsync {
Expand Down Expand Up @@ -1356,7 +1356,6 @@ enum TerminalExceptionCodeApi: Int {
case encryptionKeyStillInitializing
case declinedByStripeApi
case declinedByReader
case offlineTestCardInLivemode
case notConnectedToInternet
case requestTimedOut
case stripeApiConnectionError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class DiscoveryDelegatePlugin: NSObject, DiscoveryDelegate {
self._cancelable = nil
DispatchQueue.main.async {
if let error = error as? NSError {
self._sink?.error(error.toPlatformError())
let exception = error.toApi()
if (exception.code == TerminalExceptionCodeApi.canceled) {return}
self._sink?.error(exception.toPlatformError())
}

self._sink?.endOfStream()
Expand Down
4 changes: 2 additions & 2 deletions stripe_terminal/ios/Classes/TerminalPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public class TerminalPlugin: NSObject, FlutterPlugin, TerminalPlatformApi {
}

func onSupportsReadersOfType(
_ deviceType: DeviceTypeApi,
_ deviceType: DeviceTypeApi?,
_ discoveryConfiguration: DiscoveryConfigurationApi
) throws -> Bool {
let hostDiscoveryMethod = discoveryConfiguration.toHostDiscoveryMethod()
guard let hostDiscoveryMethod else {
return false
}
let hostDeviceType = deviceType.toHost()
let hostDeviceType = deviceType?.toHost()
guard let hostDeviceType else {
return false
}
Expand Down
12 changes: 8 additions & 4 deletions stripe_terminal/lib/src/platform/terminal_platform.api.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion stripe_terminal/lib/src/platform/terminal_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TerminalPlatform extends _$TerminalPlatform {
@MethodApi(kotlin: MethodApiType.sync, swift: MethodApiType.sync)
@override
Future<bool> supportsReadersOfType({
required DeviceType deviceType,
required DeviceType? deviceType,
required DiscoveryConfiguration discoveryConfiguration,
});

Expand Down
2 changes: 1 addition & 1 deletion stripe_terminal/lib/src/terminal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Terminal {
/// This makes it easy to quickly test your integration end-to-end, from pairing with
/// a reader to taking payments.
Future<bool> supportsReadersOfType({
required DeviceType deviceType,
required DeviceType? deviceType,
required DiscoveryConfiguration discoveryConfiguration,
}) async {
return await _platform.supportsReadersOfType(
Expand Down
2 changes: 1 addition & 1 deletion stripe_terminal/lib/src/terminal_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ class TerminalException {
required this.stackTrace,
required this.paymentIntent,
required this.apiError,
}) : message = (message.isEmpty ? null : code.message) ?? '';
}) : message = (message.isEmpty ? code.message : message) ?? '';

@override
String toString() => [
Expand Down
2 changes: 1 addition & 1 deletion stripe_terminal/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mek_stripe_terminal
description: A StripeTerminal plugin to discover readers, connect to them and process payments.
version: 3.1.0
version: 3.1.1
repository: https://github.com/BreX900/mek-packages/tree/main/stripe_terminal
homepage: https://github.com/BreX900/mek-packages/tree/main/stripe_terminal
topics:
Expand Down

0 comments on commit 315e1ae

Please sign in to comment.