Manage Beneficiary Services
This commit is contained in:
@@ -49,6 +49,54 @@ class BeneficiaryService {
|
||||
return null;
|
||||
|
||||
}
|
||||
///Step 1: Validate beneficiary (returns refNo)
|
||||
Future<String?> validateBeneficiary({
|
||||
required String accountNo,
|
||||
required String ifscCode,
|
||||
required String remitterName,
|
||||
}) async {
|
||||
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
'/api/beneficiary/validate/outside_bank',
|
||||
queryParameters: {
|
||||
'accountNo': accountNo,
|
||||
'ifscCode': ifscCode,
|
||||
'remitterName': remitterName,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['refNo'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error validating beneficiary: $e");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Step 2: Check validation status (returns Beneficiary name if success)
|
||||
Future<String?> checkValidationStatus(String refNo) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'/api/beneficiary/check',
|
||||
queryParameters: {
|
||||
'refNo': refNo,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200 && response.data != null) {
|
||||
return Beneficiary.fromJson(response.data).name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error checking validation status: $e");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Send Data for Validation
|
||||
Future<void> sendForValidation(Beneficiary beneficiary) async {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
|
||||
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
|
||||
class Beneficiary {
|
||||
final String accountNo;
|
||||
final String accountType;
|
||||
@@ -18,8 +20,6 @@ class Beneficiary {
|
||||
});
|
||||
|
||||
factory Beneficiary.fromJson(Map<String, dynamic> json) {
|
||||
print('==============================');
|
||||
print(json);
|
||||
return Beneficiary(
|
||||
accountNo: json['accountNo'] ?? '',
|
||||
accountType: json['accountType'] ?? '',
|
||||
@@ -29,7 +29,7 @@ class Beneficiary {
|
||||
branchName: json['branchName'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'accountNo': accountNo,
|
||||
|
@@ -1,3 +1,5 @@
|
||||
// ignore_for_file: prefer_final_fields, unused_field
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
|
@@ -42,7 +42,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
baseColor: Colors.grey.shade300,
|
||||
highlightColor: Colors.grey.shade100,
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
leading: const CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
|
@@ -1,3 +1,5 @@
|
||||
// ignore_for_file: unused_field
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shimmer/main.dart';
|
||||
import 'di/injection.dart';
|
||||
import 'app.dart';
|
||||
|
||||
|
Reference in New Issue
Block a user