frames-android icon indicating copy to clipboard operation
frames-android copied to clipboard

Error codes for the CardTokenRequest

Open september669 opened this issue 3 years ago • 0 comments

Hello We are using version 3.x.x And we don't use your UI, but only API part. So we are processing error: CardTokenisationFail to show error messages to our users.

api.setTokenListener(
                object : CheckoutAPIClient.OnTokenGenerated {
                    override fun onNetworkError(error: NetworkError) {
                        Timber.e(error)
                        deferred.completeExceptionally(error)
                    }

                    override fun onTokenGenerated(response: CardTokenisationResponse) {
                        deferred.complete(response.token)
                    }

                    override fun onError(error: CardTokenisationFail) {
                        Timber.e("request_id: ${error.requestId}\nerror_type: ${error.errorType}\nerror_codes: ${Arrays.toString(error.errorCodes)}")
                        deferred.completeExceptionally(CardTokenisationException(error.requestId, error.errorType, error.errorCodes))
                    }
                }
            )

Now we are going to update lib version to 4.x.x But in CardTokenRequest (as I understand it is a replacement for the CheckoutAPIClient.OnTokenGenerated) there is no error code and error.errorType, only errorMessage. We can't use errorMessage for mapping to the our messages, it is highly unreliable.

public data class CardTokenRequest(
    val card: Card,
    val onSuccess: (tokenDetails: TokenDetails) -> Unit,
    val onFailure: (errorMessage: String) -> Unit
)
https://github.com/checkout/frames-android/blob/fc90c00c05ac76e77d148935a1b02023f14aad0a/checkout/src/main/java/com/checkout/tokenization/model/CardTokenRequest.kt#L9

Is it possible to add an error code and error type to CardTokenRequest? Or is there another way to create a card token?

september669 avatar May 25 '23 09:05 september669