completed velocity integration

This commit is contained in:
2026-05-27 19:01:24 +02:00
parent fec46fb6e9
commit 6fdd3183fb
29 changed files with 2760 additions and 2293 deletions

View File

@@ -3,6 +3,7 @@ import 'package:go_router/go_router.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:provider/provider.dart';
import 'package:qpay/http/http.dart';
import 'package:qpay/models/api_response.dart';
import 'package:qpay/screens/pay/pay_controller.dart' as pc;
import 'package:qpay/screens/transaction_controller.dart' as tc;
import 'package:qpay/screens/home/home_controller.dart' as hc;
@@ -29,50 +30,43 @@ class ReceiptController extends ChangeNotifier {
);
}
void _showErrorSnackBar(String? message) {
WidgetsBinding.instance.addPostFrameCallback((_) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message.toString()),
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.deepOrange,
),
);
});
}
void setLoading(bool value) {
model.isLoading = value;
notifyListeners();
}
Future<void> doIntegration(String id) async {
Future<ApiResponse<Map<String, dynamic>>> doIntegration(String id) async {
try {
model.isLoading = true;
model.status = '';
notifyListeners();
dynamic workflowResponse = await http.get(
'/public/transaction/integration/$id'
'/public/transaction/integration/$id',
);
logger.i(workflowResponse.toString());
dynamic response = workflowResponse['body'];
model.isLoading = false;
if (response['status'] == 'SUCCESS') {
model.status = response['status'];
transactionController.updateReceiptData(response);
notifyListeners();
return ApiResponse.success(Map<String, dynamic>.from(response));
} else {
model.status = response['status'];
model.errorMessage = response['errorMessage'];
_showErrorSnackBar(response['errorMessage']);
notifyListeners();
return ApiResponse.failure(
response['errorMessage'] ?? "Integration failed",
);
}
notifyListeners();
} catch (e) {
model.isLoading = false;
model.errorMessage = e.toString();
notifyListeners();
return ApiResponse.failure(e.toString());
}
}
@@ -115,27 +109,28 @@ class ReceiptController extends ChangeNotifier {
.model
.formData = transactionController.model.formData.copyWith(
amount: model.receiptData?['amount'].toStringAsFixed(2) ?? '',
creditPhone: model.receiptData?['creditPhone'] ?? '',
debitPhone: model.receiptData?['debitPhone'] ?? '',
paymentProcessorLabel: model.receiptData?['paymentProcessorLabel'] ?? '',
paymentProcessorName: model.receiptData?['paymentProcessorName'] ?? '',
id: null
id: null,
);
setLoading(false);
context.push('/make-payment');
}
Future<void> getReceiptData(String id) async {
Future<ApiResponse<Map<String, dynamic>>> getReceiptData(String id) async {
setLoading(true);
try {
Map<String, dynamic> response = await http.get('/public/transaction/$id');
model.receiptData = response;
setLoading(false);
return ApiResponse.success(response);
} catch (e) {
_showErrorSnackBar(
setLoading(false);
return ApiResponse.failure(
"Problem fetching transaction data, are you connected to the internet?",
);
} finally {
setLoading(false);
}
}