|
|
|
|
@ -14,6 +14,7 @@ import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
|
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/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/payfort/models/apple_pay_request_insert_model.dart';
|
|
|
|
|
@ -134,7 +135,7 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() async {
|
|
|
|
|
selectedPaymentMethod = "MADA";
|
|
|
|
|
if (appState.isPaytabsEnabled) {
|
|
|
|
|
paytabsViewModel.setPaymentConfiguration(
|
|
|
|
|
@ -214,7 +215,100 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
openPaymentURL("mada");
|
|
|
|
|
if (appState.isPayfortHostedPageEnabled) {
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context));
|
|
|
|
|
|
|
|
|
|
transID = Utils.getAppointmentTransID(
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.appointmentNo,
|
|
|
|
|
);
|
|
|
|
|
await payfortViewModel.getPayfortConfigurations(
|
|
|
|
|
serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), projectId: widget.patientAppointmentHistoryResponseModel.projectID, integrationId: 1);
|
|
|
|
|
|
|
|
|
|
payfortViewModel.initiatePaymentWithCard(
|
|
|
|
|
transactionID: transID,
|
|
|
|
|
fileNumber: appState.getAuthenticatedUser()!.patientId.toString(),
|
|
|
|
|
amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(),
|
|
|
|
|
onSucceeded: (paymentResult) async {
|
|
|
|
|
print("Payment Success Data: ${paymentResult.toString()}");
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context));
|
|
|
|
|
await myAppointmentsViewModel.createAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
payedAmount: num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
|
|
|
|
|
paymentReference: paymentResult.fortId!,
|
|
|
|
|
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
|
|
|
|
|
patientType: appState.getAuthenticatedUser()!.patientType!,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
print(value);
|
|
|
|
|
await myAppointmentsViewModel.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID)
|
|
|
|
|
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: paymentResult.fortId!,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) {
|
|
|
|
|
//TODO: Implement LiveCare Check-In API Call
|
|
|
|
|
await myAppointmentsViewModel.insertLiveCareVIDARequest(
|
|
|
|
|
clientRequestID: transID,
|
|
|
|
|
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {});
|
|
|
|
|
} else {
|
|
|
|
|
await myAppointmentsViewModel.generateAppointmentQR(
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onFailed: (err) {
|
|
|
|
|
print("Payment Failed Data: ${err.toString()}");
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
openPaymentURL("mada");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
@ -257,7 +351,7 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() async {
|
|
|
|
|
selectedPaymentMethod = "VISA";
|
|
|
|
|
if (appState.isPaytabsEnabled) {
|
|
|
|
|
paytabsViewModel.setPaymentConfiguration(
|
|
|
|
|
@ -337,8 +431,110 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
if (appState.isPayfortHostedPageEnabled) {
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context));
|
|
|
|
|
|
|
|
|
|
openPaymentURL("visa");
|
|
|
|
|
transID = Utils.getAppointmentTransID(
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
widget.patientAppointmentHistoryResponseModel.appointmentNo,
|
|
|
|
|
);
|
|
|
|
|
await payfortViewModel.getPayfortConfigurations(
|
|
|
|
|
serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), projectId: widget.patientAppointmentHistoryResponseModel.projectID, integrationId: 1);
|
|
|
|
|
|
|
|
|
|
payfortViewModel.initiatePaymentWithCard(
|
|
|
|
|
transactionID: transID,
|
|
|
|
|
fileNumber: appState.getAuthenticatedUser()!.patientId.toString(),
|
|
|
|
|
amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(),
|
|
|
|
|
onSucceeded: (paymentResult) async {
|
|
|
|
|
print("Payment Success Data: ${paymentResult.toString()}");
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context));
|
|
|
|
|
await myAppointmentsViewModel.createAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
payedAmount: num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
|
|
|
|
|
paymentReference: paymentResult.fortId!,
|
|
|
|
|
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
|
|
|
|
|
patientType: appState.getAuthenticatedUser()!.patientType!,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
print(value);
|
|
|
|
|
await myAppointmentsViewModel.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID)
|
|
|
|
|
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: paymentResult.fortId!,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) {
|
|
|
|
|
//TODO: Implement LiveCare Check-In API Call
|
|
|
|
|
await myAppointmentsViewModel.insertLiveCareVIDARequest(
|
|
|
|
|
clientRequestID: transID,
|
|
|
|
|
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {});
|
|
|
|
|
} else {
|
|
|
|
|
await myAppointmentsViewModel.generateAppointmentQR(
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onFailed: (err) {
|
|
|
|
|
print("Payment Failed Data: ${err.toString()}");
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
openPaymentURL("visa");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
@ -416,6 +612,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
@ -436,6 +637,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
@ -664,6 +870,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
@ -685,6 +896,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
@ -752,6 +968,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
@ -773,6 +994,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
@ -929,6 +1155,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
@ -950,6 +1181,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
|
|
|
|
|
myAppointmentsViewModel.initAppointmentsViewModel();
|
|
|
|
|
myAppointmentsViewModel.getPatientAppointments(true, false);
|
|
|
|
|
|
|
|
|
|
getIt.get<HabibWalletViewModel>().setIsWalletAmountToBeLoaded(true);
|
|
|
|
|
getIt.get<HabibWalletViewModel>().initHabibWalletProvider();
|
|
|
|
|
getIt.get<HabibWalletViewModel>().getPatientBalanceAmount();
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
|