|
|
|
|
@ -19,6 +19,8 @@ import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/
|
|
|
|
|
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';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/paytabs/models/paytabs_transaction_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/paytabs/paytabs_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/insurance/insurance_home_page.dart';
|
|
|
|
|
@ -45,6 +47,7 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
|
|
|
|
|
late BookAppointmentsViewModel bookAppointmentsViewModel;
|
|
|
|
|
late MyAppointmentsViewModel myAppointmentsViewModel;
|
|
|
|
|
late PayfortViewModel payfortViewModel;
|
|
|
|
|
late PayTabsViewModel paytabsViewModel;
|
|
|
|
|
late AppState appState;
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser? browser;
|
|
|
|
|
@ -87,6 +90,7 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
|
|
|
|
|
bookAppointmentsViewModel = Provider.of<BookAppointmentsViewModel>(context);
|
|
|
|
|
myAppointmentsViewModel = Provider.of<MyAppointmentsViewModel>(context);
|
|
|
|
|
payfortViewModel = Provider.of<PayfortViewModel>(context);
|
|
|
|
|
paytabsViewModel = Provider.of<PayTabsViewModel>(context, listen: false);
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: AppColors.bgScaffoldColor,
|
|
|
|
|
body: Consumer<BookAppointmentsViewModel>(builder: (context, bookAppointmentsVM, child) {
|
|
|
|
|
@ -133,7 +137,50 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
selectedPaymentMethod = "MADA";
|
|
|
|
|
openPaymentURL("mada");
|
|
|
|
|
if (appState.isPaytabsEnabled) {
|
|
|
|
|
paytabsViewModel.setPaymentConfiguration(
|
|
|
|
|
"Appointment Payment",
|
|
|
|
|
bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
|
|
|
|
|
);
|
|
|
|
|
paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.bookingWaitingAppointment.tr(context: context));
|
|
|
|
|
await bookAppointmentsViewModel.insertSpecificAppointmentForWalkIn(onSuccess: (val) async {
|
|
|
|
|
String appointmentNo = val.data['AppointmentNo'].toString();
|
|
|
|
|
await myAppointmentsViewModel.createAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
projectID: bookAppointmentsViewModel.waitingAppointmentProjectID,
|
|
|
|
|
clinicID: bookAppointmentsViewModel.selectedDoctor.clinicID!,
|
|
|
|
|
appointmentNo: appointmentNo,
|
|
|
|
|
payedAmount: bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
|
|
|
|
|
patientType: appState.getAuthenticatedUser()!.patientType!,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
print(value);
|
|
|
|
|
await myAppointmentsViewModel.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: Utils.isVidaPlusProject(bookAppointmentsViewModel.waitingAppointmentProjectID)
|
|
|
|
|
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
appointmentNo: appointmentNo,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
sendCheckInRequest(bookAppointmentsViewModel.waitingAppointmentNFCCode, appointmentNo, context);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}, onError: (err) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err.toString()),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
openPaymentURL("mada");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
Container(
|
|
|
|
|
@ -175,7 +222,50 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
selectedPaymentMethod = "VISA";
|
|
|
|
|
openPaymentURL("visa");
|
|
|
|
|
if (appState.isPaytabsEnabled) {
|
|
|
|
|
paytabsViewModel.setPaymentConfiguration(
|
|
|
|
|
"Appointment Payment",
|
|
|
|
|
bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
|
|
|
|
|
);
|
|
|
|
|
paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.bookingWaitingAppointment.tr(context: context));
|
|
|
|
|
await bookAppointmentsViewModel.insertSpecificAppointmentForWalkIn(onSuccess: (val) async {
|
|
|
|
|
String appointmentNo = val.data['AppointmentNo'].toString();
|
|
|
|
|
await myAppointmentsViewModel.createAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
projectID: bookAppointmentsViewModel.waitingAppointmentProjectID,
|
|
|
|
|
clinicID: bookAppointmentsViewModel.selectedDoctor.clinicID!,
|
|
|
|
|
appointmentNo: appointmentNo,
|
|
|
|
|
payedAmount: bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
|
|
|
|
|
patientType: appState.getAuthenticatedUser()!.patientType!,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
print(value);
|
|
|
|
|
await myAppointmentsViewModel.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: Utils.isVidaPlusProject(bookAppointmentsViewModel.waitingAppointmentProjectID)
|
|
|
|
|
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
appointmentNo: appointmentNo,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
sendCheckInRequest(bookAppointmentsViewModel.waitingAppointmentNFCCode, appointmentNo, context);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}, onError: (err) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err.toString()),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
openPaymentURL("visa");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
isShowTamara
|
|
|
|
|
@ -531,14 +621,7 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startApplePay() async {
|
|
|
|
|
showCommonBottomSheet(context,
|
|
|
|
|
child: Utils.getLoadingWidget(),
|
|
|
|
|
callBackFunc: (str) {},
|
|
|
|
|
title: "",
|
|
|
|
|
height: ResponsiveExtension.screenHeight * 0.3,
|
|
|
|
|
isCloseButtonVisible: false,
|
|
|
|
|
isDismissible: false,
|
|
|
|
|
isFullScreen: false);
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.loadingText.tr(context: context));
|
|
|
|
|
transID = Utils.getAppointmentTransID(
|
|
|
|
|
bookAppointmentsViewModel.selectedDoctor.projectID!,
|
|
|
|
|
bookAppointmentsViewModel.selectedDoctor.clinicID!,
|
|
|
|
|
@ -596,36 +679,80 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
|
|
|
|
|
|
|
|
|
|
//TODO: Need to pass dynamic params to the Apple Pay instead of static values
|
|
|
|
|
await payfortViewModel.applePayRequestInsert(applePayInsertRequest: applePayInsertRequest).then((value) {
|
|
|
|
|
payfortViewModel.paymentWithApplePay(
|
|
|
|
|
customerName: "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
|
|
|
|
|
// customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
|
|
|
|
customerEmail: "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com",
|
|
|
|
|
orderDescription: "Appointment Payment",
|
|
|
|
|
orderAmount: double.parse(bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!.toString()),
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
merchantIdentifier: payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier,
|
|
|
|
|
applePayAccessCode: payfortViewModel.payfortProjectDetailsRespModel!.accessCode,
|
|
|
|
|
applePayShaRequestPhrase: payfortViewModel.payfortProjectDetailsRespModel!.shaRequest,
|
|
|
|
|
currency: appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED",
|
|
|
|
|
onFailed: (failureResult) async {
|
|
|
|
|
log("failureResult: ${failureResult.message.toString()}");
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
if (appState.isPaytabsEnabled) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
paytabsViewModel.setPaymentConfiguration(
|
|
|
|
|
"Appointment Payment",
|
|
|
|
|
bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
|
|
|
|
|
);
|
|
|
|
|
paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.bookingWaitingAppointment.tr(context: context));
|
|
|
|
|
await bookAppointmentsViewModel.insertSpecificAppointmentForWalkIn(onSuccess: (val) async {
|
|
|
|
|
String appointmentNo = val.data['AppointmentNo'].toString();
|
|
|
|
|
await myAppointmentsViewModel.createAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
projectID: bookAppointmentsViewModel.waitingAppointmentProjectID,
|
|
|
|
|
clinicID: bookAppointmentsViewModel.selectedDoctor.clinicID!,
|
|
|
|
|
appointmentNo: appointmentNo,
|
|
|
|
|
payedAmount: bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
|
|
|
|
|
patientType: appState.getAuthenticatedUser()!.patientType!,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
print(value);
|
|
|
|
|
await myAppointmentsViewModel.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: Utils.isVidaPlusProject(bookAppointmentsViewModel.waitingAppointmentProjectID)
|
|
|
|
|
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
appointmentNo: appointmentNo,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
sendCheckInRequest(bookAppointmentsViewModel.waitingAppointmentNFCCode, appointmentNo, context);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}, onError: (err) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: failureResult.message.toString()),
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err.toString()),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onSucceeded: (successResult) async {
|
|
|
|
|
log("successResult: ${successResult.responseMessage.toString()}");
|
|
|
|
|
selectedPaymentMethod = successResult.paymentOption ?? "VISA";
|
|
|
|
|
checkPaymentStatus();
|
|
|
|
|
},
|
|
|
|
|
// projectId: appo.projectID,
|
|
|
|
|
// serviceTypeEnum: ServiceTypeEnum.appointmentPayment,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
payfortViewModel.paymentWithApplePay(
|
|
|
|
|
customerName: "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
|
|
|
|
|
// customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
|
|
|
|
customerEmail: "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com",
|
|
|
|
|
orderDescription: "Appointment Payment",
|
|
|
|
|
orderAmount: double.parse(bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!.toString()),
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
merchantIdentifier: payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier,
|
|
|
|
|
applePayAccessCode: payfortViewModel.payfortProjectDetailsRespModel!.accessCode,
|
|
|
|
|
applePayShaRequestPhrase: payfortViewModel.payfortProjectDetailsRespModel!.shaRequest,
|
|
|
|
|
currency: appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED",
|
|
|
|
|
onFailed: (failureResult) async {
|
|
|
|
|
log("failureResult: ${failureResult.message.toString()}");
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: failureResult.message.toString()),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onSucceeded: (successResult) async {
|
|
|
|
|
log("successResult: ${successResult.responseMessage.toString()}");
|
|
|
|
|
selectedPaymentMethod = successResult.paymentOption ?? "VISA";
|
|
|
|
|
checkPaymentStatus();
|
|
|
|
|
},
|
|
|
|
|
// projectId: appo.projectID,
|
|
|
|
|
// serviceTypeEnum: ServiceTypeEnum.appointmentPayment,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|