35 lines
910 B
Dart
35 lines
910 B
Dart
import 'dart:developer';
|
|
|
|
import 'package:dio/dio.dart';
|
|
import 'package:kmobile/data/models/neft_response.dart';
|
|
import 'package:kmobile/data/models/neft_transaction.dart';
|
|
|
|
class NeftService {
|
|
final Dio _dio;
|
|
|
|
NeftService(this._dio);
|
|
|
|
Future<NeftResponse> processNeftTransaction(
|
|
NeftTransaction transaction) async {
|
|
try {
|
|
await Future.delayed(const Duration(seconds: 3));
|
|
final response = await _dio.post(
|
|
'/api/payment/neft',
|
|
data: transaction.toJson(),
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
return NeftResponse.fromJson(response.data);
|
|
} else {
|
|
throw Exception(
|
|
'NEFT transaction failed with status code: ${response.statusCode}');
|
|
}
|
|
} on DioException {
|
|
log('DioException Occured');
|
|
rethrow;
|
|
} catch (e) {
|
|
throw Exception('An unexpected error occurred: ${e.toString()}');
|
|
}
|
|
}
|
|
}
|