stripe / stripe-terminal-ios

Stripe Terminal iOS SDK
https://stripe.com/docs/terminal/sdk/ios
Other
104 stars 65 forks source link

`discoverReaders` calls completion with error when cancelled #272

Closed r2-pro closed 9 months ago

r2-pro commented 1 year ago

Summary

Despite documentation stating:

@note If discoverReaders is canceled, the completion block will be called with nil (rather than an SCPErrorCanceled error).

SDK calls completion block of discoverReaders with an error.

(lldb) print (error.self as NSError).userInfo
([String : Any]) 2 key/value pairs {
  [0] = {
    key = "com.stripe-terminal:Message"
    value = (object = 0x0000000283e1f720)
  }
  [1] = {
    key = "NSLocalizedDescription"
    value = (object = 0x0000000283e1f720)
  }
}
(lldb) po 0x0000000283e1f720
discoverReaders was canceled.
(lldb) po 0x0000000283e1f720
discoverReaders was canceled.

iOS version

17.0.3

Installation method

SPM

SDK version

3.1.0

bric-stripe commented 12 months ago

@r2-pro sorry for the confusion here, and thanks for reporting. This was a change made in 3.0 and is called out in the changelog

Update: Canceling discoverReaders now completes with an SCPErrorCanceled error. Previously no error was provided when canceled.

but we missed updating that note. I'll make sure this gets fixed up in the 3.3 release. But for now the behavior you're seeing in the expected behavior in 3.x SDKs.

fwiw this was for consistency with other commands that report the cancelled error as well as consistency with the Android SDK.