stripe / stripe-ios

Stripe iOS SDK
https://stripe.com
MIT License
2.09k stars 975 forks source link

Payment is immediately being canceled due to ErrorCode: 2850 #1874

Closed DanielCauser closed 3 years ago

DanielCauser commented 3 years ago

Summary

We're having an issue where the first transaction of the day immediately cancels due to error 2850. This is awful, especially because even retrying the same transaction, they get the same error, the only way to make it work is to actually cancel the payment and try again, which puts the client funds on hold.

What we do to reproduce:

  1. Use the app normally for one day.
  2. On the next day do (With the same app, or a fresh install)
  3. Connect iOS app to the Bluetooth terminal (SDK connect).
  4. Create a payment intent.
  5. Collect Payment.
  6. Payment cancels as soon as the user inserts the card in the terminal with error 2850. Even though there are no cards on the card reader.

image

Is there any suggestion I can do to try to troubleshoot this problem?

Code to reproduce

Payment service:

//Step 1 - Create a PaymentIntent
var paymentIntent = await _paymentService.CreatePaymentIntent(ct, parameters);

//Save the PaymentIntent in case we need to cancel it.
_currentIntent = paymentIntent;

//Step 2 - Collect payment method and update the PaymentIntent
paymentIntent = await _paymentService.CollectPaymentMethod(ct, paymentIntent, statusMessageCallback);

Within _paymentService.CollectPaymentMethod

var tcs = new TaskCompletionSource<SCPPaymentIntent>();
var displayDelegate = new StripePaymentServiceDelegates.ReaderDisplayDelegate(readerDisplayCallback, _resourcesService);

using (await _transactionLock.LockAsync(ct))
{
_collectPaymentMethodCancelable = SCPTerminal.Shared.CollectPaymentMethod(intent.Intent, displayDelegate, (paymentIntent, error) =>
{
    if (paymentIntent != null)
    {
        tcs.TrySetResult(paymentIntent);
    }
    else
    {
        SetExceptionFromStripeError(tcs, error, "CollectPaymentMethod failed");
    }
});
}

iOS version

12+

Installation method

N/A

SDK version

SDK Version is 1.3.0

Other information

davidme-stripe commented 3 years ago

Hello! Sorry to redirect you elsewhere, but could you repost this in https://github.com/stripe/stripe-terminal-ios/issues? This issues page is for the in-app payment SDK.

DanielCauser commented 3 years ago

In case folk in the future arrive in this issue, I created the other issue at: https://github.com/stripe/stripe-terminal-ios/issues/112