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