Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(iOS) Terminal.shared.collectPaymentMethod fails silently on second attempt to capture card - if card is left in reader from prev attempt #155

Closed
benhill opened this issue May 21, 2022 · 4 comments · Fixed by #157

Comments

@benhill
Copy link

benhill commented May 21, 2022

I am using StripeTerminal (2.8.0)

I am implementing Stripe Terminal on iOS. When processing a valid card from my M2 reader, it works great.

If there is an error in my transaction, I have added a "try again" button that just starts the payment capture process over: fetchPaymentIntent => retrievePaymentIntent => collectPaymentMethod (code below) . If I remove the card before "trying again", everything works fine.

But if I leave the card in the M2 reader (such that the beeping reminders start to sound), and then attempt to run the code below, the app becomes unresponsive at Terminal.shared.collectPaymentMethod. No errors are thrown in output and the completion method isn't called.

I have tried to figure out a way to test if the card is still in the reader to throw a "remove card please" message before the code below is run again but I haven't been able to find anything in the API reference.

Here's my collect payment code:

func collectPayment() {
        StripePayment.shared.fetchPaymentIntent(totalCart: totalCart) { createResult, createError in
            if let error = createError {
                self.throwPaymentError(error)
            } else if let clientSecret = createResult {
                Terminal.shared.retrievePaymentIntent(clientSecret: clientSecret) { (intent, error) in
                    if let retrieveError = error {
                        self.throwPaymentError(retrieveError)
                    } else if let retrievedIntent = intent {
                        self.collectCancelable = Terminal.shared.collectPaymentMethod(retrievedIntent) { collectResult, collectError in                            
                            self.readerMessageLabel.text = "Processing Payment"
                            if let error = collectError {
                                self.throwPaymentError(error)
                            } else if let paymentIntent = collectResult {
                                self.processPayment(paymentIntent)
                            }
                        }
                    }
                }
            }
        }
    }
@bric-stripe
Copy link
Collaborator

@benhill thanks for the report! Just confirming we've been able to reproduce and are investigating further. So far we've identified that this is a regression in version 2.3.0. Version 2.2 correctly fails the second collectPaymentIntent call with the expected CardLeftInReader error.

@benhill
Copy link
Author

benhill commented May 23, 2022

Ah, thank you! Out of curiosity, is there a way to identify that a card has been left in the reader via the API?

@bric-stripe
Copy link
Collaborator

is there a way to identify that a card has been left in the reader via the API

there's not currently a great way to do this. One option is to track the state via the didReportReaderEvent. If you receive a CardInserted event is sent, when the transaction is complete, if you haven't received the CardRemoved event, you could update your UI to request the card be removed until you receive that CardRemoved event.

note we're still investigating this regression and will need to do a full release test but we're likely going to release a 2.9.1 with a bugfix for this issue. No definite timeline but I'm hopeful for early next week. With that fix if the card was left in the reader the second collectPaymentMethod call will fail right away with the CardLeftInReader error, which is the expected behavior for this.

@benhill
Copy link
Author

benhill commented May 25, 2022

thank you, as always. I updated the version to 2.2 - and yes, no issue there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants