adding CityWallet functionality

This commit is contained in:
Prince
2026-06-11 16:33:22 +02:00
parent b10d233428
commit ad79bf2af8
7 changed files with 301 additions and 84 deletions

View File

@@ -1,3 +1,4 @@
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
@@ -54,19 +55,21 @@ class ConfirmController extends ChangeNotifier {
notifyListeners();
// todo: find out if we still need to update these fields
transactionController
transactionController.model.formData = transactionController
.model
.formData = transactionController.model.formData.copyWith(
type: "REQUEST",
trace: transactionController.model.confirmationData['trace'],
id: transactionController.model.confirmationData['id'],
authType: transactionController.model.selectedPaymentProcessor.authType,
);
.formData
.copyWith(
type: "REQUEST",
trace: transactionController.model.confirmationData['trace'],
id: transactionController.model.confirmationData['id'],
authType:
transactionController.model.selectedPaymentProcessor.authType,
);
dynamic workflowResponse = await http.get(
'/public/transaction/request/'
'${transactionController.model.confirmationData['id']}/'
'${transactionController.model.selectedPaymentProcessor.authType}'
'${transactionController.model.confirmationData['id']}/'
'${transactionController.model.selectedPaymentProcessor.authType}',
);
logger.i(workflowResponse.toString());
@@ -82,7 +85,9 @@ class ConfirmController extends ChangeNotifier {
} else {
model.status = response['status'];
model.errorMessage = response['errorMessage'];
return ApiResponse.failure(response['errorMessage'] ?? "Transaction failed");
return ApiResponse.failure(
response['errorMessage'] ?? "Transaction failed",
);
}
} catch (e) {
logger.e(e);
@@ -125,6 +130,50 @@ class ConfirmController extends ChangeNotifier {
return ApiResponse.failure("Polling cancelled");
}
Future<ApiResponse<Map<String, dynamic>>> updateVelocityTransactionOtp(
String id,
Map<String, dynamic> transaction,
) async {
try {
model.isLoading = true;
notifyListeners();
dynamic response = await http.put(
'/public/transaction/$id/velocity-otp',
transaction,
);
model.isLoading = false;
notifyListeners();
if (response['status'] == 'SUCCESS') {
return ApiResponse.success(Map<String, dynamic>.from(response));
} else {
model.errorMessage =
response['errorMessage'] ??
"Problem updating transaction. Please try again or contact support";
return ApiResponse.failure(model.errorMessage!);
}
} on DioException catch (e, s) {
if (kDebugMode) {
logger.e(e);
logger.e(s);
}
model.isLoading = false;
notifyListeners();
return ApiResponse.failure(
"Network error. Please try again or contact support",
);
} catch (e, s) {
logger.e(s);
model.isLoading = false;
notifyListeners();
return ApiResponse.failure(
"Problem updating that transaction. Please try again or contact support",
);
}
}
@override
void dispose() {
// TODO: implement dispose