Skip to content

Instantly share code, notes, and snippets.

@ijogendrajat
Created April 16, 2024 06:13
Show Gist options
  • Save ijogendrajat/c03c75eccbcc47bbc07913855481c99c to your computer and use it in GitHub Desktop.
Save ijogendrajat/c03c75eccbcc47bbc07913855481c99c to your computer and use it in GitHub Desktop.
Handle Transaction Error
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