Beneficiary Localization Chamges

This commit is contained in:
2025-08-14 16:15:35 +05:30
parent f48bfabb4a
commit e2a809d363
12 changed files with 324 additions and 39 deletions

View File

@@ -15,3 +15,4 @@ class ThemeState extends Equatable {
@override
List<Object?> get props => [themeType];
}

View File

@@ -1,8 +1,6 @@
// ignore_for_file: avoid_print
import 'dart:async';
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/neft_service.dart';
@@ -70,13 +68,13 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: const Text('Invalid Amount for RTGS'),
content: const Text(
'RTGS transactions require a minimum amount of 200,000. Please enter a higher amount or select NEFT as the transaction mode.'),
title: Text(AppLocalizations.of(context).invalidRtgs),
content: Text(
AppLocalizations.of(context).invalidRtgsPopUp),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('OK'),
child: Text(AppLocalizations.of(context).ok),
),
],
),
@@ -129,9 +127,9 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
final error = jsonDecode(e.response.toString())['error'];
var errorMessage =
{
"INCORRECT_TPIN" : "Please Enter the correct TPIN",
"INSUFFICIENT_FUNDS": "Your account does not have sufficient balance"
}[error] ?? "Something Went Wrong";
"INCORRECT_TPIN" : AppLocalizations.of(context).correctTpin,
"INSUFFICIENT_FUNDS": AppLocalizations.of(context).insufficientFund
}[error] ?? AppLocalizations.of(context).somethingWentWrong;
final paymentResponse = PaymentResponse(
isSuccess: false,
@@ -143,11 +141,70 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
print(e.toString());
final paymentResponse = PaymentResponse(
isSuccess: false,
errorMessage: "Something went Wrong",
errorMessage: AppLocalizations.of(context).somethingWentWrong,
);
completer.complete(paymentResponse);
}
} else {
}
// else if (_selectedMode == TransactionMode.imps){
// final rtgsTx = RtgsTransaction(
// fromAccount: widget.debitAccountNo,
// toAccount: widget.creditBeneficiary.accountNo,
// amount: _amountController.text,
// ifscCode: widget.creditBeneficiary.ifscCode,
// remitterName: widget.remitterName,
// beneficiaryName: widget.creditBeneficiary.name,
// tpin: tpin,
// );
// final rtgsService = getIt<RtgsService>();
// final completer = Completer<PaymentResponse>();
// Navigator.of(pinScreenContext).pushReplacement(
// MaterialPageRoute(
// builder: (_) => PaymentAnimationScreen(
// paymentResponse: completer.future),
// ),
// );
// try {
// final rtgsResponse =
// await rtgsService.processRtgsTransaction(rtgsTx);
// final paymentResponse = PaymentResponse(
// isSuccess: rtgsResponse.message.toUpperCase() == 'SUCCESS',
// date: DateTime.now(),
// creditedAccount: rtgsTx.toAccount,
// amount: rtgsTx.amount,
// currency: 'INR',
// utr: rtgsResponse.utr,
// );
// completer.complete(paymentResponse);
// } on DioException catch(e) {
// print('dio exception');
// print(e.toString());
// final error = jsonDecode(e.response.toString())['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) {
// print('generic exception');
// print(e.toString());
// final paymentResponse = PaymentResponse(
// isSuccess: false,
// errorMessage: "Something went Wrong",
// );
// completer.complete(paymentResponse);
// }
// }
else {
final rtgsTx = RtgsTransaction(
fromAccount: widget.debitAccountNo,
toAccount: widget.creditBeneficiary.accountNo,
@@ -186,9 +243,10 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
final error = jsonDecode(e.response.toString())['error'];
var errorMessage =
{
"INCORRECT_TPIN" : "Please Enter the correct TPIN",
"INSUFFICIENT_FUNDS": "Your account does not have sufficient balance"
}[error] ?? "Something Went Wrong";
"INCORRECT_TPIN" : AppLocalizations.of(context).correctTpin,
"INSUFFICIENT_FUNDS": AppLocalizations.of(context).insufficientFund
// ignore: use_build_context_synchronously
}[error] ?? AppLocalizations.of(context).somethingWentWrong;
final paymentResponse = PaymentResponse(
isSuccess: false,
@@ -200,7 +258,7 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
print(e.toString());
final paymentResponse = PaymentResponse(
isSuccess: false,
errorMessage: "Something went Wrong",
errorMessage: AppLocalizations.of(context).somethingWentWrong,
);
completer.complete(paymentResponse);
}
@@ -248,7 +306,7 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
// Credit Account (Beneficiary)
Text(
"Credit To",
AppLocalizations.of(context).creditedTo,
style: Theme.of(context).textTheme.titleSmall,
),
Card(
@@ -264,7 +322,7 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
// Transaction Mode Selection
Text(
"Select Transaction Mode",
AppLocalizations.of(context).selectTransactionType,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 12),
@@ -292,15 +350,19 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
selectedBorderColor: Colors.transparent,
splashColor: Theme.of(context).primaryColor.withOpacity(0.1),
highlightColor: Theme.of(context).primaryColor.withOpacity(0.05),
children: const [
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
child: Text('NEFT'),
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
child: Text(AppLocalizations.of(context).neft),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
child: Text('RTGS'),
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
child: Text(AppLocalizations.of(context).rtgs),
),
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
// child: Text(AppLocalizations.of(context).imps),
// ),
],
),
),
@@ -336,7 +398,7 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
),
child: const Text("Proceed"),
child: Text(AppLocalizations.of(context).proceed),
),
),
],

