advance payment implementation done for self & other file number

pull/53/head
haroon amjad 1 month ago
parent 3e95999bf3
commit 97038f1a25

@ -176,8 +176,8 @@ class ApiClientImp implements ApiClient {
body[_appState.isAuthenticated ? 'TokenID' : 'LogInTokenID'] = _appState.appAuthToken;
}
body['TokenID'] = "@dm!n";
body['PatientID'] = 3628599;
// body['TokenID'] = "@dm!n";
// body['PatientID'] = 3628599;
}
body.removeWhere((key, value) => value == null);

@ -723,7 +723,7 @@ const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_In
class ApiConsts {
static const maxSmallScreen = 660;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat;
// static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -1,6 +1,8 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_repo.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
class HabibWalletViewModel extends ChangeNotifier {
@ -8,6 +10,10 @@ class HabibWalletViewModel extends ChangeNotifier {
num habibWalletAmount = 0;
num walletRechargeAmount = 0;
bool isBottomSheetContentLoading = false;
bool isSearchedFileNumberDataShown = false;
int currentIndex = 0;
List<HospitalsModel> advancePaymentHospitals = [];
@ -21,12 +27,16 @@ class HabibWalletViewModel extends ChangeNotifier {
String depositorName = '';
String mobileNumber = '';
num selectedRechargeType = 1;
HabibWalletViewModel({required this.habibWalletRepo, required this.errorHandlerService});
initHabibWalletProvider() {
isWalletAmountLoading = true;
isBottomSheetContentLoading = false;
habibWalletAmount = 0;
walletRechargeAmount = 0;
selectedRechargeType = 1;
advancePaymentHospitals.clear();
selectedHospital = null;
fileNumber = '';
@ -35,6 +45,11 @@ class HabibWalletViewModel extends ChangeNotifier {
notifyListeners();
}
setSelectedRechargeType(num type) {
selectedRechargeType = type;
notifyListeners();
}
setSelectedHospital(HospitalsModel hospital) {
selectedHospital = hospital;
notifyListeners();
@ -57,6 +72,19 @@ class HabibWalletViewModel extends ChangeNotifier {
notifyListeners();
}
String getSelectedRechargeTypeValue() {
switch (selectedRechargeType) {
case 1:
return LocaleKeys.myAccount.tr();
case 2:
return LocaleKeys.family.tr();
case 3:
return LocaleKeys.otherAccount.tr();
default:
return LocaleKeys.myAccount.tr();
}
}
Future<void> getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async {
isWalletAmountLoading = true;
notifyListeners();
@ -144,14 +172,21 @@ class HabibWalletViewModel extends ChangeNotifier {
}
Future<void> getPatientInfoByPatientID({required String patientID, Function(dynamic)? onSuccess, Function(String)? onError}) async {
isBottomSheetContentLoading = true;
notifyListeners();
final result = await habibWalletRepo.getPatientInfoByPatientID(patientID: patientID);
result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure),
(failure) async {
isBottomSheetContentLoading = false;
notifyListeners();
await errorHandlerService.handleError(failure: failure);
},
(apiResponse) {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
isBottomSheetContentLoading = false;
notifyListeners();
if (onSuccess != null) {
onSuccess(apiResponse);

@ -151,8 +151,12 @@ class _AppointmentCardState extends State<AppointmentCard> {
spacing: 3.h,
runSpacing: 4.h,
children: [
widget.isFromHomePage ? SizedBox.shrink() : AppCustomChipWidget(labelText: widget.isLoading ? "Cardiology" : widget.patientAppointmentHistoryResponseModel.clinicName!).toShimmer2(isShow: widget.isLoading),
widget.isFromHomePage ? SizedBox.shrink() : AppCustomChipWidget(labelText: widget.isLoading ? "Olaya" : widget.patientAppointmentHistoryResponseModel.projectName!).toShimmer2(isShow: widget.isLoading),
widget.isFromHomePage
? SizedBox.shrink()
: AppCustomChipWidget(labelText: widget.isLoading ? "Cardiology" : widget.patientAppointmentHistoryResponseModel.clinicName!).toShimmer2(isShow: widget.isLoading),
widget.isFromHomePage
? SizedBox.shrink()
: AppCustomChipWidget(labelText: widget.isLoading ? "Olaya" : widget.patientAppointmentHistoryResponseModel.projectName!).toShimmer2(isShow: widget.isLoading),
AppCustomChipWidget(
icon: AppAssets.appointment_calendar_icon,
labelText:

@ -102,7 +102,7 @@ class _HabibWalletState extends State<HabibWalletPage> {
fontSize: 14,
fontWeight: FontWeight.bold,
borderRadius: 12,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
// padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 40.h,
),
],

@ -34,11 +34,15 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
FocusNode textFocusNode = FocusNode();
late HabibWalletViewModel habibWalletVM;
late AppState appState;
final TextEditingController amountTextController = TextEditingController();
@override
void initState() {
scheduleMicrotask(() {
habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
appState.getAuthenticatedUser()!.mobileNumber!);
habibWalletVM.setSelectedRechargeType(0);
habibWalletVM.getProjectsList();
});
super.initState();
@ -47,7 +51,7 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
@override
Widget build(BuildContext context) {
habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false);
AppState appState = getIt.get<AppState>();
appState = getIt.get<AppState>();
return Scaffold(
backgroundColor: AppColors.bgScaffoldColor,
body: Column(
@ -136,8 +140,8 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocaleKeys.myAccount.tr(context: context).toText16(color: AppColors.textColor, weight: FontWeight.w500),
"${LocaleKeys.medicalFile.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}"
(habibWalletVM.getSelectedRechargeTypeValue()).toText16(color: AppColors.textColor, weight: FontWeight.w500),
"${LocaleKeys.medicalFile.tr(context: context)}: ${habibWalletVM.fileNumber}"
.toText14(color: AppColors.greyTextColor, weight: FontWeight.w500),
],
),
@ -276,8 +280,8 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
);
} else {
habibWalletVM.setWalletRechargeAmount(num.parse(amountTextController.text));
habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
appState.getAuthenticatedUser()!.mobileNumber!);
// habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
// appState.getAuthenticatedUser()!.mobileNumber!);
Navigator.of(context).push(
CustomPageRoute(
page: WalletPaymentConfirmPage(),

@ -189,7 +189,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
if (Utils.havePrivilege(103)) {
startApplePay();
} else {
openPaymentURL("applepay");
openPaymentURL("ApplePay");
}
})
: SizedBox(height: 12.h),
@ -214,8 +214,8 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
applePayInsertRequest.clinicID = 0;
applePayInsertRequest.currency = appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED";
applePayInsertRequest.customerEmail = "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com";
applePayInsertRequest.customerID = appState.getAuthenticatedUser()!.patientId.toString();
applePayInsertRequest.customerEmail = "CustID_${habibWalletVM.fileNumber.toString()}@HMG.com";
applePayInsertRequest.customerID = habibWalletVM.fileNumber.toString();
applePayInsertRequest.customerName = "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}";
applePayInsertRequest.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken);
@ -224,7 +224,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
applePayInsertRequest.projectID = habibWalletVM.selectedHospital!.iD!.toString();
applePayInsertRequest.serviceID = ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString();
applePayInsertRequest.channelID = 3;
applePayInsertRequest.patientID = appState.getAuthenticatedUser()!.patientId.toString();
applePayInsertRequest.patientID = habibWalletVM.fileNumber.toString();
applePayInsertRequest.patientTypeID = appState.getAuthenticatedUser()!.patientType;
applePayInsertRequest.patientOutSA = appState.getAuthenticatedUser()!.outSa;
applePayInsertRequest.appointmentDate = null;
@ -237,7 +237,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
applePayInsertRequest.isSchedule = "0";
applePayInsertRequest.language = appState.isArabic() ? 'ar' : 'en';
applePayInsertRequest.languageID = appState.isArabic() ? 1 : 2;
applePayInsertRequest.userName = appState.getAuthenticatedUser()!.patientId;
applePayInsertRequest.userName = int.parse(habibWalletVM.fileNumber);
applePayInsertRequest.responseContinueURL = "http://hmg.com/Documents/success.html";
applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html";
applePayInsertRequest.paymentOption = "ApplePay";
@ -330,6 +330,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
},
onError: (err) {});
} else {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
@ -403,11 +404,11 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
"Advance Payment",
transID,
habibWalletVM.selectedHospital!.iD!.toString(),
"CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com",
"CustID_${habibWalletVM.fileNumber.toString()}@HMG.com",
selectedPaymentMethod,
appState.getAuthenticatedUser()!.patientType.toString(),
"${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
appState.getAuthenticatedUser()!.patientId.toString(),
habibWalletVM.depositorName,
habibWalletVM.fileNumber.toString(),
appState.getAuthenticatedUser()!,
browser!,
false,

@ -29,6 +29,7 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/input_widget.dart';
@ -43,6 +44,7 @@ class MultiPageBottomSheet extends StatefulWidget {
class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
late AppState appState;
static final DialogService _dialogService = getIt.get<DialogService>();
TextEditingController fileNumberEditingController = TextEditingController();
@ -52,7 +54,7 @@ class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
return Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: getCurrentIndexWidget(habibWalletVM),
child: habibWalletVM.isBottomSheetContentLoading ? Utils.getLoadingWidget() : getCurrentIndexWidget(habibWalletVM),
);
});
}
@ -80,13 +82,12 @@ class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
labelText: LocaleKeys.fileNumber.tr(),
hintText: "xxxxxxxxx",
controller: fileNumberEditingController,
// focusNode: _nationalIdFocusNode,
isEnable: true,
prefix: null,
isAllowRadius: true,
isBorderAllowed: false,
isAllowLeadingIcon: true,
autoFocus: true,
autoFocus: false,
padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 8.h),
leadingIcon: AppAssets.requests,
).withVerticalPadding(8),
@ -94,9 +95,23 @@ class _MultiPageBottomSheetState extends State<MultiPageBottomSheet> {
CustomButton(
text: LocaleKeys.submit.tr(),
onPressed: () async {
await habibWalletVM.getPatientInfoByPatientID(patientID: fileNumberEditingController.text, onSuccess: (response) {
await habibWalletVM.getPatientInfoByPatientID(
patientID: fileNumberEditingController.text,
onSuccess: (response) async {
print(response.data["GetPatientInfoByPatientIDList"][0]["FullName"]);
}, onError: (error) {});
await _dialogService.showCommonBottomSheetWithoutH(
message: "A file was found with name: ${response.data["GetPatientInfoByPatientIDList"][0]["FullName"]}, Would you like to recharge wallet for this file number?".needTranslation,
label: LocaleKeys.notice.tr(),
onOkPressed: () {
habibWalletVM.setSelectedRechargeType(3);
habibWalletVM.setDepositorDetails(response.data["GetPatientInfoByPatientIDList"][0]["PatientID"].toString(), response.data["GetPatientInfoByPatientIDList"][0]["FullName"],
response.data["GetPatientInfoByPatientIDList"][0]["MobileNumber"]);
Navigator.of(context).pop();
Navigator.of(context).pop();
},
onCancelPressed: () {});
},
onError: (error) {});
},
backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedBorderColor,

@ -62,10 +62,12 @@ class CustomButton extends StatelessWidget {
children: [
if (icon != null)
Padding(
padding: const EdgeInsets.only(right: 8.0, left: 8.0, bottom: 4.5),
padding: const EdgeInsets.only(right: 8.0, left: 8.0),
child: Utils.buildSvgWithAssets(icon: icon!, iconColor: iconColor, isDisabled: isDisabled, width: iconSize, height: iconSize),
),
Text(
Padding(
padding: EdgeInsets.only(top: 2.5),
child: Text(
text,
style: context.dynamicTextStyle(
fontSize: fontSize.fSize,
@ -74,6 +76,7 @@ class CustomButton extends StatelessWidget {
fontWeight: fontWeight,
),
),
),
],
),
)

Loading…
Cancel
Save