checkout / frames-ios

Frames iOS: making native card payments simple

Home Page:https://www.checkout.com/docs/integrate/sdks/ios-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CheckoutAPIClient never throws an error if an unexpected error occurs

PiotrPawlus opened this issue · comments

Describe the bug
If you are using CheckoutAPIClient for both methods

  • createCardToken(card:_, successHandler:_, errorHandler:_) - Line 98, Line 105
  • createApplePayToken(paymentData:_, successHandler: _, errorHandler:_) - Line 134, Line 142
    will never throw an unexpected error if occurs.

To Reproduce
Steps to reproduce the behaviour:

  1. Have invalid expired credentials to the sandbox
  2. Create CheckoutAPIClient
  3. Request createCardToken or createApplePayToken
  4. Expectations are not handled

Expected behaviour
In both cases Frames should throw an error which will allow to handle it on the application side.

Hi @PiotrPawlus

When you say invalid expired credentials you mean a wrong public API key?
Checkout.com public API keys don't expire today, the only way to invalidate them is for them to be manually refreshed from the merchant's account configuration.

I agree this can be improved though, any suggestion of the type of exception you'd expect there?
Feel free to send a pull request and someone from the team will review it.

Thanks

Hi @PiotrPawlus,
I added new pull request which can fix the problem you described. Hope, it will be merged soon.

Thanks @christianvershkov for the PR. 3.2.0 now includes NetworkError via two new methods:

public func createCardToken(
        card: CkoCardTokenRequest,
        completion: @escaping ((Swift.Result<CkoCardTokenResponse, NetworkError>) -> Void)
    )

public func createApplePayToken(
        paymentData: Data,
        completion: @escaping ((Swift.Result<CkoCardTokenResponse, NetworkError>) -> Void)
    )