NEFT and RTGS transaction error resolved
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
// ignore_for_file: unused_local_variable
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import '../../data/repositories/auth_repository.dart';
|
import '../../data/repositories/auth_repository.dart';
|
||||||
|
|
||||||
|
@@ -29,5 +29,3 @@ class ImpsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@ class NeftService {
|
|||||||
'NEFT transaction failed with status code: ${response.statusCode}');
|
'NEFT transaction failed with status code: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} on DioException {
|
} on DioException {
|
||||||
|
print('DioException Occured');
|
||||||
rethrow;
|
rethrow;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Exception('An unexpected error occurred: ${e.toString()}');
|
throw Exception('An unexpected error occurred: ${e.toString()}');
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:kmobile/data/models/imps_transaction.dart';
|
|
||||||
import 'package:kmobile/data/models/rtgs_response.dart';
|
import 'package:kmobile/data/models/rtgs_response.dart';
|
||||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||||
|
|
||||||
@@ -29,6 +28,4 @@ class RtgsService {
|
|||||||
throw Exception('An unexpected error occurred: ${e.toString()}');
|
throw Exception('An unexpected error occurred: ${e.toString()}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processImpsTransaction(ImpsTransaction impsTx) {}
|
|
||||||
}
|
}
|
||||||
|
@@ -2,40 +2,40 @@ import 'package:flutter/material.dart';
|
|||||||
import 'theme_type.dart';
|
import 'theme_type.dart';
|
||||||
|
|
||||||
class AppThemes {
|
class AppThemes {
|
||||||
static ThemeData getLightTheme(ThemeType type) {
|
static ThemeData getLightTheme(ThemeType type) {
|
||||||
// Define a seed color based on the theme type
|
// Define a seed color based on the theme type
|
||||||
final Color seedColor;
|
final Color seedColor;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ThemeType.green:
|
case ThemeType.green:
|
||||||
seedColor = Colors.green;
|
seedColor = Colors.green;
|
||||||
break;
|
break;
|
||||||
case ThemeType.orange:
|
case ThemeType.orange:
|
||||||
seedColor = Colors.orange;
|
seedColor = Colors.orange;
|
||||||
break;
|
break;
|
||||||
case ThemeType.blue:
|
case ThemeType.blue:
|
||||||
seedColor = Colors.blue;
|
seedColor = Colors.blue;
|
||||||
break;
|
break;
|
||||||
case ThemeType.violet:
|
case ThemeType.violet:
|
||||||
default:
|
default:
|
||||||
seedColor = Colors.deepPurple;
|
seedColor = Colors.deepPurple;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a ColorScheme from the seed color
|
// Create a ColorScheme from the seed color
|
||||||
final colorScheme = ColorScheme.fromSeed(
|
final colorScheme = ColorScheme.fromSeed(
|
||||||
seedColor: seedColor,
|
seedColor: seedColor,
|
||||||
brightness: Brightness.light, // Explicitly set for a light theme
|
brightness: Brightness.light, // Explicitly set for a light theme
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the ThemeData from the ColorScheme
|
// Create the ThemeData from the ColorScheme
|
||||||
return ThemeData.from(
|
return ThemeData.from(
|
||||||
colorScheme: colorScheme,
|
colorScheme: colorScheme,
|
||||||
useMaterial3: true, // Recommended for modern Flutter apps
|
useMaterial3: true, // Recommended for modern Flutter apps
|
||||||
).copyWith(
|
).copyWith(
|
||||||
scaffoldBackgroundColor: Colors.white,
|
scaffoldBackgroundColor: Colors.white,
|
||||||
bottomNavigationBarTheme: BottomNavigationBarThemeData(
|
bottomNavigationBarTheme: BottomNavigationBarThemeData(
|
||||||
backgroundColor: colorScheme.surface,
|
backgroundColor: colorScheme.surface,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -62,7 +62,7 @@ Dio _createDioClient() {
|
|||||||
BaseOptions(
|
BaseOptions(
|
||||||
baseUrl:
|
baseUrl:
|
||||||
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
||||||
// 'http://localhost:8081',
|
//'http://localhost:8081',
|
||||||
connectTimeout: const Duration(seconds: 5),
|
connectTimeout: const Duration(seconds: 5),
|
||||||
receiveTimeout: const Duration(seconds: 10),
|
receiveTimeout: const Duration(seconds: 10),
|
||||||
headers: {
|
headers: {
|
||||||
|
@@ -281,21 +281,21 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
tx.type == 'CR' ? Colors.green : Colors.red,
|
tx.type == 'CR' ? Colors.green : Colors.red,
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
tx.date ?? '',
|
tx.date ?? '',
|
||||||
style: const TextStyle(fontSize: 15),
|
style: const TextStyle(fontSize: 15),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
tx.name != null
|
tx.name != null
|
||||||
? (tx.name!.length > 18
|
? (tx.name!.length > 18
|
||||||
? tx.name!.substring(0, 22)
|
? tx.name!.substring(0, 22)
|
||||||
: tx.name!)
|
: tx.name!)
|
||||||
: '',
|
: '',
|
||||||
style: const TextStyle(fontSize: 12),
|
style: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
"₹${tx.amount}",
|
"₹${tx.amount}",
|
||||||
style: const TextStyle(fontSize: 17),
|
style: const TextStyle(fontSize: 17),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
@@ -308,8 +308,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) {
|
separatorBuilder: (context, index) {
|
||||||
return const Divider();
|
return const Divider();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@@ -576,7 +576,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
style: const TextStyle(fontSize: 15),
|
style: const TextStyle(fontSize: 15),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
tx.name != null
|
tx.name != null
|
||||||
? (tx.name!.length > 18
|
? (tx.name!.length > 18
|
||||||
? tx.name!.substring(0, 22)
|
? tx.name!.substring(0, 22)
|
||||||
: tx.name!)
|
: tx.name!)
|
||||||
|
@@ -50,7 +50,7 @@ class AccountCard extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
account.accountNumber,
|
account.accountNumber,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:Theme.of(context).scaffoldBackgroundColor, fontSize: 16),
|
color: Theme.of(context).scaffoldBackgroundColor, fontSize: 16),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Text(
|
Text(
|
||||||
|
@@ -107,35 +107,50 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
|||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
print('dio exception');
|
print(e);
|
||||||
print(e.toString());
|
String errorMessage;
|
||||||
|
if (e.response != null && e.response!.data != null) {
|
||||||
final error = jsonDecode(e.response.toString())['error'];
|
print('error has data');
|
||||||
var errorMessage = {
|
try {
|
||||||
"INCORRECT_TPIN":
|
// final error = jsonDecode(e.response!.toString())['error'];
|
||||||
AppLocalizations.of(context).correctTpin,
|
final error = e.response?.data['error'];
|
||||||
"INSUFFICIENT_FUNDS":
|
print('actual error message $error');
|
||||||
AppLocalizations.of(context).insufficientFund
|
errorMessage = {
|
||||||
}[error] ??
|
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||||
AppLocalizations.of(context).somethingWentWrong;
|
"INSUFFICIENT_FUNDS":
|
||||||
|
"Your account does not have sufficient balance"
|
||||||
|
}[error] ??
|
||||||
|
"Something Went Wrong";
|
||||||
|
} catch (_) {
|
||||||
|
print('error extracting errorMessage');
|
||||||
|
errorMessage = "Something Went Wrong";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print('has has no data');
|
||||||
|
errorMessage = "Something Went Wrong";
|
||||||
|
}
|
||||||
|
print('PaymentResponse generating');
|
||||||
final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
isSuccess: false,
|
isSuccess: false,
|
||||||
errorMessage: errorMessage,
|
errorMessage: errorMessage,
|
||||||
);
|
);
|
||||||
|
print('PaymentResponse generated');
|
||||||
|
print(paymentResponse);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
|
print("NEFT transaction failed with DioException."); // Add
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('generic exception');
|
print('generic exception');
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
isSuccess: false,
|
isSuccess: false,
|
||||||
errorMessage:
|
errorMessage: AppLocalizations.of(pinScreenContext)
|
||||||
AppLocalizations.of(context).somethingWentWrong,
|
.somethingWentWrong,
|
||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
|
print(
|
||||||
|
"NEFT transaction failed with generic exception."); // Add
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//IMPS transaction
|
//IMPS transaction
|
||||||
else if (_selectedMode == TransactionMode.imps) {
|
else if (_selectedMode == TransactionMode.imps) {
|
||||||
final impsTx = ImpsTransaction(
|
final impsTx = ImpsTransaction(
|
||||||
@@ -195,7 +210,9 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
|||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
//RTGS
|
||||||
|
else {
|
||||||
final rtgsTx = RtgsTransaction(
|
final rtgsTx = RtgsTransaction(
|
||||||
fromAccount: widget.debitAccountNo,
|
fromAccount: widget.debitAccountNo,
|
||||||
toAccount: widget.creditBeneficiary.accountNo,
|
toAccount: widget.creditBeneficiary.accountNo,
|
||||||
@@ -233,13 +250,12 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
|||||||
|
|
||||||
final error = jsonDecode(e.response.toString())['error'];
|
final error = jsonDecode(e.response.toString())['error'];
|
||||||
var errorMessage = {
|
var errorMessage = {
|
||||||
"INCORRECT_TPIN":
|
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||||
AppLocalizations.of(context).correctTpin,
|
|
||||||
"INSUFFICIENT_FUNDS":
|
"INSUFFICIENT_FUNDS":
|
||||||
AppLocalizations.of(context).insufficientFund
|
"Your account does not have sufficient balance"
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
}[error] ??
|
}[error] ??
|
||||||
AppLocalizations.of(context).somethingWentWrong;
|
"Something Went Wrong";
|
||||||
|
|
||||||
final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
isSuccess: false,
|
isSuccess: false,
|
||||||
@@ -251,8 +267,7 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
|||||||
print(e.toString());
|
print(e.toString());
|
||||||
final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
isSuccess: false,
|
isSuccess: false,
|
||||||
errorMessage:
|
errorMessage: "Something Went Wrong",
|
||||||
AppLocalizations.of(context).somethingWentWrong,
|
|
||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
// ignore_for_file: use_build_context_synchronously
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:kmobile/api/services/imps_service.dart';
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
import 'package:kmobile/api/services/neft_service.dart';
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
@@ -214,6 +215,38 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
utr: neftResponse.utr,
|
utr: neftResponse.utr,
|
||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
print(e);
|
||||||
|
String errorMessage;
|
||||||
|
if (e.response != null && e.response!.data != null) {
|
||||||
|
print('error has data');
|
||||||
|
try {
|
||||||
|
// final error = jsonDecode(e.response!.toString())['error'];
|
||||||
|
final error = e.response?.data['error'];
|
||||||
|
print('actual error message $error');
|
||||||
|
errorMessage = {
|
||||||
|
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||||
|
"INSUFFICIENT_FUNDS":
|
||||||
|
"Your account does not have sufficient balance"
|
||||||
|
}[error] ??
|
||||||
|
"Something Went Wrong";
|
||||||
|
} catch (_) {
|
||||||
|
print('error extracting errorMessage');
|
||||||
|
errorMessage = "Something Went Wrong";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print('has has no data');
|
||||||
|
errorMessage = "Something Went Wrong";
|
||||||
|
}
|
||||||
|
print('PaymentResponse generating');
|
||||||
|
final paymentResponse = PaymentResponse(
|
||||||
|
isSuccess: false,
|
||||||
|
errorMessage: errorMessage,
|
||||||
|
);
|
||||||
|
print('PaymentResponse generated');
|
||||||
|
print(paymentResponse);
|
||||||
|
completer.complete(paymentResponse);
|
||||||
|
print("NEFT transaction failed with DioException."); // Add
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
isSuccess: false,
|
isSuccess: false,
|
||||||
@@ -245,15 +278,32 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final neftResponse =
|
final impsResponse =
|
||||||
await impsService.processImpsTransaction(impsTx);
|
await impsService.processImpsTransaction(impsTx);
|
||||||
final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
isSuccess: neftResponse.message.toUpperCase() == 'SUCCESS',
|
isSuccess: impsResponse.message.toUpperCase() == 'SUCCESS',
|
||||||
date: DateTime.now(),
|
date: DateTime.now(),
|
||||||
creditedAccount: impsTx.toAccount,
|
creditedAccount: impsTx.toAccount,
|
||||||
amount: impsTx.amount,
|
amount: impsTx.amount,
|
||||||
currency: 'INR',
|
currency: 'INR',
|
||||||
utr: neftResponse.utr,
|
utr: impsResponse.utr,
|
||||||
|
);
|
||||||
|
completer.complete(paymentResponse);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
print('dio exception');
|
||||||
|
print(e.toString());
|
||||||
|
|
||||||
|
final error = e.response?.data['error'];
|
||||||
|
var errorMessage = {
|
||||||
|
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||||
|
"INSUFFICIENT_FUNDS":
|
||||||
|
"Your account does not have sufficient balance"
|
||||||
|
}[error] ??
|
||||||
|
"Something Went Wrong";
|
||||||
|
|
||||||
|
final paymentResponse = PaymentResponse(
|
||||||
|
isSuccess: false,
|
||||||
|
errorMessage: errorMessage,
|
||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -298,6 +348,25 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
utr: rtgsResponse.utr,
|
utr: rtgsResponse.utr,
|
||||||
);
|
);
|
||||||
completer.complete(paymentResponse);
|
completer.complete(paymentResponse);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
print('dio exception');
|
||||||
|
print(e.toString());
|
||||||
|
|
||||||
|
final error = e.response?.data['error'];
|
||||||
|
var errorMessage = {
|
||||||
|
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||||
|
"INSUFFICIENT_FUNDS":
|
||||||
|
"Your account does not have sufficient balance"
|
||||||
|
// ignore: duplicate_ignore
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
}[error] ??
|
||||||
|
"Something Went Wrong";
|
||||||
|
|
||||||
|
final paymentResponse = PaymentResponse(
|
||||||
|
isSuccess: false,
|
||||||
|
errorMessage: errorMessage,
|
||||||
|
);
|
||||||
|
completer.complete(paymentResponse);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final paymentResponse = PaymentResponse(
|
final paymentResponse = PaymentResponse(
|
||||||
isSuccess: false,
|
isSuccess: false,
|
||||||
|
Reference in New Issue
Block a user