View File

@@ -1,4 +1,5 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:kmobile/api/services/neft_service.dart';
import 'package:kmobile/api/services/rtgs_service.dart';
import 'package:kmobile/data/models/neft_transaction.dart';
@@ -83,7 +84,6 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
final String accountNo = accountNumberController.text.trim();
final String ifsc = ifscController.text.trim();
// TODO: Replace with actual remitter name
// ignore: prefer_const_declarations
final String remitter = "Unknown";
@@ -141,8 +141,8 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
if (_formKey.currentState!.validate()) {
if (!_isBeneficiaryValidated) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Please validate beneficiary details first.')),
SnackBar(
content: Text(AppLocalizations.of(context).plsValidateBeneficiary)),
);
return;
}
@@ -155,13 +155,12 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: const Text('Invalid Amount for RTGS'),
content: const Text(
'RTGS transactions require a minimum amount of 200,000. Please enter a higher amount or select NEFT as the transaction mode.'),
title: Text(AppLocalizations.of(context).invalidRtgs),
content: Text(AppLocalizations.of(context).invalidRtgsPopUp),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('OK'),
child: Text(AppLocalizations.of(context).ok),
),
],
),
@@ -346,7 +345,7 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context).accountNumberRequired;
} else if (value.length < 7 || value.length > 20) {
return 'Account number must be between 7 and 20 digits';
return AppLocalizations.of(context).accno7to20;
}
return null;
},
@@ -385,6 +384,10 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
children: [
Expanded(
child: TextFormField(
maxLength: 11,
inputFormatters: [
LengthLimitingTextInputFormatter(11),
],
decoration: InputDecoration(
labelText: AppLocalizations.of(context).ifscCode,
border: const OutlineInputBorder(),
@@ -520,7 +523,7 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
} else {
setState(() {
_validationError =
'Account numbers do not match.';
AppLocalizations.of(context).accountMismatch;
});
}
},
@@ -531,7 +534,7 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
child: CircularProgressIndicator(
strokeWidth: 2),
)
: const Text('Validate Beneficiary'),
: Text(AppLocalizations.of(context).validateBeneficiary),
),
),
),

View File

@@ -212,7 +212,7 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
} else {
setState(() {
_validationError =
'Please enter a valid and matching account number.';
AppLocalizations.of(context).accountMismatch;
});
}
},
@@ -222,7 +222,7 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Text('Validate Beneficiary'),
: Text(AppLocalizations.of(context).validateBeneficiary),
),
),
),
@@ -234,7 +234,7 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
const Icon(Icons.check_circle, color: Colors.green),
const SizedBox(width: 8),
Text(
'Beneficiary: $_beneficiaryName',
'${AppLocalizations.of(context).beneficiaryName}: $_beneficiaryName',
style: const TextStyle(
color: Colors.green, fontWeight: FontWeight.bold),
),
@@ -338,7 +338,7 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
if (!_isBeneficiaryValidated) {
setState(() {
_validationError =
'Please validate beneficiary before proceeding.';
AppLocalizations.of(context).validateBeneficiaryproceeding;
});
return;
}