Created
April 16, 2024 06:13
-
-
Save ijogendrajat/c03c75eccbcc47bbc07913855481c99c to your computer and use it in GitHub Desktop.
Handle Transaction Error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void handleSdkResponse(String sdkResponse) { | |
if (sdkResponse.isNotEmpty) { | |
try { | |
final responseJson = jsonDecode(sdkResponse); | |
if (responseJson['success'] == false) { | |
// Implement your ui part here | |
final errorCode = responseJson['errorCode'].toString(); | |
final errorMessage = responseJson['error'].toString(); | |
final transactionId = responseJson['transaction']; | |
print('Error: $errorCode - $errorMessage (Transaction: $transactionId)'); | |
} | |
} on FormatException catch (e) { | |
print('Invalid JSON format: $e'); | |
} catch (e) { | |
print('Error processing SDK response: $e'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment