Immediate LiveCare consultation implementation contd.
							parent
							
								
									2f4d6f5553
								
							
						
					
					
						commit
						10b77206f6
					
				| @ -0,0 +1,5 @@ | ||||
| <svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||
|     <path d="M12 2.75H11.9278C9.92082 2.74998 8.31557 2.74996 7.0558 2.91933C5.75291 3.0945 4.67453 3.46676 3.82064 4.32064C2.96676 5.17453 2.5945 6.25291 2.41933 7.5558C2.24996 8.81557 2.24998 10.4208 2.25 12.4278V12.5722C2.24998 14.5792 2.24996 16.1844 2.41933 17.4442C2.5945 18.7471 2.96676 19.8255 3.82064 20.6794C4.67453 21.5332 5.75291 21.9055 7.0558 22.0807C8.31558 22.25 9.92083 22.25 11.9278 22.25H12.0722C14.0792 22.25 15.6844 22.25 16.9442 22.0807C18.2471 21.9055 19.3255 21.5332 20.1794 20.6794C21.0332 19.8255 21.4055 18.7471 21.5807 17.4442C21.75 16.1844 21.75 14.5792 21.75 12.5722V12.5C21.75 11.9615 21.3135 11.525 20.775 11.525C20.2365 11.525 19.8 11.9615 19.8 12.5C19.8 14.5959 19.7979 16.0697 19.6481 17.1844C19.502 18.271 19.2317 18.8693 18.8005 19.3005C18.3693 19.7317 17.771 20.002 16.6844 20.1481C15.5697 20.2979 14.0959 20.3 12 20.3C9.90415 20.3 8.43035 20.2979 7.31564 20.1481C6.22898 20.002 5.63068 19.7317 5.1995 19.3005C4.76831 18.8693 4.49804 18.271 4.35194 17.1844C4.20207 16.0697 4.2 14.5959 4.2 12.5C4.2 10.4042 4.20207 8.93035 4.35194 7.81564C4.49804 6.72898 4.76831 6.13068 5.1995 5.6995C5.63068 5.26831 6.22898 4.99804 7.31564 4.85194C8.43035 4.70207 9.90415 4.7 12 4.7C12.5385 4.7 12.975 4.26348 12.975 3.725C12.975 3.18652 12.5385 2.75 12 2.75Z" fill="#2E3039"/> | ||||
|     <path d="M17.0855 3.5503C18.1526 2.48323 19.8827 2.48323 20.9497 3.5503C22.0168 4.61736 22.0168 6.34742 20.9497 7.41448L20.078 8.28615L16.2139 4.42188L17.0855 3.5503Z" fill="#2E3039"/> | ||||
|     <path d="M15.1533 5.48254L19.0174 9.34682L14.2337 14.1306C13.2653 15.0992 12.6734 15.6912 11.9448 16.0983C11.5383 16.3255 10.9218 16.5239 10.291 16.6994C9.64198 16.88 8.89524 17.0578 8.18242 17.2275L8.17373 17.2296C7.92037 17.2899 7.65385 17.2145 7.46969 17.0303C7.28552 16.8462 7.21009 16.5796 7.27041 16.3263L7.27249 16.3175C7.44221 15.6047 7.62 14.858 7.8006 14.209C7.97615 13.5782 8.17455 12.9617 8.40167 12.5553C8.80884 11.8266 9.40083 11.2348 10.3694 10.2664L15.1533 5.48254Z" fill="#2E3039"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 2.0 KiB | 
| @ -0,0 +1,37 @@ | ||||
| class LiveCareImmediateAppointmentFeesList { | ||||
|   String? amount; | ||||
|   String? companyName; | ||||
|   bool? isInsured; | ||||
|   bool? isShowInsuranceUpdateModule; | ||||
|   bool? isCash; | ||||
|   bool? isEligible; | ||||
|   String? tax; | ||||
|   String? total; | ||||
|   String? currency; | ||||
| 
 | ||||
|   LiveCareImmediateAppointmentFeesList({this.amount, this.companyName, this.isInsured, this.isShowInsuranceUpdateModule, this.tax, this.total, this.currency}); | ||||
| 
 | ||||
|   LiveCareImmediateAppointmentFeesList.fromJson(Map<String, dynamic> json) { | ||||
|     amount = json['Amount']; | ||||
|     companyName = json['CompanyName']; | ||||
|     isInsured = json['IsInsured']; | ||||
|     isCash = json['IsCash']; | ||||
|     isEligible = json['IsEligible']; | ||||
|     isShowInsuranceUpdateModule = json['IsShowInsuranceUpdateModule']; | ||||
|     tax = json['Tax']; | ||||
|     total = json['Total']; | ||||
|     currency = json['currency']; | ||||
|   } | ||||
| 
 | ||||
|   Map<String, dynamic> toJson() { | ||||
|     final Map<String, dynamic> data = new Map<String, dynamic>(); | ||||
|     data['Amount'] = this.amount; | ||||
|     data['CompanyName'] = this.companyName; | ||||
|     data['IsInsured'] = this.isInsured; | ||||
|     data['IsShowInsuranceUpdateModule'] = this.isShowInsuranceUpdateModule; | ||||
|     data['Tax'] = this.tax; | ||||
|     data['Total'] = this.total; | ||||
|     data['currency'] = this.currency; | ||||
|     return data; | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,301 @@ | ||||
| import 'dart:io'; | ||||
| 
 | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:hmg_patient_app_new/core/app_assets.dart'; | ||||
| import 'package:hmg_patient_app_new/core/app_state.dart'; | ||||
| import 'package:hmg_patient_app_new/core/dependencies.dart'; | ||||
| import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; | ||||
| import 'package:hmg_patient_app_new/core/utils/utils.dart'; | ||||
| import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_view_model.dart'; | ||||
| import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/book_appointment/livecare/immediate_livecare_payment_page.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/book_appointment/livecare/widgets/select_livecare_call_type.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/insurance/insurance_home_page.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; | ||||
| import 'package:permission_handler/permission_handler.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import 'package:smooth_corner/smooth_corner.dart'; | ||||
| 
 | ||||
| class ImmediateLiveCarePaymentDetails extends StatelessWidget { | ||||
|   ImmediateLiveCarePaymentDetails({super.key}); | ||||
| 
 | ||||
|   late BookAppointmentsViewModel bookAppointmentsViewModel; | ||||
|   late AppState appState; | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     bookAppointmentsViewModel = Provider.of<BookAppointmentsViewModel>(context, listen: false); | ||||
|     appState = getIt.get<AppState>(); | ||||
|     return Scaffold( | ||||
|       backgroundColor: AppColors.scaffoldBgColor, | ||||
|       body: Column( | ||||
|         children: [ | ||||
|           Expanded( | ||||
|             child: CollapsingListView( | ||||
|               title: "Review LiveCare Request".needTranslation, | ||||
|               child: SingleChildScrollView( | ||||
|                 padding: EdgeInsets.symmetric(horizontal: 24.h), | ||||
|                 child: Column( | ||||
|                   crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                   children: [ | ||||
|                     SizedBox(height: 24.h), | ||||
|                     LocaleKeys.patientInfo.tr(context: context).toText16(isBold: true), | ||||
|                     SizedBox(height: 16.h), | ||||
|                     Container( | ||||
|                       decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                         color: AppColors.whiteColor, | ||||
|                         borderRadius: 24.h, | ||||
|                         hasShadow: false, | ||||
|                       ), | ||||
|                       child: Padding( | ||||
|                         padding: EdgeInsets.all(16.h), | ||||
|                         child: Row( | ||||
|                           children: [ | ||||
|                             Image.asset( | ||||
|                               appState.getAuthenticatedUser()?.gender == 1 ? AppAssets.male_img : AppAssets.femaleImg, | ||||
|                               width: 52.h, | ||||
|                               height: 52.h, | ||||
|                             ), | ||||
|                             SizedBox(width: 8.h), | ||||
|                             Column( | ||||
|                               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                               children: [ | ||||
|                                 "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}".toText16(isBold: true), | ||||
|                                 SizedBox(height: 8.h), | ||||
|                                 AppCustomChipWidget(labelText: "${appState.getAuthenticatedUser()!.age} Years Old"), | ||||
|                               ], | ||||
|                             ), | ||||
|                           ], | ||||
|                         ), | ||||
|                       ), | ||||
|                     ), | ||||
|                     SizedBox(height: 24.h), | ||||
|                     "Clinic Information".needTranslation.toText16(isBold: true), | ||||
|                     SizedBox(height: 16.h), | ||||
|                     Container( | ||||
|                       decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                         color: AppColors.whiteColor, | ||||
|                         borderRadius: 24.h, | ||||
|                         hasShadow: false, | ||||
|                       ), | ||||
|                       child: Padding( | ||||
|                         padding: EdgeInsets.all(16.h), | ||||
|                         child: Row( | ||||
|                           children: [ | ||||
|                             Utils.buildSvgWithAssets(icon: AppAssets.generic_clinic_icon, width: 32.h, height: 32.h, fit: BoxFit.contain), | ||||
|                             SizedBox(width: 8.h), | ||||
|                             Column( | ||||
|                               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                               children: [ | ||||
|                                 (appState.isArabic() ? bookAppointmentsViewModel.immediateLiveCareSelectedClinic.serviceNameN : bookAppointmentsViewModel.immediateLiveCareSelectedClinic.serviceName)! | ||||
|                                     .toText16(isBold: true), | ||||
|                                 // SizedBox(height: 8.h), | ||||
|                                 // AppCustomChipWidget(labelText: "${appState.getAuthenticatedUser()!.age} Years Old"), | ||||
|                               ], | ||||
|                             ), | ||||
|                           ], | ||||
|                         ), | ||||
|                       ), | ||||
|                     ), | ||||
|                     SizedBox(height: 24.h), | ||||
|                     "Selected LiveCare Type".needTranslation.toText16(isBold: true), | ||||
|                     SizedBox(height: 16.h), | ||||
|                     Consumer<BookAppointmentsViewModel>(builder: (context, bookAppointmentsVM, child) { | ||||
|                       return Container( | ||||
|                         decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                           color: AppColors.whiteColor, | ||||
|                           borderRadius: 24.h, | ||||
|                           hasShadow: false, | ||||
|                         ), | ||||
|                         child: Padding( | ||||
|                           padding: EdgeInsets.all(16.h), | ||||
|                           child: Row( | ||||
|                             mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                             children: [ | ||||
|                               Row( | ||||
|                                 children: [ | ||||
|                                   Utils.buildSvgWithAssets(icon: AppAssets.livecare_clinic_icon, width: 32.h, height: 32.h, fit: BoxFit.contain), | ||||
|                                   SizedBox(width: 8.h), | ||||
|                                   getLiveCareType(bookAppointmentsViewModel.liveCareSelectedCallType).toText16(isBold: true), | ||||
|                                 ], | ||||
|                               ), | ||||
|                               Utils.buildSvgWithAssets(icon: AppAssets.edit_icon, width: 24.h, height: 24.h, fit: BoxFit.contain), | ||||
|                             ], | ||||
|                           ), | ||||
|                         ), | ||||
|                       ).onPress(() { | ||||
|                         showCommonBottomSheetWithoutHeight(context, child: SelectLiveCareCallType(bookAppointmentsViewModel: bookAppointmentsViewModel), callBackFunc: () async { | ||||
|                           debugPrint("Selected Call Type: ${bookAppointmentsViewModel.liveCareSelectedCallType}"); | ||||
|                         }, title: "Select LiveCare call type".needTranslation, isCloseButtonVisible: true, isFullScreen: false); | ||||
|                       }); | ||||
|                     }), | ||||
|                     SizedBox(height: 24.h) | ||||
|                   ], | ||||
|                 ), | ||||
|               ), | ||||
|             ), | ||||
|           ), | ||||
|           Container( | ||||
|             decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|               color: AppColors.whiteColor, | ||||
|               borderRadius: 24.h, | ||||
|               hasShadow: false, | ||||
|             ), | ||||
|             child: Column( | ||||
|               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|               children: [ | ||||
|                 (bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.isCash ?? true) | ||||
|                     ? Container( | ||||
|                         height: 50.h, | ||||
|                         decoration: ShapeDecoration( | ||||
|                           color: AppColors.secondaryLightRedBorderColor, | ||||
|                           shape: SmoothRectangleBorder( | ||||
|                             borderRadius: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)), | ||||
|                             smoothness: 1, | ||||
|                           ), | ||||
|                         ), | ||||
|                         child: Row( | ||||
|                           mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                           children: [ | ||||
|                             "Insurance expired or inactive".needTranslation.toText14(color: AppColors.primaryRedColor, weight: FontWeight.w500).paddingSymmetrical(24.h, 0.h), | ||||
|                             CustomButton( | ||||
|                               text: LocaleKeys.updateInsurance.tr(context: context), | ||||
|                               onPressed: () { | ||||
|                                 Navigator.of(context).push( | ||||
|                                   CustomPageRoute( | ||||
|                                     page: InsuranceHomePage(), | ||||
|                                   ), | ||||
|                                 ); | ||||
|                               }, | ||||
|                               backgroundColor: AppColors.primaryRedColor, | ||||
|                               borderColor: AppColors.secondaryLightRedBorderColor, | ||||
|                               textColor: AppColors.whiteColor, | ||||
|                               fontSize: 10, | ||||
|                               fontWeight: FontWeight.w500, | ||||
|                               borderRadius: 8, | ||||
|                               padding: EdgeInsets.fromLTRB(15, 0, 15, 0), | ||||
|                               height: 30.h, | ||||
|                             ).paddingSymmetrical(24.h, 0.h), | ||||
|                           ], | ||||
|                         ), | ||||
|                       ) | ||||
|                     : const SizedBox(), | ||||
|                 SizedBox(height: 24.h), | ||||
|                 "Total amount to pay".needTranslation.toText18(isBold: true).paddingSymmetrical(24.h, 0.h), | ||||
|                 SizedBox(height: 17.h), | ||||
|                 Row( | ||||
|                   mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                   children: [ | ||||
|                     "Amount before tax".needTranslation.toText14(isBold: true), | ||||
|                     Utils.getPaymentAmountWithSymbol(bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.amount!.toText16(isBold: true), AppColors.blackColor, 13, | ||||
|                         isSaudiCurrency: bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.currency!.toLowerCase() == "sar"), | ||||
|                   ], | ||||
|                 ).paddingSymmetrical(24.h, 0.h), | ||||
|                 Row( | ||||
|                   mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                   children: [ | ||||
|                     "VAT 15%".needTranslation.toText14(isBold: true, color: AppColors.greyTextColor), | ||||
|                     Utils.getPaymentAmountWithSymbol( | ||||
|                         bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.tax!.toText14(isBold: true, color: AppColors.greyTextColor), AppColors.greyTextColor, 13, | ||||
|                         isSaudiCurrency: bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.currency!.toLowerCase() == "sar"), | ||||
|                   ], | ||||
|                 ).paddingSymmetrical(24.h, 0.h), | ||||
|                 SizedBox(height: 17.h), | ||||
|                 Row( | ||||
|                   mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                   children: [ | ||||
|                     SizedBox(width: 150.h, child: Utils.getPaymentMethods()), | ||||
|                     Utils.getPaymentAmountWithSymbol(bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.total!.toText24(isBold: true), AppColors.blackColor, 17, | ||||
|                         isSaudiCurrency: bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.currency!.toLowerCase() == "sar"), | ||||
|                   ], | ||||
|                 ).paddingSymmetrical(24.h, 0.h), | ||||
|                 CustomButton( | ||||
|                   text: LocaleKeys.payNow.tr(context: context), | ||||
|                   onPressed: () async { | ||||
|                     await askVideoCallPermission().then((val) { | ||||
|                       if (val) { | ||||
|                         Navigator.of(context).push( | ||||
|                           CustomPageRoute( | ||||
|                             page: ImmediateLiveCarePaymentPage(), | ||||
|                           ), | ||||
|                         ); | ||||
|                       } else { | ||||
|                         showCommonBottomSheetWithoutHeight( | ||||
|                           title: LocaleKeys.notice.tr(context: context), | ||||
|                           context, | ||||
|                           child: Utils.getWarningWidget( | ||||
|                               loadingText: | ||||
|                                   "LiveCare requires Camera, Microphone & Location permissions to enable virtual consultation between patient & doctor, Please allow these to proceed.".needTranslation, | ||||
|                               isShowActionButtons: true, | ||||
|                               onCancelTap: () { | ||||
|                                 Navigator.pop(context); | ||||
|                               }, | ||||
|                               onConfirmTap: () async { | ||||
|                                 openAppSettings(); | ||||
|                               }), | ||||
|                           callBackFunc: () {}, | ||||
|                           isFullScreen: false, | ||||
|                           isCloseButtonVisible: true, | ||||
|                         ); | ||||
|                       } | ||||
|                     }); | ||||
|                   }, | ||||
|                   backgroundColor: AppColors.infoColor, | ||||
|                   borderColor: AppColors.infoColor, | ||||
|                   textColor: AppColors.whiteColor, | ||||
|                   fontSize: 16, | ||||
|                   fontWeight: FontWeight.w500, | ||||
|                   borderRadius: 12, | ||||
|                   padding: EdgeInsets.fromLTRB(10, 0, 10, 0), | ||||
|                   height: 50.h, | ||||
|                   icon: AppAssets.appointment_pay_icon, | ||||
|                   iconColor: AppColors.whiteColor, | ||||
|                   iconSize: 18.h, | ||||
|                 ).paddingSymmetrical(24.h, 24.h), | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Future<bool> askVideoCallPermission() async { | ||||
|     Map<Permission, PermissionStatus> statuses = await [ | ||||
|       Permission.camera, | ||||
|       Permission.microphone, | ||||
|     ].request(); | ||||
| 
 | ||||
|     if (statuses[Permission.camera] == PermissionStatus.granted && statuses[Permission.microphone] == PermissionStatus.granted) { | ||||
|       // Camera permission granted | ||||
|       return true; | ||||
|     } else { | ||||
|       return false; | ||||
|     } | ||||
| 
 | ||||
|     // if (!(await Permission.camera.request().isGranted) || !(await Permission.microphone.request().isGranted)) { | ||||
|     //   return false; | ||||
|     // } | ||||
|   } | ||||
| 
 | ||||
|   String getLiveCareType(int callType) { | ||||
|     switch (callType) { | ||||
|       case 1: | ||||
|         return "Video Call".needTranslation; | ||||
|       case 2: | ||||
|         return "Audio Call".needTranslation; | ||||
|       case 3: | ||||
|         return "Phone Call".needTranslation; | ||||
|       default: | ||||
|         return "Video Call".needTranslation; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,510 @@ | ||||
| import 'dart:async'; | ||||
| import 'dart:developer'; | ||||
| import 'dart:io'; | ||||
| 
 | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter/material.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_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/utils/date_util.dart'; | ||||
| import 'package:hmg_patient_app_new/features/book_appointments/book_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/core/utils/size_utils.dart'; | ||||
| import 'package:hmg_patient_app_new/core/utils/utils.dart'; | ||||
| import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart'; | ||||
| import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart'; | ||||
| import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart'; | ||||
| import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/appointments/my_appointments_page.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/insurance/insurance_home_page.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; | ||||
| import 'package:hmg_patient_app_new/services/cache_service.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/in_app_browser/InAppBrowser.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; | ||||
| import 'package:permission_handler/permission_handler.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import 'package:smooth_corner/smooth_corner.dart'; | ||||
| 
 | ||||
| class ImmediateLiveCarePaymentPage extends StatefulWidget { | ||||
|   ImmediateLiveCarePaymentPage({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   State<ImmediateLiveCarePaymentPage> createState() => _ImmediateLiveCarePaymentPageState(); | ||||
| } | ||||
| 
 | ||||
| class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentPage> { | ||||
|   late PayfortViewModel payfortViewModel; | ||||
|   late BookAppointmentsViewModel bookAppointmentsViewModel; | ||||
|   late MyAppointmentsViewModel myAppointmentsViewModel; | ||||
|   late AppState appState; | ||||
| 
 | ||||
|   MyInAppBrowser? browser; | ||||
|   String selectedPaymentMethod = ""; | ||||
| 
 | ||||
|   String transID = ""; | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     scheduleMicrotask(() { | ||||
|       payfortViewModel.initPayfortViewModel(); | ||||
|     }); | ||||
|     super.initState(); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     appState = getIt.get<AppState>(); | ||||
|     myAppointmentsViewModel = Provider.of<MyAppointmentsViewModel>(context); | ||||
|     bookAppointmentsViewModel = Provider.of<BookAppointmentsViewModel>(context, listen: false); | ||||
|     payfortViewModel = Provider.of<PayfortViewModel>(context); | ||||
|     return Scaffold( | ||||
|       backgroundColor: AppColors.bgScaffoldColor, | ||||
|       body: Consumer<MyAppointmentsViewModel>(builder: (context, myAppointmentsVM, child) { | ||||
|         return Column( | ||||
|           children: [ | ||||
|             Expanded( | ||||
|               child: CollapsingListView( | ||||
|                 title: "Appointment Payment".needTranslation, | ||||
|                 child: SingleChildScrollView( | ||||
|                   child: Column( | ||||
|                     crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                     children: [ | ||||
|                       SizedBox(height: 24.h), | ||||
|                       Container( | ||||
|                         decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                           color: AppColors.whiteColor, | ||||
|                           borderRadius: 20.h, | ||||
|                           hasShadow: false, | ||||
|                         ), | ||||
|                         child: Row( | ||||
|                           mainAxisSize: MainAxisSize.max, | ||||
|                           children: [ | ||||
|                             Column( | ||||
|                               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                               children: [ | ||||
|                                 Image.asset(AppAssets.mada, width: 72.h, height: 25.h), | ||||
|                                 SizedBox(height: 16.h), | ||||
|                                 "Mada".needTranslation.toText16(isBold: true), | ||||
|                               ], | ||||
|                             ), | ||||
|                             SizedBox(width: 8.h), | ||||
|                             const Spacer(), | ||||
|                             Transform.flip( | ||||
|                               flipX: appState.isArabic() ? true : false, | ||||
|                               child: Utils.buildSvgWithAssets( | ||||
|                                 icon: AppAssets.forward_arrow_icon, | ||||
|                                 iconColor: AppColors.blackColor, | ||||
|                                 width: 18.h, | ||||
|                                 height: 13.h, | ||||
|                                 fit: BoxFit.contain, | ||||
|                               ), | ||||
|                             ), | ||||
|                           ], | ||||
|                         ).paddingSymmetrical(16.h, 16.h), | ||||
|                       ).paddingSymmetrical(24.h, 0.h).onPress(() { | ||||
|                         selectedPaymentMethod = "MADA"; | ||||
|                         openPaymentURL("mada"); | ||||
|                       }), | ||||
|                       SizedBox(height: 16.h), | ||||
|                       Container( | ||||
|                         decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                           color: AppColors.whiteColor, | ||||
|                           borderRadius: 20.h, | ||||
|                           hasShadow: false, | ||||
|                         ), | ||||
|                         child: Row( | ||||
|                           mainAxisSize: MainAxisSize.max, | ||||
|                           children: [ | ||||
|                             Column( | ||||
|                               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                               children: [ | ||||
|                                 Row( | ||||
|                                   children: [ | ||||
|                                     Image.asset(AppAssets.visa, width: 50.h, height: 50.h), | ||||
|                                     SizedBox(width: 8.h), | ||||
|                                     Image.asset(AppAssets.Mastercard, width: 40.h, height: 40.h), | ||||
|                                   ], | ||||
|                                 ), | ||||
|                                 SizedBox(height: 16.h), | ||||
|                                 "Visa or Mastercard".needTranslation.toText16(isBold: true), | ||||
|                               ], | ||||
|                             ), | ||||
|                             SizedBox(width: 8.h), | ||||
|                             const Spacer(), | ||||
|                             Transform.flip( | ||||
|                               flipX: appState.isArabic() ? true : false, | ||||
|                               child: Utils.buildSvgWithAssets( | ||||
|                                 icon: AppAssets.forward_arrow_icon, | ||||
|                                 iconColor: AppColors.blackColor, | ||||
|                                 width: 18.h, | ||||
|                                 height: 13.h, | ||||
|                                 fit: BoxFit.contain, | ||||
|                               ), | ||||
|                             ), | ||||
|                           ], | ||||
|                         ).paddingSymmetrical(16.h, 16.h), | ||||
|                       ).paddingSymmetrical(24.h, 0.h).onPress(() { | ||||
|                         selectedPaymentMethod = "VISA"; | ||||
|                         openPaymentURL("visa"); | ||||
|                       }), | ||||
|                       SizedBox(height: 16.h), | ||||
|                       Container( | ||||
|                         decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                           color: AppColors.whiteColor, | ||||
|                           borderRadius: 20.h, | ||||
|                           hasShadow: false, | ||||
|                         ), | ||||
|                         child: Row( | ||||
|                           mainAxisSize: MainAxisSize.max, | ||||
|                           children: [ | ||||
|                             Column( | ||||
|                               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                               children: [ | ||||
|                                 Image.asset(AppAssets.tamara_en, width: 72.h, height: 25.h), | ||||
|                                 SizedBox(height: 16.h), | ||||
|                                 "Tamara".needTranslation.toText16(isBold: true), | ||||
|                               ], | ||||
|                             ), | ||||
|                             SizedBox(width: 8.h), | ||||
|                             const Spacer(), | ||||
|                             Transform.flip( | ||||
|                               flipX: appState.isArabic() ? true : false, | ||||
|                               child: Utils.buildSvgWithAssets( | ||||
|                                 icon: AppAssets.forward_arrow_icon, | ||||
|                                 iconColor: AppColors.blackColor, | ||||
|                                 width: 18.h, | ||||
|                                 height: 13.h, | ||||
|                                 fit: BoxFit.contain, | ||||
|                               ), | ||||
|                             ), | ||||
|                           ], | ||||
|                         ).paddingSymmetrical(16.h, 16.h), | ||||
|                       ).paddingSymmetrical(24.h, 0.h).onPress(() { | ||||
|                         selectedPaymentMethod = "TAMARA"; | ||||
|                         openPaymentURL("tamara"); | ||||
|                       }), | ||||
|                     ], | ||||
|                   ), | ||||
|                 ), | ||||
|               ), | ||||
|             ), | ||||
|             Container( | ||||
|               decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                 color: AppColors.whiteColor, | ||||
|                 borderRadius: 24.h, | ||||
|                 hasShadow: false, | ||||
|               ), | ||||
|               child: Consumer<PayfortViewModel>(builder: (context, payfortVM, child) { | ||||
|                 //TODO: Need to add loading state & animation for Apple Pay Configuration | ||||
|                 return Column( | ||||
|                   crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                   children: [ | ||||
|                     (bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.isCash ?? true) | ||||
|                         ? Container( | ||||
|                             height: 50.h, | ||||
|                             decoration: ShapeDecoration( | ||||
|                               color: AppColors.secondaryLightRedBorderColor, | ||||
|                               shape: SmoothRectangleBorder( | ||||
|                                 borderRadius: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)), | ||||
|                                 smoothness: 1, | ||||
|                               ), | ||||
|                             ), | ||||
|                             child: Row( | ||||
|                               mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                               children: [ | ||||
|                                 "Insurance expired or inactive".needTranslation.toText14(color: AppColors.primaryRedColor, weight: FontWeight.w500).paddingSymmetrical(24.h, 0.h), | ||||
|                                 CustomButton( | ||||
|                                   text: LocaleKeys.updateInsurance.tr(context: context), | ||||
|                                   onPressed: () { | ||||
|                                     Navigator.of(context).push( | ||||
|                                       CustomPageRoute( | ||||
|                                         page: InsuranceHomePage(), | ||||
|                                       ), | ||||
|                                     ); | ||||
|                                   }, | ||||
|                                   backgroundColor: AppColors.primaryRedColor, | ||||
|                                   borderColor: AppColors.secondaryLightRedBorderColor, | ||||
|                                   textColor: AppColors.whiteColor, | ||||
|                                   fontSize: 10, | ||||
|                                   fontWeight: FontWeight.w500, | ||||
|                                   borderRadius: 8, | ||||
|                                   padding: EdgeInsets.fromLTRB(15, 0, 15, 0), | ||||
|                                   height: 30.h, | ||||
|                                 ).paddingSymmetrical(24.h, 0.h), | ||||
|                               ], | ||||
|                             ), | ||||
|                           ) | ||||
|                         : const SizedBox(), | ||||
|                     SizedBox(height: 24.h), | ||||
|                     "Total amount to pay".needTranslation.toText18(isBold: true).paddingSymmetrical(24.h, 0.h), | ||||
|                     SizedBox(height: 17.h), | ||||
|                     Row( | ||||
|                       mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                       children: [ | ||||
|                         "Amount before tax".needTranslation.toText14(isBold: true), | ||||
|                         Utils.getPaymentAmountWithSymbol(bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.amount!.toString().toText16(isBold: true), AppColors.blackColor, 13, | ||||
|                             isSaudiCurrency: true), | ||||
|                       ], | ||||
|                     ).paddingSymmetrical(24.h, 0.h), | ||||
|                     Row( | ||||
|                       mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                       children: [ | ||||
|                         "VAT 15%".needTranslation.toText14(isBold: true, color: AppColors.greyTextColor), | ||||
|                         Utils.getPaymentAmountWithSymbol( | ||||
|                             bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.tax!.toString().toText14(isBold: true, color: AppColors.greyTextColor), AppColors.greyTextColor, 13, | ||||
|                             isSaudiCurrency: true), | ||||
|                       ], | ||||
|                     ).paddingSymmetrical(24.h, 0.h), | ||||
|                     SizedBox(height: 17.h), | ||||
|                     Row( | ||||
|                       mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                       children: [ | ||||
|                         "".needTranslation.toText14(isBold: true), | ||||
|                         Utils.getPaymentAmountWithSymbol(bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.total!.toString().toText24(isBold: true), AppColors.blackColor, 17, | ||||
|                             isSaudiCurrency: true), | ||||
|                       ], | ||||
|                     ).paddingSymmetrical(24.h, 0.h), | ||||
|                     Platform.isIOS | ||||
|                         ? Utils.buildSvgWithAssets( | ||||
|                             icon: AppAssets.apple_pay_button, | ||||
|                             width: 200.h, | ||||
|                             height: 80.h, | ||||
|                             fit: BoxFit.contain, | ||||
|                           ).paddingSymmetrical(24.h, 0.h).onPress(() { | ||||
|                             // payfortVM.setIsApplePayConfigurationLoading(true); | ||||
|                             if (Utils.havePrivilege(103)) { | ||||
|                               startApplePay(); | ||||
|                             } else { | ||||
|                               openPaymentURL("ApplePay"); | ||||
|                             } | ||||
|                           }) | ||||
|                         : SizedBox(height: 12.h), | ||||
|                     SizedBox(height: 12.h), | ||||
|                   ], | ||||
|                 ); | ||||
|               }), | ||||
|             ), | ||||
|           ], | ||||
|         ); | ||||
|       }), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   onBrowserLoadStart(String url) { | ||||
|     print("onBrowserLoadStart"); | ||||
|     print(url); | ||||
| 
 | ||||
|     if (selectedPaymentMethod == "tamara") { | ||||
|       if (Platform.isAndroid) { | ||||
|         Uri uri = new Uri.dataFromString(url); | ||||
|         // tamaraPaymentStatus = uri.queryParameters['status']!; | ||||
|         // tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!; | ||||
|       } else { | ||||
|         Uri uri = new Uri.dataFromString(url); | ||||
|         // tamaraPaymentStatus = uri.queryParameters['paymentStatus']!; | ||||
|         // tamaraOrderID = uri.queryParameters['orderId']!; | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     // if(selectedPaymentMethod != "TAMARA") { | ||||
|     MyInAppBrowser.successURLS.forEach((element) { | ||||
|       if (url.contains(element)) { | ||||
|         browser?.close(); | ||||
|         MyInAppBrowser.isPaymentDone = true; | ||||
|         return; | ||||
|       } | ||||
|     }); | ||||
|     // } | ||||
| 
 | ||||
|     // if(selectedPaymentMethod != "TAMARA") { | ||||
|     MyInAppBrowser.errorURLS.forEach((element) { | ||||
|       if (url.contains(element)) { | ||||
|         browser?.close(); | ||||
|         MyInAppBrowser.isPaymentDone = false; | ||||
|         return; | ||||
|       } | ||||
|     }); | ||||
|     // } | ||||
|   } | ||||
| 
 | ||||
|   onBrowserExit(bool isPaymentMade) async { | ||||
|     print("onBrowserExit Called!!!!"); | ||||
|     if (selectedPaymentMethod == "TAMARA") { | ||||
|       // checkTamaraPaymentStatus(transID!, appo); | ||||
|       // if (tamaraPaymentStatus != null && tamaraPaymentStatus.toLowerCase() == "approved") { | ||||
|       //   updateTamaraRequestStatus("success", "14", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo); | ||||
|       // } else { | ||||
|       //   updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo); | ||||
|       // } | ||||
|     } else { | ||||
|       checkPaymentStatus(); | ||||
|       // checkPaymentStatus(appo); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   void checkPaymentStatus() async { | ||||
|     LoaderBottomSheet.showLoader(loadingText: "Checking payment status, Please wait...".needTranslation); | ||||
|     await payfortViewModel.checkPaymentStatus( | ||||
|         transactionID: transID, | ||||
|         onSuccess: (apiResponse) async { | ||||
|           debugPrint(apiResponse.data.toString()); | ||||
|           if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") { | ||||
|             await bookAppointmentsViewModel.addNewCallRequestForImmediateLiveCare(transID); | ||||
|             LoaderBottomSheet.hideLoader(); | ||||
| 
 | ||||
|             // showCommonBottomSheetWithoutHeight( | ||||
|             //   context, | ||||
|             //   child: Utils.getSuccessWidget(loadingText: "Payment Successful!".needTranslation), | ||||
|             //   callBackFunc: () { | ||||
|             //     Navigator.of(context).pop(); | ||||
|             //     Navigator.of(context).pop(); | ||||
|             //   }, | ||||
|             //   isFullScreen: false, | ||||
|             //   isCloseButtonVisible: true, | ||||
|             // ); | ||||
|           } else { | ||||
|             showCommonBottomSheetWithoutHeight( | ||||
|               context, | ||||
|               child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation), | ||||
|               callBackFunc: () {}, | ||||
|               isFullScreen: false, | ||||
|               isCloseButtonVisible: true, | ||||
|             ); | ||||
|           } | ||||
|         }); | ||||
|   } | ||||
| 
 | ||||
|   openPaymentURL(String paymentMethod) { | ||||
|     browser = MyInAppBrowser(onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart, context: context); | ||||
|     transID = Utils.getAppointmentTransID( | ||||
|       bookAppointmentsViewModel.immediateLiveCareSelectedClinic.serviceID!, | ||||
|       ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12, | ||||
|       DateTime.now().millisecondsSinceEpoch, | ||||
|     ); | ||||
| 
 | ||||
|     //TODO: Need to pass dynamic params to the payment request instead of static values | ||||
|     browser?.openPaymentBrowser( | ||||
|         myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!, | ||||
|         "LiveCare Payment", | ||||
|         transID, | ||||
|         "12", | ||||
|         "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com", | ||||
|         selectedPaymentMethod, | ||||
|         appState.getAuthenticatedUser()!.patientType.toString(), | ||||
|         "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", | ||||
|         appState.getAuthenticatedUser()!.patientId.toString(), | ||||
|         appState.getAuthenticatedUser()!, | ||||
|         browser!, | ||||
|         false, | ||||
|         "4", | ||||
|         bookAppointmentsViewModel.immediateLiveCareSelectedClinic.serviceID.toString(), | ||||
|         context, | ||||
|         myAppointmentsViewModel.patientAppointmentShareResponseModel!.appointmentDate, | ||||
|         myAppointmentsViewModel.patientAppointmentShareResponseModel!.appointmentNo, | ||||
|         myAppointmentsViewModel.patientAppointmentShareResponseModel!.clinicID, | ||||
|         myAppointmentsViewModel.patientAppointmentShareResponseModel!.doctorID, | ||||
|         "3"); | ||||
|   } | ||||
| 
 | ||||
|   startApplePay() async { | ||||
|     LoaderBottomSheet.showLoader(loadingText: "Fetching Apple Pay details, Please wait...".needTranslation); | ||||
|     transID = Utils.getAppointmentTransID( | ||||
|       bookAppointmentsViewModel.immediateLiveCareSelectedClinic.serviceID!, | ||||
|       ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12, | ||||
|       DateTime.now().millisecondsSinceEpoch, | ||||
|     ); | ||||
| 
 | ||||
|     ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest(); | ||||
| 
 | ||||
|     await payfortViewModel.getPayfortConfigurations( | ||||
|         serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), projectId: ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12, integrationId: 2); | ||||
| 
 | ||||
|     applePayInsertRequest.clientRequestID = transID; | ||||
|     applePayInsertRequest.clinicID = bookAppointmentsViewModel.immediateLiveCareSelectedClinic.serviceID!; | ||||
| 
 | ||||
|     applePayInsertRequest.currency = appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED"; | ||||
|     applePayInsertRequest.customerEmail = "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com"; | ||||
|     applePayInsertRequest.customerID = appState.getAuthenticatedUser()!.patientId.toString(); | ||||
|     applePayInsertRequest.customerName = "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}"; | ||||
| 
 | ||||
|     applePayInsertRequest.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken); | ||||
|     applePayInsertRequest.voipToken = await Utils.getStringFromPrefs(CacheConst.voipToken); | ||||
|     applePayInsertRequest.doctorID = 0; | ||||
|     applePayInsertRequest.projectID = "12"; | ||||
|     applePayInsertRequest.serviceID = ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(); | ||||
|     applePayInsertRequest.channelID = 3; | ||||
|     applePayInsertRequest.patientID = appState.getAuthenticatedUser()!.patientId.toString(); | ||||
|     applePayInsertRequest.patientTypeID = appState.getAuthenticatedUser()!.patientType; | ||||
|     applePayInsertRequest.patientOutSA = appState.getAuthenticatedUser()!.outSa; | ||||
|     applePayInsertRequest.appointmentDate = DateUtil.convertDateToString(DateTime.now()); | ||||
|     applePayInsertRequest.appointmentNo = 0; | ||||
|     applePayInsertRequest.orderDescription = "LiveCare Payment"; | ||||
|     applePayInsertRequest.liveServiceID = bookAppointmentsViewModel.immediateLiveCareSelectedClinic.serviceID!.toString(); | ||||
|     applePayInsertRequest.latitude = "0.0"; | ||||
|     applePayInsertRequest.longitude = "0.0"; | ||||
|     applePayInsertRequest.amount = bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.total.toString(); | ||||
|     applePayInsertRequest.isSchedule = "0"; | ||||
|     applePayInsertRequest.language = appState.isArabic() ? 'ar' : 'en'; | ||||
|     applePayInsertRequest.languageID = appState.isArabic() ? 1 : 2; | ||||
|     applePayInsertRequest.userName = appState.getAuthenticatedUser()!.patientId; | ||||
|     applePayInsertRequest.responseContinueURL = "http://hmg.com/Documents/success.html"; | ||||
|     applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html"; | ||||
|     applePayInsertRequest.paymentOption = "ApplePay"; | ||||
| 
 | ||||
|     applePayInsertRequest.isMobSDK = true; | ||||
|     applePayInsertRequest.merchantReference = transID; | ||||
|     applePayInsertRequest.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.returnURL = ""; | ||||
| 
 | ||||
|     //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: "LiveCare Payment", | ||||
|         orderAmount: double.parse(bookAppointmentsViewModel.liveCareImmediateAppointmentFeesList.total!), | ||||
|         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()}"); | ||||
|           LoaderBottomSheet.hideLoader(); | ||||
|           showCommonBottomSheetWithoutHeight( | ||||
|             context, | ||||
|             child: Utils.getErrorWidget(loadingText: failureResult.message.toString()), | ||||
|             callBackFunc: () {}, | ||||
|             isFullScreen: false, | ||||
|             isCloseButtonVisible: true, | ||||
|           ); | ||||
|         }, | ||||
|         onSucceeded: (successResult) async { | ||||
|           LoaderBottomSheet.hideLoader(); | ||||
|           log("successResult: ${successResult.responseMessage.toString()}"); | ||||
|           selectedPaymentMethod = successResult.paymentOption ?? "VISA"; | ||||
|           checkPaymentStatus(); | ||||
|         }, | ||||
|         // projectId: appo.projectID, | ||||
|         // serviceTypeEnum: ServiceTypeEnum.appointmentPayment, | ||||
|       ); | ||||
|     }); | ||||
|   } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue