Adyen / adyen-ios

Adyen iOS Drop-in and Components
https://docs.adyen.com/checkout/ios
MIT License
150 stars 119 forks source link

[BUG] PollingComponent doesn't support network error and fails even though payment succeeds #692

Closed alekpopek closed 2 years ago

alekpopek commented 2 years ago

Describe the bug PollingComponent doesn't support network error and it calls didFail delegate method even though a payment did finish with success.

To Reproduce Steps to reproduce the behavior:

  1. Initiate BLIK payment
  2. Open banking app to get blik code
  3. Go back to the app an enter the code
  4. Click Pay button in DropIn UI
  5. Open Banking app to confirm payment
  6. Go back to the app
  7. Payment succeeds
  8. DropInComponentDelegate didFail(with error: Error, from component: DropInComponent) is called because of network error

Expected behavior PollingComponent should handle network error and repeat API calls until it gets a proper response.

Logs

2021-11-05 12:58:26.257378+0100 Task <97A5706D-5EB2-4D74-9D62-B9BB6614EDAC>.<3> HTTP load failed, 478/0 bytes (error code: -1005 [4:-4])
2021-11-05 12:58:26.260411+0100 Connection 28: received failure notification
2021-11-05 12:58:26.260968+0100 Task <97A5706D-5EB2-4D74-9D62-B9BB6614EDAC>.<3> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "Połączenie sieciowe zostało utracone." UserInfo={_kCFStreamErrorCodeKey=-4, NSUnderlyingError=0x281b83060 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x2835d61c0 [0x20c1d9860]>{length = 16, capacity = 16, bytes = 0x100201bbc14382440000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <97A5706D-5EB2-4D74-9D62-B9BB6614EDAC>.<3>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <97A5706D-5EB2-4D74-9D62-B9BB6614EDAC>.<3>"
), NSLocalizedDescription=Połączenie sieciowe zostało utracone., NSErrorFailingURLStringKey=https://checkoutshopper-live.adyen.com/checkoutshopper/services/PaymentInitiation/v1/status?clientKey=live_{hidden}, NSErrorFailingURLKey=https://checkoutshopper-live.adyen.com/checkoutshopper/services/PaymentInitiation/v1/status?clientKey=live_{hidden}, _kCFStreamErrorDomainKey=4}
2021-11-05 12:58:26.266614+0100 Connection 27: received failure notification
2021-11-05 12:58:48.221508+0100 Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
descorp commented 2 years ago

Hey @alekpopek

Indeed, after returning to foreground, sometimes NSUrlSession is corrupted and first request might lead to en error. We will add some error threshold.

UPD

This PR #693 should do the trick?

alekpopek commented 2 years ago

Thanks @descorp It's pretty urgent because it happens on our live app from time to time.

descorp commented 2 years ago

@alekpopek

will be patched up and released this week :) Thanks for pointing out the issue!

descorp commented 2 years ago

Hey @alekpopek

4.4.0 was released with fix for PollingComponent.

alekpopek commented 2 years ago

Thank You! :tada:

descorp commented 2 years ago

Could you verify it does the job for you?

alekpopek commented 2 years ago

Yes. It was tested last week and I can confirm that It works. Thank You