From 2532d958958af392ca2ef18a21786b288feaaf2a Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 9 Aug 2026 10:37:32 +0300 Subject: [PATCH 1/4] updates --- .../book_appointment_page.dart | 1 + .../book_appointment/doctor_profile_page.dart | 2 + .../hmg_services/services_page.dart | 94 ++++++++++--------- pubspec.yaml | 4 +- 4 files changed, 54 insertions(+), 47 deletions(-) diff --git a/lib/presentation/book_appointment/book_appointment_page.dart b/lib/presentation/book_appointment/book_appointment_page.dart index 9b210eee..cb93d9e0 100644 --- a/lib/presentation/book_appointment/book_appointment_page.dart +++ b/lib/presentation/book_appointment/book_appointment_page.dart @@ -552,6 +552,7 @@ class _BookAppointmentPageState extends State { Transform.flip(flipX: appState.isArabic(), child: Utils.buildSvgWithAssets(icon: AppAssets.forward_arrow_icon, iconColor: AppColors.textColor, width: 40.h, height: 40.h)), ], ).onPress(() { + Clarity.sendCustomEvent('Select_Region_Page'); bookAppointmentsViewModel.setProjectID(null); openRegionListBottomSheet(context, RegionBottomSheetType.FOR_REGION); }), diff --git a/lib/presentation/book_appointment/doctor_profile_page.dart b/lib/presentation/book_appointment/doctor_profile_page.dart index a3b4aa48..9b5d6583 100644 --- a/lib/presentation/book_appointment/doctor_profile_page.dart +++ b/lib/presentation/book_appointment/doctor_profile_page.dart @@ -1,3 +1,4 @@ +import 'package:clarity_flutter/clarity_flutter.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart'; @@ -30,6 +31,7 @@ class DoctorProfilePage extends StatelessWidget { @override Widget build(BuildContext context) { + Clarity.setCurrentScreenName('Doctor Profile Page'); final bookAppointmentsViewModel = Provider.of(context, listen: false); final appState = getIt.get(); return Scaffold( diff --git a/lib/presentation/hmg_services/services_page.dart b/lib/presentation/hmg_services/services_page.dart index 75144cf7..582fd6fc 100644 --- a/lib/presentation/hmg_services/services_page.dart +++ b/lib/presentation/hmg_services/services_page.dart @@ -1,6 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; +import 'package:get_it/get_it.dart'; import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_export.dart'; @@ -13,8 +14,10 @@ import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; import 'package:hmg_patient_app_new/features/blood_donation/blood_donation_view_model.dart'; import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_view_model.dart'; +import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; import 'package:hmg_patient_app_new/features/hmg_services/models/ui_models/hmg_services_component_model.dart'; +import 'package:hmg_patient_app_new/features/hospital/hospital_selection_view_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart'; import 'package:hmg_patient_app_new/features/water_monitor/water_monitor_view_model.dart'; import 'package:hmg_patient_app_new/features/weather/weather_view_model.dart'; @@ -45,6 +48,7 @@ import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../core/dependencies.dart'; +import '../emergency_services/call_ambulance/widgets/HospitalBottomSheetBody.dart'; class ServicesPage extends StatefulWidget { final bool showBackIcon; @@ -116,51 +120,51 @@ class _ServicesPageState extends State { ); } }), - // HmgServicesComponentModel( - // 11, - // LocaleKeys.indoorNavigation.tr(), - // "", - // AppAssets.indoor_nav_icon, - // bgColor: Color(0xff45A2F8), - // true, - // route: null, - // onTap: () { - // showCommonBottomSheetWithoutHeight( - // title: LocaleKeys.selectHospital.tr(), - // GetIt.instance().navigatorKey.currentContext!, - // child: ChangeNotifierProvider( - // create: (context) => HospitalSelectionBottomSheetViewModel(getIt()), - // child: Consumer( - // builder: (_, vm, __) => HospitalBottomSheetBody( - // searchText: vm.searchController, - // displayList: vm.displayList, - // onFacilityClicked: (value) { - // vm.setSelectedFacility(value); - // vm.getDisplayList(); - // }, - // onHospitalClicked: (hospital) { - // Navigator.pop(GetIt.instance().navigatorKey.currentContext!); - // vm.openPenguin(hospital); - // }, - // onHospitalSearch: (value) { - // vm.searchHospitals(value ?? ""); - // }, - // selectedFacility: vm.selectedFacility, - // hmcCount: vm.hmcCount, - // hmgCount: vm.hmgCount, - // ), - // ), - // ), - // isFullScreen: false, - // isCloseButtonVisible: true, - // hasBottomPadding: false, - // backgroundColor: AppColors.bottomSheetBgColor, - // callBackFunc: () { - // GetIt.instance().navigatorKey.currentContext!.read().clearSearchText(); - // }, - // ); - // }, - // ), + HmgServicesComponentModel( + 11, + LocaleKeys.indoorNavigation.tr(), + "", + AppAssets.indoor_nav_icon, + bgColor: Color(0xff45A2F8), + true, + route: null, + onTap: () { + showCommonBottomSheetWithoutHeight( + title: LocaleKeys.selectHospital.tr(), + GetIt.instance().navigatorKey.currentContext!, + child: ChangeNotifierProvider( + create: (context) => HospitalSelectionBottomSheetViewModel(getIt()), + child: Consumer( + builder: (_, vm, __) => HospitalBottomSheetBody( + searchText: vm.searchController, + displayList: vm.displayList, + onFacilityClicked: (value) { + vm.setSelectedFacility(value); + vm.getDisplayList(); + }, + onHospitalClicked: (hospital) { + Navigator.pop(GetIt.instance().navigatorKey.currentContext!); + vm.openPenguin(hospital); + }, + onHospitalSearch: (value) { + vm.searchHospitals(value ?? ""); + }, + selectedFacility: vm.selectedFacility, + hmcCount: vm.hmcCount, + hmgCount: vm.hmgCount, + ), + ), + ), + isFullScreen: false, + isCloseButtonVisible: true, + hasBottomPadding: false, + backgroundColor: AppColors.bottomSheetBgColor, + callBackFunc: () { + GetIt.instance().navigatorKey.currentContext!.read().clearSearchText(); + }, + ); + }, + ), HmgServicesComponentModel( 11, LocaleKeys.eReferralServices.tr(), "", AppAssets.eReferral, bgColor: AppColors.eReferralCardColor, true, route: null, onTap: () async { if (getIt.get().isAuthenticated) { diff --git a/pubspec.yaml b/pubspec.yaml index df7ce33e..a70a56a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,8 +2,8 @@ name: hmg_patient_app_new description: "New HMG Patient App" publish_to: 'none' # Remove this line if you wish to publish to pub.dev -#version: 0.0.40+41 -version: 0.0.11+1 +version: 0.0.41+42 +#version: 0.0.11+1 environment: sdk: ">=3.6.0 <4.0.0" -- 2.30.2 From 91b999d31361eeccf2ec6cc455ed7571fcc4639a Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 9 Aug 2026 11:14:54 +0300 Subject: [PATCH 2/4] updates --- ios/Runner.xcodeproj/project.pbxproj | 24 ++++++++++++++++-------- pubspec.yaml | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index fdc3bdfa..f52d12fc 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -8,8 +8,8 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 1587365701FF0D2AAAFED0D8 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A83C76CFF9D3F92EDE3B22B4 /* Pods_Runner.framework */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 37D27FAF2C38AC83B852680C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A83C76CFF9D3F92EDE3B22B4 /* Pods_Runner.framework */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 478CFA942E638C8E0064F3D7 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 478CFA932E638C8E0064F3D7 /* GoogleService-Info.plist */; }; 61243B492EC5FA3700D46FA0 /* PenguinModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61243B422EC5FA3700D46FA0 /* PenguinModel.swift */; }; @@ -100,7 +100,7 @@ 76B1D2512F91BF8000DBBD1B /* Penguin.xcframework in Frameworks */, 76B1D2552F91BF8000DBBD1B /* PenNavUI.xcframework in Frameworks */, 76B1D2532F91BF8000DBBD1B /* PenguinINRenderer.xcframework in Frameworks */, - DE1EF78253E64BE86845D2CC /* Pods_Runner.framework in Frameworks */, + 37D27FAF2C38AC83B852680C /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -339,10 +339,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; @@ -356,10 +360,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; @@ -519,7 +527,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 3A359E86ZF; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -529,7 +537,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.0.5; + MARKETING_VERSION = 0.0.12; PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.HMGPatientApp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -706,7 +714,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 3A359E86ZF; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -716,7 +724,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.0.5; + MARKETING_VERSION = 0.0.12; PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.HMGPatientApp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -736,7 +744,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 3A359E86ZF; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -746,7 +754,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.0.5; + MARKETING_VERSION = 0.0.12; PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.HMGPatientApp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/pubspec.yaml b/pubspec.yaml index a70a56a8..1685f8df 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,8 +2,8 @@ name: hmg_patient_app_new description: "New HMG Patient App" publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.41+42 -#version: 0.0.11+1 +#version: 0.0.42+43 +version: 0.0.12+1 environment: sdk: ">=3.6.0 <4.0.0" -- 2.30.2 From 64e60456cc776db5867c86c189375fada422edb2 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 9 Aug 2026 16:42:04 +0300 Subject: [PATCH 3/4] updates --- .../my_appointments/my_appointments_repo.dart | 7 +++--- .../my_appointments_view_model.dart | 16 ++++++++----- .../book_appointment/select_doctor_page.dart | 24 +++++++++++++++++-- .../book_appointment/widgets/doctor_card.dart | 7 +++--- lib/presentation/home/landing_page.dart | 2 +- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/lib/features/my_appointments/my_appointments_repo.dart b/lib/features/my_appointments/my_appointments_repo.dart index d7a926d3..87fb2ec2 100644 --- a/lib/features/my_appointments/my_appointments_repo.dart +++ b/lib/features/my_appointments/my_appointments_repo.dart @@ -25,7 +25,7 @@ import 'models/resp_models/appointment_details_resp_model.dart'; abstract class MyAppointmentsRepo { Future>>> getPatientAppointments( - {required bool isActiveAppointment, required bool isArrivedAppointments, bool isForEyeMeasurement = false}); + {required bool isActiveAppointment, required bool isArrivedAppointments, bool isForEyeMeasurement = false, bool isForTimeLine = false}); Future>> getPatientShareAppointment( {required int projectID, required int clinicID, required String appointmentNo, required bool isLiveCareAppointment}); @@ -105,14 +105,15 @@ class MyAppointmentsRepoImp implements MyAppointmentsRepo { @override Future>>> getPatientAppointments( - {required bool isActiveAppointment, required bool isArrivedAppointments, bool isForEyeMeasurement = false}) async { + {required bool isActiveAppointment, required bool isArrivedAppointments, bool isForEyeMeasurement = false, bool isForTimeLine = false}) async { Map mapDevice = { "IsActiveAppointment": isActiveAppointment, "IsComingFromCOC": false, "isForUpcomming": false, "IsForMedicalReport": false, "IsForArrived": isArrivedAppointments, - "IsIrisPrescription": isForEyeMeasurement + "IsIrisPrescription": isForEyeMeasurement, + "IsForTimeLine": isForTimeLine }; try { diff --git a/lib/features/my_appointments/my_appointments_view_model.dart b/lib/features/my_appointments/my_appointments_view_model.dart index 52d8b240..1689b57a 100644 --- a/lib/features/my_appointments/my_appointments_view_model.dart +++ b/lib/features/my_appointments/my_appointments_view_model.dart @@ -55,6 +55,7 @@ class MyAppointmentsViewModel extends ChangeNotifier { bool isAppointmentDataToBeLoaded = true; bool isMyDoctorsDataToBeLoaded = true; + bool isArrivedAppointmentDataLoaded = false; bool isEyeMeasurementsAppointmentsLoading = false; @@ -76,7 +77,7 @@ class MyAppointmentsViewModel extends ChangeNotifier { List patientUpcomingAppointmentsHistoryList = []; List patientArrivedAppointmentsHistoryList = []; - List patientTimelineAppointmentsList = []; + List patientAllArrivedAppointmentsHistoryList = []; List patientMyDoctorsList = []; @@ -172,7 +173,7 @@ class MyAppointmentsViewModel extends ChangeNotifier { patientAppointmentsHistoryList.clear(); patientUpcomingAppointmentsHistoryList.clear(); patientArrivedAppointmentsHistoryList.clear(); - patientTimelineAppointmentsList.clear(); + patientAllArrivedAppointmentsHistoryList.clear(); patientEyeMeasurementsAppointmentsHistoryList.clear(); isMyAppointmentsLoading = true; isTimeLineAppointmentsLoading = true; @@ -266,7 +267,7 @@ class MyAppointmentsViewModel extends ChangeNotifier { ); } - Future getPatientAppointments(bool isActiveAppointment, bool isArrivedAppointments, {Function(dynamic)? onSuccess, Function(String)? onError}) async { + Future getPatientAppointments(bool isActiveAppointment, bool isArrivedAppointments, {bool isForTimeLine = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { if (patientArrivedAppointmentsHistoryList.isNotEmpty) { isPatientHasQueueAppointment = false; notifyListeners(); @@ -277,12 +278,11 @@ class MyAppointmentsViewModel extends ChangeNotifier { } if (!isAppointmentDataToBeLoaded) return; - patientAppointmentsByClinic.clear(); patientAppointmentsByHospital.clear(); patientAppointmentsViewList.clear(); - patientTimelineAppointmentsList.clear(); + patientAllArrivedAppointmentsHistoryList.clear(); filteredAppointmentList.clear(); patientAppointmentsHistoryList.clear(); patientUpcomingAppointmentsHistoryList.clear(); @@ -291,7 +291,7 @@ class MyAppointmentsViewModel extends ChangeNotifier { final results = await Future.wait([ myAppointmentsRepo.getPatientAppointments(isActiveAppointment: isActiveAppointment, isArrivedAppointments: isArrivedAppointments), - myAppointmentsRepo.getPatientAppointments(isActiveAppointment: false, isArrivedAppointments: true), + myAppointmentsRepo.getPatientAppointments(isActiveAppointment: false, isArrivedAppointments: true, isForTimeLine: isForTimeLine), ]); results[0].fold( @@ -320,6 +320,10 @@ class MyAppointmentsViewModel extends ChangeNotifier { patientArrivedAppointmentsHistoryList = apiResponse.data!; isMyAppointmentsLoading = false; isAppointmentDataToBeLoaded = false; + if (!isForTimeLine) { + patientAllArrivedAppointmentsHistoryList = apiResponse.data!; + isArrivedAppointmentDataLoaded = true; + } notifyListeners(); if (onSuccess != null) { onSuccess(apiResponse); diff --git a/lib/presentation/book_appointment/select_doctor_page.dart b/lib/presentation/book_appointment/select_doctor_page.dart index 132cd46a..8813da07 100644 --- a/lib/presentation/book_appointment/select_doctor_page.dart +++ b/lib/presentation/book_appointment/select_doctor_page.dart @@ -134,8 +134,28 @@ class _SelectDoctorPageState extends State { isLoading: bookAppointmentsVM.isClinicsListLoading, doctorsListResponseModel: bookAppointmentsVM.liveCareDoctorsList[index], bookAppointmentsViewModel: bookAppointmentsViewModel, - ).onPress(() { - // onLiveCareClinicSelected(bookAppointmentsVM.liveCareClinicsList[index]); + ).onPress(() async { + bookAppointmentsVM.setSelectedDoctor(bookAppointmentsVM.liveCareDoctorsList[index]); + LoaderBottomSheet.showLoader(); + await bookAppointmentsVM.getDoctorProfile(onSuccess: (dynamic respData) { + LoaderBottomSheet.hideLoader(); + Navigator.of(context).push( + CustomPageRoute( + page: DoctorProfilePage( + isDoctorAllowedToBook: true, + ), + ), + ); + }, onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }); }), ), ), diff --git a/lib/presentation/book_appointment/widgets/doctor_card.dart b/lib/presentation/book_appointment/widgets/doctor_card.dart index fe7cf3e0..180edae0 100644 --- a/lib/presentation/book_appointment/widgets/doctor_card.dart +++ b/lib/presentation/book_appointment/widgets/doctor_card.dart @@ -167,9 +167,10 @@ class DoctorCard extends StatelessWidget { ], ), ), - (doctorsListResponseModel.isLiveCare ?? true) - ? SizedBox.shrink() - : Expanded( + // (doctorsListResponseModel.isLiveCare ?? true) + // ? SizedBox.shrink() + // : + Expanded( flex: 1, child: Utils.buildSvgWithAssets(icon: AppAssets.doctor_profile_icon, width: 20.h, height: 20.h, fit: BoxFit.scaleDown).toShimmer2(isShow: isLoading), ), diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index b3ba5e78..2df8f77c 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -493,8 +493,8 @@ class _LandingPageState extends State { ).paddingSymmetrical(24.h, 0.h).onPress(() { myAppointmentsViewModel.onTabChange(0); myAppointmentsViewModel.updateListWRTTab(0); - Navigator.of(context).push(CustomPageRoute(page: MyAppointmentsPage())); + Navigator.of(context).push(CustomPageRoute(page: MyAppointmentsPage())); // getIt.get().setPaymentConfiguration("Appointment Payment", 15.5); // getIt.get().startCardPayment(); }), -- 2.30.2 From ed653d8108220f6814631fb9d94b45aac0a7691a Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 9 Aug 2026 17:47:50 +0300 Subject: [PATCH 4/4] Payment request & response insert implemented in paytabs. --- lib/core/api_consts.dart | 2 +- lib/core/dependencies.dart | 6 +- lib/features/paytabs/paytabs_view_model.dart | 199 +++++++++++++++--- .../appointment_payment_page.dart | 44 +++- .../immediate_livecare_payment_page.dart | 40 +++- .../waiting_appointment_payment_page.dart | 45 +++- .../er_online_checkin_payment_page.dart | 42 +++- .../wallet_payment_confirm_page.dart | 36 +++- .../ancillary_order_payment_page.dart | 39 +++- 9 files changed, 400 insertions(+), 53 deletions(-) diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 7744dee7..9fb7050a 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -5,7 +5,7 @@ import 'package:hmg_patient_app_new/core/enums.dart'; 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 diff --git a/lib/core/dependencies.dart b/lib/core/dependencies.dart index ecfe1324..e4ca4c25 100644 --- a/lib/core/dependencies.dart +++ b/lib/core/dependencies.dart @@ -369,7 +369,11 @@ class AppDependencies { errorHandlerService: getIt(), )); - getIt.registerLazySingleton(() => PayTabsViewModel(appState: getIt())); + getIt.registerLazySingleton(() => PayTabsViewModel( + appState: getIt(), + payfortRepo: getIt(), + errorHandlerService: getIt(), + )); getIt.registerLazySingleton( () => ClarityService(appState: getIt.get()), diff --git a/lib/features/paytabs/paytabs_view_model.dart b/lib/features/paytabs/paytabs_view_model.dart index 35a924af..508753ef 100644 --- a/lib/features/paytabs/paytabs_view_model.dart +++ b/lib/features/paytabs/paytabs_view_model.dart @@ -11,17 +11,29 @@ import 'package:flutter_paytabs_bridge/PaymentSdkTransactionType.dart'; import 'package:flutter_paytabs_bridge/flutter_paytabs_bridge.dart'; import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; +import 'package:hmg_patient_app_new/core/cache_consts.dart'; +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/paytabs/models/paytabs_transaction_response_model.dart'; +import 'package:hmg_patient_app_new/features/payfort/models/payfort_request_insert_model.dart'; +import 'package:hmg_patient_app_new/features/payfort/models/payfort_response_insert_model.dart'; +import 'package:hmg_patient_app_new/features/payfort/payfort_repo.dart'; +import 'package:hmg_patient_app_new/services/error_handler_service.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; class PayTabsViewModel extends ChangeNotifier { late PaymentSdkConfigurationDetails paymentConfiguration; final AppState appState; + final PayfortRepo payfortRepo; + final ErrorHandlerService errorHandlerService; late PaytabsTransactionResponseModel paytabsTransactionResponseModel; PayTabsViewModel({ required this.appState, + required this.payfortRepo, + required this.errorHandlerService, }); setPaymentConfiguration(String paymentDescription, num amount, {bool isAddCard = false}) { @@ -152,6 +164,42 @@ class PayTabsViewModel extends ChangeNotifier { notifyListeners(); } + Future paytabsRequestInsert({required PayfortRequestInsertModel payfortRequestInsertModel, Function(dynamic)? onSuccess, Function(String)? onError}) async { + final result = await payfortRepo.payfortRequestInsert(payfortRequestInsertModel: payfortRequestInsertModel); + + 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) { + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } + + Future paytabsResponseInsert({required PayfortResponseInsertModel payfortResponseInsertModel, Function(dynamic)? onSuccess, Function(String)? onError}) async { + final result = await payfortRepo.payfortResponseInsert(payfortResponseInsertModel: payfortResponseInsertModel); + + 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) { + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } + startApplePayPayment({Function(PaytabsTransactionResponseModel)? onSuccess, Function(String)? onError}) async { bool _callbackFired = false; // prevent duplicate callback invocations @@ -189,41 +237,132 @@ class PayTabsViewModel extends ChangeNotifier { }); } - startCardPayment({Function(PaytabsTransactionResponseModel)? onSuccess, Function(String)? onError}) { + startCardPayment({ + required String paymentOption, + required String liveServiceID, + required String isScheduleLiveCare, + required String appointmentDate, + required String appointmentNo, + required String doctorID, + required String transactionID, + required String amount, + required String fileNumber, + required String orderDescription, + required String serviceID, + required String projectID, + Function(PaytabsTransactionResponseModel)? onSuccess, + Function(String)? onError, + }) async { bool _callbackFired = false; // prevent duplicate callback invocations - FlutterPaytabsBridge.startCardPayment(paymentConfiguration, (event) { - if (_callbackFired) return; // ignore any subsequent callback calls + try { + LoaderBottomSheet.showLoader(); - final transactionDetails = event["data"] as Map?; - if (event["status"] == "success") { - _callbackFired = true; - // Cast Map to Map - final data = Map.from(event["data"] as Map); - paytabsTransactionResponseModel = PaytabsTransactionResponseModel.fromJson(data); - if (paytabsTransactionResponseModel.isSuccess!) { - onSuccess!(paytabsTransactionResponseModel); - } else { - // Transaction was processed but failed - final reason = - transactionDetails?["payResponseReturn"] ?? transactionDetails?["responseMessage"] ?? transactionDetails?["message"] ?? "Unknown error"; - final responseCode = transactionDetails?["responseCode"] ?? ""; - final errorMessage = - responseCode.toString().isNotEmpty ? "Transaction failed (Code: $responseCode): $reason" : "Transaction failed: $reason"; - onError!(errorMessage); + // Create PayfortRequestInsertModel (same as Payfort implementation) + PayfortRequestInsertModel payfortRequestInsertModel = PayfortRequestInsertModel(); + + payfortRequestInsertModel.commandType = "SALE"; + payfortRequestInsertModel.amount = num.parse(amount); + payfortRequestInsertModel.customerEmail = getIt.get().getAuthenticatedUser()!.emailAddress; + payfortRequestInsertModel.orderDescription = orderDescription; + payfortRequestInsertModel.serviceID = serviceID; + payfortRequestInsertModel.paymentOption = paymentOption; + payfortRequestInsertModel.clientRequestID = transactionID; + payfortRequestInsertModel.projectID = projectID; + payfortRequestInsertModel.fileNumber = getIt.get().getAuthenticatedUser()!.patientId.toString(); + payfortRequestInsertModel.customerName = "${getIt.get().getAuthenticatedUser()!.firstName} ${getIt.get().getAuthenticatedUser()!.lastName}"; + payfortRequestInsertModel.currency = getIt.get().getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED"; + payfortRequestInsertModel.liveServiceID = liveServiceID; + payfortRequestInsertModel.latitude = getIt.get().userLat.toString(); + payfortRequestInsertModel.longitude = getIt.get().userLong.toString(); + payfortRequestInsertModel.merchantReference = transactionID; + payfortRequestInsertModel.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken); + payfortRequestInsertModel.language = getIt.get().isArabic() ? "ar" : "en"; + payfortRequestInsertModel.integrationId = "2"; // PayTabs integration ID + payfortRequestInsertModel.isSchedule = isScheduleLiveCare; + payfortRequestInsertModel.appointmentDate = appointmentDate; + payfortRequestInsertModel.appointmentNo = appointmentNo; + payfortRequestInsertModel.doctorID = doctorID; + + // Call request insert API before payment + await paytabsRequestInsert(payfortRequestInsertModel: payfortRequestInsertModel); + + LoaderBottomSheet.hideLoader(); + + // Start PayTabs payment + FlutterPaytabsBridge.startCardPayment(paymentConfiguration, (event) async { + if (_callbackFired) return; // ignore any subsequent callback calls + + final transactionDetails = event["data"] as Map?; + if (event["status"] == "success") { + _callbackFired = true; + + LoaderBottomSheet.showLoader(); + + // Cast Map to Map + final data = Map.from(event["data"] as Map); + paytabsTransactionResponseModel = PaytabsTransactionResponseModel.fromJson(data); + + // Create PayfortResponseInsertModel (same as Payfort implementation) + PayfortResponseInsertModel payfortResponseInsertModel = PayfortResponseInsertModel(); + + payfortResponseInsertModel.fortId = paytabsTransactionResponseModel.transactionReference ?? ""; + payfortResponseInsertModel.commandType = paytabsTransactionResponseModel.transactionType ?? "SALE"; + // payfortResponseInsertModel.amount = paytabsTransactionResponseModel.tranTotal ?? 0; + payfortResponseInsertModel.amount = num.parse(amount); + payfortResponseInsertModel.sadadOLP = ""; + payfortResponseInsertModel.paymentOption = paytabsTransactionResponseModel.paymentInfo?.paymentMethod ?? ""; + payfortResponseInsertModel.customerIP = ""; + payfortResponseInsertModel.eCI = ""; + payfortResponseInsertModel.responseMessage = paytabsTransactionResponseModel.payResponseReturn ?? ""; + payfortResponseInsertModel.cardNumber = paytabsTransactionResponseModel.paymentInfo!.paymentDescription; + payfortResponseInsertModel.cardBin = ""; + payfortResponseInsertModel.installmentsNumber = 0; + payfortResponseInsertModel.status = paytabsTransactionResponseModel.isSuccess! ? "success" : "failed"; + payfortResponseInsertModel.merchantRef = transactionID; + payfortResponseInsertModel.isRefund = false; + payfortResponseInsertModel.remmeberMe = true; + payfortResponseInsertModel.reconciliationReference = ""; + + // Call response insert API after payment + await paytabsResponseInsert(payfortResponseInsertModel: payfortResponseInsertModel); + + LoaderBottomSheet.hideLoader(); + + if (paytabsTransactionResponseModel.isSuccess!) { + if (onSuccess != null) { + onSuccess(paytabsTransactionResponseModel); + } + } else { + // Transaction was processed but failed + final reason = transactionDetails?["payResponseReturn"] ?? transactionDetails?["responseMessage"] ?? transactionDetails?["message"] ?? "Unknown error"; + final responseCode = transactionDetails?["responseCode"] ?? ""; + final errorMessage = responseCode.toString().isNotEmpty ? "Transaction failed (Code: $responseCode): $reason" : "Transaction failed: $reason"; + if (onError != null) { + onError(errorMessage); + } + } + } else if (event["status"] == "error") { + _callbackFired = true; + final errorMessage = event["message"] ?? "An error occurred"; + debugPrint("Error occurred in transaction: $errorMessage"); + debugPrint("Full error event: $event"); + if (onError != null) { + onError(errorMessage); + } + } else if (event["status"] == "event") { + // Intermediate SDK events – do NOT mark _callbackFired, just log + final eventMessage = event["message"] ?? "Event occurred"; + debugPrint("Event occurred: $eventMessage"); } - } else if (event["status"] == "error") { - _callbackFired = true; - final errorMessage = event["message"] ?? "An error occurred"; - debugPrint("Error occurred in transaction: $errorMessage"); - debugPrint("Full error event: $event"); - onError!(errorMessage); - } else if (event["status"] == "event") { - // Intermediate SDK events – do NOT mark _callbackFired, just log - final eventMessage = event["message"] ?? "Event occurred"; - debugPrint("Event occurred: $eventMessage"); + }); + } catch (error) { + debugPrint("PayTabs Payment Error: $error"); + LoaderBottomSheet.hideLoader(); + if (onError != null) { + onError("Payment initialization failed: $error"); } - }); + } } startAlternatePayment({Function(PaytabsTransactionResponseModel)? onSuccess, Function(String)? onError}) { diff --git a/lib/presentation/appointments/appointment_payment_page.dart b/lib/presentation/appointments/appointment_payment_page.dart index 46130b12..0d864b64 100644 --- a/lib/presentation/appointments/appointment_payment_page.dart +++ b/lib/presentation/appointments/appointment_payment_page.dart @@ -139,12 +139,30 @@ class _AppointmentPaymentPageState extends State { ).paddingSymmetrical(24.h, 0.h).onPress(() async { selectedPaymentMethod = "MADA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAppointmentTransID( + widget.patientAppointmentHistoryResponseModel.projectID, + widget.patientAppointmentHistoryResponseModel.clinicID, + widget.patientAppointmentHistoryResponseModel.appointmentNo, + ); paytabsViewModel.setPaymentConfiguration( "Appointment Payment", num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), ); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { - LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context)); + paytabsViewModel.startCardPayment( + paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment! ? "true" : "false", + appointmentDate: widget.patientAppointmentHistoryResponseModel.appointmentDate!, + appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(), + doctorID: widget.patientAppointmentHistoryResponseModel.doctorID.toString(), + transactionID: transID, + amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(), + fileNumber: appState.getAuthenticatedUser()!.patientId.toString(), + orderDescription: "Appointment Payment", + serviceID: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(), + projectID: widget.patientAppointmentHistoryResponseModel.projectID.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context)); await myAppointmentsViewModel.createAdvancePayment( paymentMethodName: selectedPaymentMethod, projectID: widget.patientAppointmentHistoryResponseModel.projectID, @@ -362,12 +380,30 @@ class _AppointmentPaymentPageState extends State { ).paddingSymmetrical(24.h, 0.h).onPress(() async { selectedPaymentMethod = "VISA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAppointmentTransID( + widget.patientAppointmentHistoryResponseModel.projectID, + widget.patientAppointmentHistoryResponseModel.clinicID, + widget.patientAppointmentHistoryResponseModel.appointmentNo, + ); paytabsViewModel.setPaymentConfiguration( "Appointment Payment", num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()), ); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { - LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context)); + paytabsViewModel.startCardPayment( + paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment! ? "true" : "false", + appointmentDate: widget.patientAppointmentHistoryResponseModel.appointmentDate!, + appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(), + doctorID: widget.patientAppointmentHistoryResponseModel.doctorID.toString(), + transactionID: transID, + amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(), + fileNumber: appState.getAuthenticatedUser()!.patientId.toString(), + orderDescription: "Appointment Payment", + serviceID: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(), + projectID: widget.patientAppointmentHistoryResponseModel.projectID.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context)); await myAppointmentsViewModel.createAdvancePayment( paymentMethodName: selectedPaymentMethod, projectID: widget.patientAppointmentHistoryResponseModel.projectID, 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 ef21ccbd..9ef3f8fb 100644 --- a/lib/presentation/book_appointment/livecare/immediate_livecare_payment_page.dart +++ b/lib/presentation/book_appointment/livecare/immediate_livecare_payment_page.dart @@ -130,11 +130,29 @@ class _ImmediateLiveCarePaymentPageState extends State ).paddingSymmetrical(24.h, 0.h).onPress(() { selectedPaymentMethod = "MADA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAdvancePaymentTransID( + emergencyServicesViewModel.selectedHospital!.iD, + appState.getAuthenticatedUser()!.patientId!, + ); paytabsViewModel.setPaymentConfiguration( "ER Online Check-In Payment", emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!, ); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { - if (emergencyServicesViewModel.isERBookAppointment) { + paytabsViewModel.startCardPayment( + paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: "0", + appointmentDate: "", + appointmentNo: "0", + doctorID: "0", + transactionID: transID, + amount: emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!.toString(), + fileNumber: appState.getAuthenticatedUser()!.patientId.toString(), + orderDescription: "ER Online Check-In Payment", + serviceID: ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum().toString(), + projectID: emergencyServicesViewModel.selectedHospital!.iD.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { + if (emergencyServicesViewModel.isERBookAppointment) { await emergencyServicesViewModel.ER_CreateAdvancePayment( paymentMethodName: selectedPaymentMethod, paymentReference: transactionData.transactionReference!, @@ -214,12 +231,29 @@ class _ErOnlineCheckinPaymentPageState extends State ).paddingSymmetrical(24.h, 0.h).onPress(() { selectedPaymentMethod = "VISA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAdvancePaymentTransID( + emergencyServicesViewModel.selectedHospital!.iD, + appState.getAuthenticatedUser()!.patientId!, + ); paytabsViewModel.setPaymentConfiguration( "ER Online Check-In Payment", emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!, ); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { - if (emergencyServicesViewModel.isERBookAppointment) { + paytabsViewModel.startCardPayment( + paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: "0", + appointmentDate: "", + appointmentNo: "0", + doctorID: "0", + transactionID: transID, + amount: emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!.toString(), + fileNumber: appState.getAuthenticatedUser()!.patientId.toString(), + orderDescription: "ER Online Check-In Payment", + serviceID: ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum().toString(), + projectID: emergencyServicesViewModel.selectedHospital!.iD.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { + if (emergencyServicesViewModel.isERBookAppointment) { await emergencyServicesViewModel.ER_CreateAdvancePayment( paymentMethodName: selectedPaymentMethod, paymentReference: transactionData.transactionReference!, diff --git a/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart b/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart index f894c387..eea9ec10 100644 --- a/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart +++ b/lib/presentation/habib_wallet/wallet_payment_confirm_page.dart @@ -113,9 +113,23 @@ class _WalletPaymentConfirmPageState extends State { ).paddingSymmetrical(24.h, 0.h).onPress(() async { selectedPaymentMethod = "MADA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber)); paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { - LoaderBottomSheet.showLoader(); + paytabsViewModel.startCardPayment( + paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: "false", + appointmentDate: DateUtil.convertDateToString(DateTime.now()), + appointmentNo: "0", + doctorID: "0", + transactionID: transID, + amount: habibWalletVM.walletRechargeAmount.toString(), + fileNumber: habibWalletVM.fileNumber.toString(), + orderDescription: "Advance Payment", + serviceID: ServiceTypeEnum.advancePayment.getIdFromServiceEnum().toString(), + projectID: habibWalletVM.selectedHospital!.iD!.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { + LoaderBottomSheet.showLoader(); await habibWalletVM.HISCreateAdvancePayment( paymentMethodName: selectedPaymentMethod, paidAmount: habibWalletVM.walletRechargeAmount, @@ -295,9 +309,23 @@ class _WalletPaymentConfirmPageState extends State { ).paddingSymmetrical(24.h, 0.h).onPress(() async { selectedPaymentMethod = "VISA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber)); paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { - LoaderBottomSheet.showLoader(); + paytabsViewModel.startCardPayment( + paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: "false", + appointmentDate: DateUtil.convertDateToString(DateTime.now()), + appointmentNo: "0", + doctorID: "0", + transactionID: transID, + amount: habibWalletVM.walletRechargeAmount.toString(), + fileNumber: habibWalletVM.fileNumber.toString(), + orderDescription: "Advance Payment", + serviceID: ServiceTypeEnum.advancePayment.getIdFromServiceEnum().toString(), + projectID: habibWalletVM.selectedHospital!.iD!.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { + LoaderBottomSheet.showLoader(); await habibWalletVM.HISCreateAdvancePayment( paymentMethodName: selectedPaymentMethod, paidAmount: habibWalletVM.walletRechargeAmount, diff --git a/lib/presentation/todo_section/ancillary_order_payment_page.dart b/lib/presentation/todo_section/ancillary_order_payment_page.dart index ae0a4c02..80b79a88 100644 --- a/lib/presentation/todo_section/ancillary_order_payment_page.dart +++ b/lib/presentation/todo_section/ancillary_order_payment_page.dart @@ -132,12 +132,29 @@ class _AncillaryOrderPaymentPageState extends State { if (!todoVM.isProcessingPayment) { selectedPaymentMethod = "MADA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAdvancePaymentTransID( + widget.projectID, + appState.getAuthenticatedUser()!.patientId!, + ); paytabsViewModel.setPaymentConfiguration( "Ancillary Orders Payment", widget.totalAmount, ); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { - final paymentAmount = widget.totalAmount; + paytabsViewModel.startCardPayment( + paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: "false", + appointmentDate: DateUtil.convertDateToString(DateTime.now()), + appointmentNo: "0", + doctorID: "0", + transactionID: transID, + amount: widget.totalAmount.toString(), + fileNumber: appState.getAuthenticatedUser()!.patientId!.toString(), + orderDescription: "Ancillary Orders Payment", + serviceID: ServiceTypeEnum.advancePayment.getIdFromServiceEnum().toString(), + projectID: widget.projectID.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { + final paymentAmount = widget.totalAmount; final fortId = transactionData.transactionReference; final paymentMethod = selectedPaymentMethod; @@ -254,11 +271,27 @@ class _AncillaryOrderPaymentPageState extends State { if (!todoVM.isProcessingPayment) { selectedPaymentMethod = "VISA"; if (appState.isPaytabsEnabled) { + transID = Utils.getAdvancePaymentTransID( + widget.projectID, + appState.getAuthenticatedUser()!.patientId!, + ); paytabsViewModel.setPaymentConfiguration( "Ancillary Orders Payment", widget.totalAmount, ); - paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async { + paytabsViewModel.startCardPayment(paymentOption: selectedPaymentMethod, + liveServiceID: "0", + isScheduleLiveCare: "false", + appointmentDate: DateUtil.convertDateToString(DateTime.now()), + appointmentNo: "0", + doctorID: "0", + transactionID: transID, + amount: widget.totalAmount.toString(), + fileNumber: appState.getAuthenticatedUser()!.patientId!.toString(), + orderDescription: "Ancillary Orders Payment", + serviceID: ServiceTypeEnum.advancePayment.getIdFromServiceEnum().toString(), + projectID: widget.projectID.toString(), + onSuccess: (PaytabsTransactionResponseModel transactionData) async { final paymentAmount = widget.totalAmount; final fortId = transactionData.transactionReference; final paymentMethod = selectedPaymentMethod; -- 2.30.2