diff --git a/lib/features/immediate_livecare/immediate_livecare_repo.dart b/lib/features/immediate_livecare/immediate_livecare_repo.dart index 6726a09b..e07d6293 100644 --- a/lib/features/immediate_livecare/immediate_livecare_repo.dart +++ b/lib/features/immediate_livecare/immediate_livecare_repo.dart @@ -101,9 +101,7 @@ class ImmediateLiveCareRepoImp implements ImmediateLiveCareRepo { onSuccess: (response, statusCode, {messageStatus, errorMessage}) { try { final respObject = response['GetERAppointmentFeesList']; - final liveCareFeesObj = LiveCareImmediateAppointmentFeesList.fromJson(respObject); - apiResponse = GenericApiModel( messageStatus: messageStatus, statusCode: statusCode, diff --git a/lib/features/payfort/payfort_repo.dart b/lib/features/payfort/payfort_repo.dart index 9262d662..6826478c 100644 --- a/lib/features/payfort/payfort_repo.dart +++ b/lib/features/payfort/payfort_repo.dart @@ -58,7 +58,7 @@ class PayfortRepoImp implements PayfortRepo { try { final list = response; if (list == null || list.isEmpty) { - throw Exception("payfort list is empty"); + throw Exception("No project configuration found."); } final applePayConfigurationResponse = PayfortProjectDetailsRespModel.fromJson(list[0]); diff --git a/lib/features/paytabs/paytabs_view_model.dart b/lib/features/paytabs/paytabs_view_model.dart index 1418cc55..a7894f07 100644 --- a/lib/features/paytabs/paytabs_view_model.dart +++ b/lib/features/paytabs/paytabs_view_model.dart @@ -17,6 +17,7 @@ import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/paytabs_config.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; +import 'package:hmg_patient_app_new/features/payfort/models/payfort_project_details_resp_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/payfort/models/payfort_request_insert_model.dart'; @@ -32,19 +33,26 @@ class PayTabsViewModel extends ChangeNotifier { final ErrorHandlerService errorHandlerService; late PaytabsTransactionResponseModel paytabsTransactionResponseModel; + PayfortProjectDetailsRespModel? paytabsProjectDetailsRespModel; + PayTabsViewModel({ required this.appState, required this.payfortRepo, required this.errorHandlerService, }); - setPaymentConfiguration(String paymentDescription, num amount, {bool isAddCard = false}) { + setPaymentConfiguration(String paymentDescription, num amount, int serviceID, int projectID, {bool isAddCard = false}) async { String cartID = DateTime.now().millisecondsSinceEpoch.toString(); + + LoaderBottomSheet.showLoader(); + + await getPayTabsConfigurations(serviceId: serviceID, projectId: projectID); + paymentConfiguration = PaymentSdkConfigurationDetails( - profileId: PaymentSdkDefaultConfig.profileID, - serverKey: PaymentSdkDefaultConfig.serverKey, - clientKey: PaymentSdkDefaultConfig.clientKey, - transactionType: PaymentSdkTransactionType.SALE, + profileId: paytabsProjectDetailsRespModel!.merchantIdentifier, + serverKey: paytabsProjectDetailsRespModel!.accessCode, + clientKey: paytabsProjectDetailsRespModel!.shaResponse, + transactionType: PaymentSdkTransactionType.SALE, cartId: cartID.substring((cartID.length - 5), cartID.length), cartDescription: paymentDescription, merchantName: PaymentSdkDefaultConfig.defaultMerchantName, @@ -112,12 +120,17 @@ class PayTabsViewModel extends ChangeNotifier { notifyListeners(); } - setAlternatePaymentConfiguration(String paymentDescription, num amount, {bool isAddCard = false}) { + setAlternatePaymentConfiguration(String paymentDescription, num amount, int serviceID, int projectID, {bool isAddCard = false}) async { String cartID = DateTime.now().millisecondsSinceEpoch.toString(); + + LoaderBottomSheet.showLoader(); + + await getPayTabsConfigurations(serviceId: serviceID, projectId: projectID); + paymentConfiguration = PaymentSdkConfigurationDetails( - profileId: PaymentSdkDefaultConfig.profileID, - serverKey: PaymentSdkDefaultConfig.serverKey, - clientKey: PaymentSdkDefaultConfig.clientKey, + profileId: paytabsProjectDetailsRespModel!.merchantIdentifier, + serverKey: paytabsProjectDetailsRespModel!.accessCode, + clientKey: paytabsProjectDetailsRespModel!.shaResponse, transactionType: PaymentSdkTransactionType.SALE, cartId: cartID.substring((cartID.length - 5), cartID.length), cartDescription: paymentDescription, @@ -260,7 +273,7 @@ class PayTabsViewModel extends ChangeNotifier { bool _callbackFired = false; // prevent duplicate callback invocations try { - LoaderBottomSheet.showLoader(); + // LoaderBottomSheet.showLoader(); // Create PayfortRequestInsertModel (same as Payfort implementation) PayfortRequestInsertModel payfortRequestInsertModel = PayfortRequestInsertModel(); @@ -382,7 +395,7 @@ class PayTabsViewModel extends ChangeNotifier { required bool isSchedule, Function(PaytabsTransactionResponseModel)? onSuccess, Function(String)? onError}) async { - LoaderBottomSheet.showLoader(); + // LoaderBottomSheet.showLoader(); TamaraRequestModel tamaraRequestModel = TamaraRequestModel(); @@ -448,4 +461,23 @@ class PayTabsViewModel extends ChangeNotifier { } }); } + + Future getPayTabsConfigurations({int? serviceId, int? projectId, int integrationId = 5, Function(dynamic)? onSuccess, Function(String)? onError}) async { + final result = await payfortRepo.getPayfortConfigurations(serviceId: serviceId, projectId: projectId, integrationId: integrationId); + + result.fold( + (failure) async => await errorHandlerService.handleError(failure: failure), + (apiResponse) { + if (apiResponse.messageStatus == 2) { + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + paytabsProjectDetailsRespModel = apiResponse.data!; + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } } diff --git a/lib/presentation/appointments/appointment_payment_page.dart b/lib/presentation/appointments/appointment_payment_page.dart index 6e9bb7b6..85a606b3 100644 --- a/lib/presentation/appointments/appointment_payment_page.dart +++ b/lib/presentation/appointments/appointment_payment_page.dart @@ -150,10 +150,11 @@ class _AppointmentPaymentPageState extends State { widget.patientAppointmentHistoryResponseModel.clinicID, widget.patientAppointmentHistoryResponseModel.appointmentNo, ); - paytabsViewModel.setPaymentConfiguration( - "Appointment Payment", - num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), - ); + await paytabsViewModel.setPaymentConfiguration( + "Appointment Payment", + num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), + ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), + widget.patientAppointmentHistoryResponseModel.projectID); paytabsViewModel.startCardPayment( paymentOption: selectedPaymentMethod, liveServiceID: "0", @@ -179,7 +180,6 @@ class _AppointmentPaymentPageState extends State { 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() @@ -263,7 +263,6 @@ class _AppointmentPaymentPageState extends State { orderDescription: "Appointment Payment", 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, @@ -275,7 +274,6 @@ class _AppointmentPaymentPageState extends State { 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() @@ -391,10 +389,11 @@ class _AppointmentPaymentPageState extends State { widget.patientAppointmentHistoryResponseModel.clinicID, widget.patientAppointmentHistoryResponseModel.appointmentNo, ); - paytabsViewModel.setPaymentConfiguration( - "Appointment Payment", - num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), - ); + await paytabsViewModel.setPaymentConfiguration( + "Appointment Payment", + num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), + ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), + widget.patientAppointmentHistoryResponseModel.projectID); paytabsViewModel.startCardPayment( paymentOption: selectedPaymentMethod, liveServiceID: "0", @@ -420,7 +419,6 @@ class _AppointmentPaymentPageState extends State { 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() @@ -504,7 +502,6 @@ class _AppointmentPaymentPageState extends State { amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(), orderDescription: "Appointment Payment", onSucceeded: (paymentResult) async { - print("Payment Success Data: ${paymentResult.toString()}"); LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context)); await myAppointmentsViewModel.createAdvancePayment( paymentMethodName: selectedPaymentMethod, @@ -516,7 +513,6 @@ class _AppointmentPaymentPageState extends State { 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() @@ -640,7 +636,10 @@ class _AppointmentPaymentPageState extends State { if (appState.isPaytabsEnabled) { paytabsViewModel.setAlternatePaymentConfiguration( - "Appointment Payment", num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString())); + "Appointment Payment", + num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), + ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), + widget.patientAppointmentHistoryResponseModel.projectID); paytabsViewModel.startAlternatePayment( liveServiceID: "0", appointmentDate: widget.patientAppointmentHistoryResponseModel.appointmentDate!, @@ -1121,10 +1120,13 @@ class _AppointmentPaymentPageState extends State { ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest(); - await payfortViewModel.getPayfortConfigurations( - serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), - projectId: widget.patientAppointmentHistoryResponseModel.projectID, - integrationId: 2); + if (!appState.isPaytabsEnabled) { + await payfortViewModel.getPayfortConfigurations( + serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), projectId: widget.patientAppointmentHistoryResponseModel.projectID, integrationId: 2); + } else { + await paytabsViewModel.setPaymentConfiguration("Appointment Payment", num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), + ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), widget.patientAppointmentHistoryResponseModel.projectID); + } applePayInsertRequest.clientRequestID = transID; applePayInsertRequest.clinicID = widget.patientAppointmentHistoryResponseModel.clinicID; @@ -1160,12 +1162,13 @@ class _AppointmentPaymentPageState extends State { applePayInsertRequest.isMobSDK = true; applePayInsertRequest.merchantReference = transID; - applePayInsertRequest.merchantIdentifier = payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier; + applePayInsertRequest.merchantIdentifier = + appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.merchantIdentifier : payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier; applePayInsertRequest.commandType = "PURCHASE"; - applePayInsertRequest.signature = payfortViewModel.payfortProjectDetailsRespModel!.signature; - applePayInsertRequest.accessCode = payfortViewModel.payfortProjectDetailsRespModel!.accessCode; - applePayInsertRequest.shaRequestPhrase = payfortViewModel.payfortProjectDetailsRespModel!.shaRequest; - applePayInsertRequest.shaResponsePhrase = payfortViewModel.payfortProjectDetailsRespModel!.shaResponse; + applePayInsertRequest.signature = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.signature : payfortViewModel.payfortProjectDetailsRespModel!.signature; + applePayInsertRequest.accessCode = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.accessCode : payfortViewModel.payfortProjectDetailsRespModel!.accessCode; + applePayInsertRequest.shaRequestPhrase = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.shaRequest : payfortViewModel.payfortProjectDetailsRespModel!.shaRequest; + applePayInsertRequest.shaResponsePhrase = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.shaResponse : payfortViewModel.payfortProjectDetailsRespModel!.shaResponse; applePayInsertRequest.returnURL = ""; //TODO: Need to pass dynamic params to the Apple Pay instead of static values @@ -1173,10 +1176,6 @@ class _AppointmentPaymentPageState extends State { if (appState.isPaytabsEnabled) { selectedPaymentMethod = "VISA"; LoaderBottomSheet.hideLoader(); - paytabsViewModel.setPaymentConfiguration( - "Appointment Payment", - num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), - ); paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context)); await myAppointmentsViewModel.createAdvancePayment( diff --git a/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart b/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart index dd6cf8eb..acf2a274 100644 --- a/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart +++ b/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart @@ -45,8 +45,9 @@ class AppointmentCheckinBottomSheet extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - checkInOptionCard( - AppAssets.checkin_location_icon, + Utils.havePrivilege(102) + ? checkInOptionCard( + AppAssets.checkin_location_icon, LocaleKeys.liveLocation.tr(context: context), LocaleKeys.verifyYourLocationAtHospital.tr(context: context), ).onPress(() { @@ -71,9 +72,10 @@ class AppointmentCheckinBottomSheet extends StatelessWidget { }, isFullScreen: false); } }); - }), + }) + : SizedBox.shrink(), // SizedBox(height: 16.h), - // checkInOptionCard(O + // checkInOptionCard( // AppAssets.checkin_nfc_icon, // LocaleKeys.nfcNearFieldCommunication.tr(context: context), // LocaleKeys.scanPhoneViaNFC.tr(context: context), diff --git a/lib/presentation/appointments/widgets/appointment_doctor_card.dart b/lib/presentation/appointments/widgets/appointment_doctor_card.dart index 8738a449..dc7bb0af 100644 --- a/lib/presentation/appointments/widgets/appointment_doctor_card.dart +++ b/lib/presentation/appointments/widgets/appointment_doctor_card.dart @@ -173,39 +173,39 @@ class AppointmentDoctorCard extends StatelessWidget { ? SizedBox.shrink() : Utils.buildSvgWithAssets(icon: AppAssets.doctor_profile_icon, width: 20.h, height: 20.h, fit: BoxFit.scaleDown) .onPress(() async { - DoctorsListResponseModel selectedDoctor = DoctorsListResponseModel(); - selectedDoctor.doctorID = patientAppointmentHistoryResponseModel.doctorID; - selectedDoctor.doctorImageURL = patientAppointmentHistoryResponseModel.doctorImageURL; - selectedDoctor.name = patientAppointmentHistoryResponseModel.doctorNameObj; - selectedDoctor.doctorTitle = patientAppointmentHistoryResponseModel.doctorTitle; - selectedDoctor.nationalityFlagURL = ""; - selectedDoctor.speciality = patientAppointmentHistoryResponseModel.doctorSpeciality; - selectedDoctor.clinicName = patientAppointmentHistoryResponseModel.clinicName; - selectedDoctor.projectName = patientAppointmentHistoryResponseModel.projectName; - selectedDoctor.clinicID = patientAppointmentHistoryResponseModel.clinicID; - selectedDoctor.projectID = patientAppointmentHistoryResponseModel.projectID; - - getIt.get().setSelectedDoctor(selectedDoctor); - LoaderBottomSheet.showLoader(); - await getIt.get().getDoctorProfile(onSuccess: (dynamic respData) { - LoaderBottomSheet.hideLoader(); - Navigator.of(context).push( - CustomPageRoute( - page: DoctorProfilePage( - isDoctorAllowedToBook: !(patientAppointmentHistoryResponseModel.isLiveCareAppointment ?? false), - ), - ), - ); - }, onError: (err) { - LoaderBottomSheet.hideLoader(); - showCommonBottomSheetWithoutHeight( - context, - child: Utils.getErrorWidget(loadingText: err), - callBackFunc: () {}, - isFullScreen: false, - isCloseButtonVisible: true, - ); - }); + // DoctorsListResponseModel selectedDoctor = DoctorsListResponseModel(); + // selectedDoctor.doctorID = patientAppointmentHistoryResponseModel.doctorID; + // selectedDoctor.doctorImageURL = patientAppointmentHistoryResponseModel.doctorImageURL; + // selectedDoctor.name = patientAppointmentHistoryResponseModel.doctorNameObj; + // selectedDoctor.doctorTitle = patientAppointmentHistoryResponseModel.doctorTitle; + // selectedDoctor.nationalityFlagURL = ""; + // selectedDoctor.speciality = patientAppointmentHistoryResponseModel.doctorSpeciality; + // selectedDoctor.clinicName = patientAppointmentHistoryResponseModel.clinicName; + // selectedDoctor.projectName = patientAppointmentHistoryResponseModel.projectName; + // selectedDoctor.clinicID = patientAppointmentHistoryResponseModel.clinicID; + // selectedDoctor.projectID = patientAppointmentHistoryResponseModel.projectID; + // + // getIt.get().setSelectedDoctor(selectedDoctor); + // LoaderBottomSheet.showLoader(); + // await getIt.get().getDoctorProfile(onSuccess: (dynamic respData) { + // LoaderBottomSheet.hideLoader(); + // Navigator.of(context).push( + // CustomPageRoute( + // page: DoctorProfilePage( + // isDoctorAllowedToBook: !(patientAppointmentHistoryResponseModel.isLiveCareAppointment ?? false), + // ), + // ), + // ); + // }, onError: (err) { + // LoaderBottomSheet.hideLoader(); + // showCommonBottomSheetWithoutHeight( + // context, + // child: Utils.getErrorWidget(loadingText: err), + // callBackFunc: () {}, + // isFullScreen: false, + // isCloseButtonVisible: true, + // ); + // }); }) ], ), @@ -220,7 +220,48 @@ class AppointmentDoctorCard extends StatelessWidget { ], ), ), - ); + ).onPress(() async { + if ((patientAppointmentHistoryResponseModel.isLiveCareAppointment! || + patientAppointmentHistoryResponseModel.isExecludeDoctor! || + patientAppointmentHistoryResponseModel.isClinicReBookingAllowed! == false || + patientAppointmentHistoryResponseModel.isActiveDoctor! == false || + !Utils.isClinicAllowedForRebook(patientAppointmentHistoryResponseModel.clinicID))) { + } else { + DoctorsListResponseModel selectedDoctor = DoctorsListResponseModel(); + selectedDoctor.doctorID = patientAppointmentHistoryResponseModel.doctorID; + selectedDoctor.doctorImageURL = patientAppointmentHistoryResponseModel.doctorImageURL; + selectedDoctor.name = patientAppointmentHistoryResponseModel.doctorNameObj; + selectedDoctor.doctorTitle = patientAppointmentHistoryResponseModel.doctorTitle; + selectedDoctor.nationalityFlagURL = ""; + selectedDoctor.speciality = patientAppointmentHistoryResponseModel.doctorSpeciality; + selectedDoctor.clinicName = patientAppointmentHistoryResponseModel.clinicName; + selectedDoctor.projectName = patientAppointmentHistoryResponseModel.projectName; + selectedDoctor.clinicID = patientAppointmentHistoryResponseModel.clinicID; + selectedDoctor.projectID = patientAppointmentHistoryResponseModel.projectID; + + getIt.get().setSelectedDoctor(selectedDoctor); + LoaderBottomSheet.showLoader(); + await getIt.get().getDoctorProfile(onSuccess: (dynamic respData) { + LoaderBottomSheet.hideLoader(); + Navigator.of(context).push( + CustomPageRoute( + page: DoctorProfilePage( + isDoctorAllowedToBook: !(patientAppointmentHistoryResponseModel.isLiveCareAppointment ?? false), + ), + ), + ); + }, onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }); + } + }); } Widget getAppointmentActionButtons(bool isAppointmentArrived) { diff --git a/lib/presentation/book_appointment/livecare/immediate_livecare_payment_page.dart b/lib/presentation/book_appointment/livecare/immediate_livecare_payment_page.dart index 2ab1e303..692e8b44 100644 --- a/lib/presentation/book_appointment/livecare/immediate_livecare_payment_page.dart +++ b/lib/presentation/book_appointment/livecare/immediate_livecare_payment_page.dart @@ -137,10 +137,8 @@ class _ImmediateLiveCarePaymentPageState extends State paytabsViewModel.setPaymentConfiguration( "ER Online Check-In Payment", emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!, - ); + ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum(), emergencyServicesViewModel.selectedHospital!.iD); paytabsViewModel.startCardPayment( paymentOption: selectedPaymentMethod, liveServiceID: "0", @@ -238,7 +238,7 @@ class _ErOnlineCheckinPaymentPageState extends State paytabsViewModel.setPaymentConfiguration( "ER Online Check-In Payment", emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!, - ); + ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum(), emergencyServicesViewModel.selectedHospital!.iD); paytabsViewModel.startCardPayment( paymentOption: selectedPaymentMethod, liveServiceID: "0", @@ -533,7 +533,7 @@ class _ErOnlineCheckinPaymentPageState extends State paytabsViewModel.setPaymentConfiguration( "ER Online Check-In Payment", emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!, - ); + ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum(), emergencyServicesViewModel.selectedHospital!.iD); paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context)); if (emergencyServicesViewModel.isERBookAppointment) { diff --git a/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart b/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart index 1ddaaec9..52cea368 100644 --- a/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart +++ b/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart @@ -116,7 +116,8 @@ class _WalletPaymentConfirmPageState extends State { selectedPaymentMethod = "MADA"; if (appState.isPaytabsEnabled) { transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber)); - paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount); + await paytabsViewModel.setPaymentConfiguration( + "Advance Payment", habibWalletVM.walletRechargeAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), habibWalletVM.selectedHospital!.iD!); paytabsViewModel.startCardPayment( paymentOption: selectedPaymentMethod, liveServiceID: "0", @@ -313,7 +314,8 @@ class _WalletPaymentConfirmPageState extends State { selectedPaymentMethod = "VISA"; if (appState.isPaytabsEnabled) { transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber)); - paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount); + await paytabsViewModel.setPaymentConfiguration( + "Advance Payment", habibWalletVM.walletRechargeAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), habibWalletVM.selectedHospital!.iD!); paytabsViewModel.startCardPayment( paymentOption: selectedPaymentMethod, liveServiceID: "0", @@ -543,7 +545,11 @@ class _WalletPaymentConfirmPageState extends State { transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber)); - await payfortViewModel.getPayfortConfigurations(serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), projectId: habibWalletVM.selectedHospital!.iD!, integrationId: 2); + if(!appState.isPaytabsEnabled) { + await payfortViewModel.getPayfortConfigurations(serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), projectId: habibWalletVM.selectedHospital!.iD!, integrationId: 2); + } else { + await paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), habibWalletVM.selectedHospital!.iD!); + } applePayInsertRequest.clientRequestID = transID; applePayInsertRequest.clinicID = 0; @@ -579,12 +585,12 @@ class _WalletPaymentConfirmPageState extends State { applePayInsertRequest.isMobSDK = true; applePayInsertRequest.merchantReference = transID; - applePayInsertRequest.merchantIdentifier = payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier; + applePayInsertRequest.merchantIdentifier = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.merchantIdentifier : payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier; applePayInsertRequest.commandType = "PURCHASE"; - applePayInsertRequest.signature = payfortViewModel.payfortProjectDetailsRespModel!.signature; - applePayInsertRequest.accessCode = payfortViewModel.payfortProjectDetailsRespModel!.accessCode; - applePayInsertRequest.shaRequestPhrase = payfortViewModel.payfortProjectDetailsRespModel!.shaRequest; - applePayInsertRequest.shaResponsePhrase = payfortViewModel.payfortProjectDetailsRespModel!.shaResponse; + applePayInsertRequest.signature = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.signature : payfortViewModel.payfortProjectDetailsRespModel!.signature; + applePayInsertRequest.accessCode = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.accessCode : payfortViewModel.payfortProjectDetailsRespModel!.accessCode; + applePayInsertRequest.shaRequestPhrase = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.shaRequest : payfortViewModel.payfortProjectDetailsRespModel!.shaRequest; + applePayInsertRequest.shaResponsePhrase = appState.isPaytabsEnabled ? paytabsViewModel.paytabsProjectDetailsRespModel!.shaResponse : payfortViewModel.payfortProjectDetailsRespModel!.shaResponse; applePayInsertRequest.returnURL = ""; //TODO: Need to pass dynamic params to the Apple Pay instead of static values @@ -592,7 +598,6 @@ class _WalletPaymentConfirmPageState extends State { if(appState.isPaytabsEnabled) { selectedPaymentMethod = "VISA"; LoaderBottomSheet.hideLoader(); - paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount); paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { LoaderBottomSheet.showLoader(); await habibWalletVM.HISCreateAdvancePayment( diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index bf1a7b62..1f8def35 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -357,21 +357,7 @@ class _LandingPageState extends State { // spacing: 18.h, children: [ Stack(clipBehavior: Clip.none, children: [ - if (appState.isAuthenticated) - Utils.buildSvgWithAssets(icon: AppAssets.bell, height: 24.h, width: 24.h).onPress(() async { - if (appState.isAuthenticated) { - notificationsViewModel.setNotificationStatusID(2); - notificationsViewModel.getAllNotifications(); - Navigator.of(context).push( - CustomPageRoute( - page: NotificationsListPage(), - // page: LoginScreen(), - ), - ); - } else { - await authVM.onLoginPressed(); - } - }), + if (appState.isAuthenticated) Utils.buildSvgWithAssets(icon: AppAssets.bell, height: 24.h, width: 24.h), (appState.isAuthenticated && todoSectionVM.notificationsCount != null && todoSectionVM.notificationsCount != "0") ? Positioned( // right: appState.isArabic() ? 8.w : -8.w, @@ -399,7 +385,20 @@ class _LandingPageState extends State { ), ) : SizedBox.shrink(), - ]), + ]).onPress(() async { + if (appState.isAuthenticated) { + notificationsViewModel.setNotificationStatusID(2); + notificationsViewModel.getAllNotifications(); + Navigator.of(context).push( + CustomPageRoute( + page: NotificationsListPage(), + // page: LoginScreen(), + ), + ); + } else { + await authVM.onLoginPressed(); + } + }), SizedBox( width: 24.w, ), diff --git a/lib/presentation/todo_section/ancillary_order_payment_page.dart b/lib/presentation/todo_section/ancillary_order_payment_page.dart index e7553df5..365dff2b 100644 --- a/lib/presentation/todo_section/ancillary_order_payment_page.dart +++ b/lib/presentation/todo_section/ancillary_order_payment_page.dart @@ -150,10 +150,7 @@ class _AncillaryOrderPaymentPageState extends State { widget.projectID, appState.getAuthenticatedUser()!.patientId!, ); - paytabsViewModel.setPaymentConfiguration( - "Ancillary Orders Payment", - widget.totalAmount, - ); + await paytabsViewModel.setPaymentConfiguration("Ancillary Orders Payment", widget.totalAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), widget.projectID); paytabsViewModel.startCardPayment( paymentOption: selectedPaymentMethod, liveServiceID: "0", @@ -289,10 +286,7 @@ class _AncillaryOrderPaymentPageState extends State { widget.projectID, appState.getAuthenticatedUser()!.patientId!, ); - paytabsViewModel.setPaymentConfiguration( - "Ancillary Orders Payment", - widget.totalAmount, - ); + await paytabsViewModel.setPaymentConfiguration("Ancillary Orders Payment", widget.totalAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), widget.projectID); paytabsViewModel.startCardPayment(paymentOption: selectedPaymentMethod, liveServiceID: "0", isScheduleLiveCare: "false", @@ -721,11 +715,13 @@ class _AncillaryOrderPaymentPageState extends State { transID = Utils.getAdvancePaymentTransID(widget.projectID, user!.patientId!); ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest(); - await payfortViewModel.getPayfortConfigurations( - serviceId: ServiceTypeEnum.ancillaryOrder.getIdFromServiceEnum(), - projectId: widget.projectID, - integrationId: 2, - ); + if (!appState.isPaytabsEnabled) { + await payfortViewModel.getPayfortConfigurations( + serviceId: ServiceTypeEnum.ancillaryOrder.getIdFromServiceEnum(), + projectId: widget.projectID, + integrationId: 2, + ); + } applePayInsertRequest.clientRequestID = transID; applePayInsertRequest.clinicID = 0; @@ -770,6 +766,10 @@ class _AncillaryOrderPaymentPageState extends State { applePayInsertRequest.returnURL = ""; try { + if (appState.isPaytabsEnabled) { + await paytabsViewModel.setPaymentConfiguration("Ancillary Orders Payment", widget.totalAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), widget.projectID); + } + await payfortViewModel.applePayRequestInsert(applePayInsertRequest: applePayInsertRequest); } catch (error) { log("Apple Pay Insert Request Failed: $error"); @@ -787,10 +787,6 @@ class _AncillaryOrderPaymentPageState extends State { if(appState.isPaytabsEnabled) { selectedPaymentMethod = "VISA"; LoaderBottomSheet.hideLoader(); - paytabsViewModel.setPaymentConfiguration( - "Ancillary Orders Payment", - widget.totalAmount, - ); paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { final paymentAmount = widget.totalAmount; final fortId = transactionData.transactionReference;