stripe / stripe-terminal-ios

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

Canceling the SDK #253

Closed usaman9040 closed 11 months ago

usaman9040 commented 1 year ago

Summary

I have been working on stripe terminal integration with an M2 device. The thing I found about it is anywhere there are cancellable involved it does not work properly. After every cancellation need to add some second delay in my case is 0.2 and for others, it is between 0.2 to 0.5 seconds.

Code to reproduce

cancelable = Terminal.shared.discoverReaders cancelable = Terminal.shared.collectPaymentMethod

iOS version

IOS 16

Installation method

Pod

SDK version

V3.0.0-b7

Other information

bric-stripe commented 1 year ago

Hi, this has been a common pain point for developers. You're correct that the trouble is the cancelable's completion is called before the command being cancelled has fully completed. The command's completion block is the source of truth for when the command has completed and another can be run. But we understand the pain with having to track that and all.

Our public 3.0 release (should be released soon) will be improving this where instead of returning SCPErrorBusy if a command is requested while another is still technically running, the command is queued and will be run when the still running command completes. This will let you enqueue commands from the cancelable completion block without needing to delay or track that the original commands completion block has been called.

usaman9040 commented 1 year ago

Yes Implementing the the queued here, is solved a lot of issue and take much of developer pain points. As you mentioned queue there are all functions related to this like prioritize one task on other and removing and managing all the tasks are available. But If there is some kind of property that indicate that SDK is free or busy that will even help more and share a lot of room for developer to play.

bric-stripe commented 11 months ago

Hi, following up here. We implemented the queue in SDK 3.0+ which should help things here. Please re-open though if running in to any problems with that approach.