34 lines
851 B
Dart
34 lines
851 B
Dart
import 'package:dio/dio.dart';
|
|
import 'package:kmobile/data/models/imps_response.dart';
|
|
import 'package:kmobile/data/models/imps_transaction.dart';
|
|
|
|
class ImpsService {
|
|
final Dio _dio;
|
|
|
|
ImpsService(this._dio);
|
|
|
|
Future<ImpsResponse> processImpsTransaction(
|
|
ImpsTransaction transaction) async {
|
|
try {
|
|
await Future.delayed(const Duration(seconds: 3));
|
|
final response = await _dio.post(
|
|
'/api/payment/rtgs',
|
|
data: transaction.toJson(),
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
return ImpsResponse.fromJson(response.data);
|
|
} else {
|
|
throw Exception(
|
|
'RTGS transaction failed with status code: ${response.statusCode}');
|
|
}
|
|
} on DioException {
|
|
rethrow;
|
|
} catch (e) {
|
|
throw Exception('An unexpected error occurred: ${e.toString()}');
|
|
}
|
|
}
|
|
}
|
|
|
|
|