datatrans / android-sample-app

sample android app which integrates the datatrans library
https://docs.datatrans.ch/docs/integrations-mobile-sdk
0 stars 13 forks source link

Handling Error Message from Datatrans SDK #10

Closed khanhnt3010 closed 3 years ago

khanhnt3010 commented 3 years ago

As document: Three kinds of exceptions exist in the library which are treated differently: • Technical exceptions: network interruption, memory or I/O errors • Business exceptions: verification failure, authentication failure, authorization failure. The business exception object may be a generic object of type BusinessException or a specialized subclass (i.e. TWINTNotInstalledException, see 4.1.1) in order to provide additional information for tailored error messages. • SSL exceptions: An SSLException can occur if the SSL handshake fails in the WebView for API levels 16-18 (TLS 1.2) or if the certificate chain is invalid and pinning is enabled.

In my product business, I would like to show specific for the user, this will help user figure out what happened. Do we have any document about error code? (this document cannot help me: https://docs.datatrans.ch/docs/error-messages) Sample code: if (exception is BusinessException) { val errorCode = exception.errorCode Timber.d(">>>error errorCode = $errorCode, ${exception.message}") }

Log received:

>>> error errorCode = 1403, declined (N)

khanhnt3010 commented 3 years ago

@dmengelt Could you please take a look?

dmengelt commented 3 years ago

https://docs.datatrans.ch/v1.0.1/docs/api-response-codes

khanhnt3010 commented 3 years ago

Thank you so much @dmengelt

khanhnt3010 commented 3 years ago

Hi @dmengelt, if I add wrong CVV card number. The error code received is: >>> error errorCode = -50, Declined Error code is not exist in the document :(

dmengelt commented 3 years ago

Can you share a transactionId with me?

khanhnt3010 commented 3 years ago

TransactionId: 210310111522917176 I'm using Visa testcard: 4242424242424242 with wrong CVV

dmengelt commented 3 years ago

Yeah unfortunately -50 is not getting "translated" to 1403 properly. This is a bug and we will release a new version of the SDKs in the upcoming days. However, this should not be an issue for you as the mapping will be:

-50 = 1403 = transaction declined without any further reason

So you can see that a "wrong CVV" will also result in a "general decline". This is because we usually do not receive the information if the CVV is wrong from the acquirers. You must display a general error message to the user in this case.

khanhnt3010 commented 3 years ago

Yeah, Thank you so much @dmengelt. You helped me a lot :) I have another question, why don't we localize errors messages like the iOS SDK?