Merge pull request 'haroon_dev' (#379) from haroon_dev into master

Reviewed-on: https://34.17.182.140/Haroon6138/HMG_Patient_App_New/pulls/379
pull/381/head
Haroon6138 1 month ago
commit 1c30e634aa

@ -210,8 +210,8 @@ class ApiClientImp implements ApiClient {
body['TokenID'] = "@dm!n"; body['TokenID'] = "@dm!n";
} }
// body['TokenID'] = "@dm!n"; body['TokenID'] = "@dm!n";
// body['PatientID'] = 5422188; // body['PatientID'] = 7000792;
// body['PatientID'] = 53320; // body['PatientID'] = 53320;
// body['PatientTypeID'] = 1; // body['PatientTypeID'] = 1;
// body['PatientOutSA'] = 0; // body['PatientOutSA'] = 0;

@ -1,11 +1,12 @@
import 'package:amazon_payfort/amazon_payfort.dart'; import 'package:amazon_payfort/amazon_payfort.dart';
import 'package:flutter_amazonpaymentservices/environment_type.dart'; import 'package:flutter_amazonpaymentservices/environment_type.dart';
import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:myfatoorah_flutter/myfatoorah_flutter.dart';
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; 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 // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT
@ -44,12 +45,17 @@ class ApiConsts {
// var payFortEnvironment = FortEnvironment.test; // var payFortEnvironment = FortEnvironment.test;
// var applePayMerchantId = "merchant.com.hmgwebservices.uat"; // var applePayMerchantId = "merchant.com.hmgwebservices.uat";
static var myFatoorahEnvironmentType = MFEnvironment.TEST;
static var myFatoorahCountry = MFCountry.SAUDIARABIA;
static setBackendURLs() { static setBackendURLs() {
switch (appEnvironmentType) { switch (appEnvironmentType) {
case AppEnvironmentTypeEnum.prod: case AppEnvironmentTypeEnum.prod:
baseUrl = "https://hmgwebservices.com/"; baseUrl = "https://hmgwebservices.com/";
payFortEnvironment = FortEnvironment.production; payFortEnvironment = FortEnvironment.production;
payFortEnvironmentType = EnvironmentType.production; payFortEnvironmentType = EnvironmentType.production;
myFatoorahEnvironmentType = MFEnvironment.LIVE;
myFatoorahCountry = MFCountry.SAUDIARABIA;
applePayMerchantId = "merchant.com.hmgwebservices"; applePayMerchantId = "merchant.com.hmgwebservices";
SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx"; SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx";
TAMARA_URL = "https://mdlaboratories.com/tamaralive/Home/Checkout"; TAMARA_URL = "https://mdlaboratories.com/tamaralive/Home/Checkout";
@ -66,6 +72,8 @@ class ApiConsts {
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
payFortEnvironment = FortEnvironment.test; payFortEnvironment = FortEnvironment.test;
payFortEnvironmentType = EnvironmentType.sandbox; payFortEnvironmentType = EnvironmentType.sandbox;
myFatoorahEnvironmentType = MFEnvironment.TEST;
myFatoorahCountry = MFCountry.KUWAIT;
applePayMerchantId = "merchant.com.hmgwebservices.uat"; applePayMerchantId = "merchant.com.hmgwebservices.uat";
SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
@ -77,12 +85,13 @@ class ApiConsts {
symptomsCheckerApi = symptomsCheckerApiUAT; symptomsCheckerApi = symptomsCheckerApiUAT;
symptomsCheckerUsername = 'guest_user'; symptomsCheckerUsername = 'guest_user';
symptomsCheckerPassword = '123456'; symptomsCheckerPassword = '123456';
break; break;
case AppEnvironmentTypeEnum.uat: case AppEnvironmentTypeEnum.uat:
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
payFortEnvironment = FortEnvironment.test; payFortEnvironment = FortEnvironment.test;
payFortEnvironmentType = EnvironmentType.sandbox; payFortEnvironmentType = EnvironmentType.sandbox;
myFatoorahEnvironmentType = MFEnvironment.TEST;
myFatoorahCountry = MFCountry.KUWAIT;
applePayMerchantId = "merchant.com.hmgwebservices.uat"; applePayMerchantId = "merchant.com.hmgwebservices.uat";
SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
@ -100,6 +109,8 @@ class ApiConsts {
baseUrl = "https://webservices.hmg.com/"; baseUrl = "https://webservices.hmg.com/";
payFortEnvironment = FortEnvironment.production; payFortEnvironment = FortEnvironment.production;
payFortEnvironmentType = EnvironmentType.production; payFortEnvironmentType = EnvironmentType.production;
myFatoorahEnvironmentType = MFEnvironment.LIVE;
myFatoorahCountry = MFCountry.SAUDIARABIA;
applePayMerchantId = "merchant.com.hmgwebservices"; applePayMerchantId = "merchant.com.hmgwebservices";
SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx"; SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx";
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
@ -117,6 +128,8 @@ class ApiConsts {
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
payFortEnvironment = FortEnvironment.test; payFortEnvironment = FortEnvironment.test;
payFortEnvironmentType = EnvironmentType.sandbox; payFortEnvironmentType = EnvironmentType.sandbox;
myFatoorahEnvironmentType = MFEnvironment.TEST;
myFatoorahCountry = MFCountry.KUWAIT;
applePayMerchantId = "merchant.com.hmgwebservices.uat"; applePayMerchantId = "merchant.com.hmgwebservices.uat";
SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
@ -134,6 +147,8 @@ class ApiConsts {
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
payFortEnvironment = FortEnvironment.test; payFortEnvironment = FortEnvironment.test;
payFortEnvironmentType = EnvironmentType.sandbox; payFortEnvironmentType = EnvironmentType.sandbox;
myFatoorahEnvironmentType = MFEnvironment.TEST;
myFatoorahCountry = MFCountry.KUWAIT;
applePayMerchantId = "merchant.com.hmgwebservices.uat"; applePayMerchantId = "merchant.com.hmgwebservices.uat";
SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://uat.hmgwebservices.com/HMGPayment/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";

@ -48,12 +48,19 @@ class AppState {
bool isPaytabsEnabled = false; bool isPaytabsEnabled = false;
bool isPayfortHostedPageEnabled = true; bool isPayfortHostedPageEnabled = true;
bool isMyFatoorahEnabled = false;
// bool isMyFatoorahEnabled = true;
void setIsPaytabsEnabled(bool value) { void setIsPaytabsEnabled(bool value) {
isPaytabsEnabled = value; isPaytabsEnabled = value;
// isPaytabsEnabled = true; // isPaytabsEnabled = true;
} }
void setIsMyFatoorahEnabled(bool value) {
// isMyFatoorahEnabled = value;
isMyFatoorahEnabled = true;
}
void setIsPayfortHostedPageEnabled(bool value) { void setIsPayfortHostedPageEnabled(bool value) {
isPayfortHostedPageEnabled = value; isPayfortHostedPageEnabled = value;
// isPayfortHostedPageEnabled = false; // isPayfortHostedPageEnabled = false;

@ -44,6 +44,7 @@ import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_rep
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_repo.dart'; import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_repo.dart';
import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_view_model.dart'; import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_view_model.dart';
import 'package:hmg_patient_app_new/features/myfatoorah/myfatoorah_view_model.dart';
import 'package:hmg_patient_app_new/features/notifications/notifications_repo.dart'; import 'package:hmg_patient_app_new/features/notifications/notifications_repo.dart';
import 'package:hmg_patient_app_new/features/notifications/notifications_view_model.dart'; import 'package:hmg_patient_app_new/features/notifications/notifications_view_model.dart';
import 'package:hmg_patient_app_new/features/offers_and_discounts/offers_and_discounts_repo.dart'; import 'package:hmg_patient_app_new/features/offers_and_discounts/offers_and_discounts_repo.dart';
@ -380,6 +381,12 @@ class AppDependencies {
errorHandlerService: getIt(), errorHandlerService: getIt(),
)); ));
getIt.registerLazySingleton<MyFatoorahViewModel>(() => MyFatoorahViewModel(
appState: getIt(),
errorHandlerService: getIt(),
payfortRepo: getIt(),
));
getIt.registerLazySingleton<ClarityService>( getIt.registerLazySingleton<ClarityService>(
() => ClarityService(appState: getIt.get<AppState>()), () => ClarityService(appState: getIt.get<AppState>()),
); );

@ -0,0 +1,5 @@
class MyFatoorahConfig {
static const String configAPIKey = "SK_KWT_0auB76h3Frhj7aUBSZa6H5ei792eZoGAPh0bBxKsrgtyjqKgf38MPnZqzGqagErb";
}

@ -1248,6 +1248,7 @@ class AuthenticationViewModel extends ChangeNotifier {
_appState.setUserBloodGroup = activation.patientBlodType ?? "N/A"; _appState.setUserBloodGroup = activation.patientBlodType ?? "N/A";
_appState.setIsPaytabsEnabled(Utils.havePrivilege(120)); _appState.setIsPaytabsEnabled(Utils.havePrivilege(120));
_appState.setIsPayfortHostedPageEnabled(Utils.havePrivilege(121)); _appState.setIsPayfortHostedPageEnabled(Utils.havePrivilege(121));
_appState.setIsMyFatoorahEnabled(Utils.havePrivilege(123));
// Refresh privileges after user switching to ensure correct privileges are loaded // Refresh privileges after user switching to ensure correct privileges are loaded
if (isSwitchUser) { if (isSwitchUser) {
@ -1796,6 +1797,7 @@ class AuthenticationViewModel extends ChangeNotifier {
_appState.setProjectsDetailList(projectDetailListModel); _appState.setProjectsDetailList(projectDetailListModel);
_appState.setIsPaytabsEnabled(Utils.havePrivilege(120)); _appState.setIsPaytabsEnabled(Utils.havePrivilege(120));
_appState.setIsPayfortHostedPageEnabled(Utils.havePrivilege(121)); _appState.setIsPayfortHostedPageEnabled(Utils.havePrivilege(121));
_appState.setIsMyFatoorahEnabled(Utils.havePrivilege(123));
} }
}, },
); );

@ -209,12 +209,12 @@ class LabViewModel extends ChangeNotifier {
final result = await labRepo.getLabResultReportPDF(labOrder: labOrder); final result = await labRepo.getLabResultReportPDF(labOrder: labOrder);
result.fold( result.fold(
(failure) async => await errorHandlerService.handleError( // (failure) async => await errorHandlerService.handleError(
failure: failure, (failure) async {
onOkPressed: () { if (onError != null) {
onError!(failure.message); onError(failure.message);
}, }
), },
(apiResponse) { (apiResponse) {
if (apiResponse.messageStatus == 2) { if (apiResponse.messageStatus == 2) {
onError!(apiResponse.errorMessage!); onError!(apiResponse.errorMessage!);

@ -772,9 +772,9 @@ class MyAppointmentsViewModel extends ChangeNotifier {
patientMyDoctorsList = apiResponse.data!; patientMyDoctorsList = apiResponse.data!;
isPatientMyDoctorsLoading = false; isPatientMyDoctorsLoading = false;
if (!isTop8) { // if (!isTop8) {
isMyDoctorsDataToBeLoaded = false; isMyDoctorsDataToBeLoaded = false;
} // }
notifyListeners(); notifyListeners();
if (onSuccess != null) { if (onSuccess != null) {

@ -0,0 +1,197 @@
import 'dart:developer';
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_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/myFatoorah_config.dart';
import 'package:hmg_patient_app_new/core/utils/utils.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/generated/codegen_loader.g.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
import 'package:myfatoorah_flutter/myfatoorah_flutter.dart';
class MyFatoorahViewModel extends ChangeNotifier {
final AppState appState;
final ErrorHandlerService errorHandlerService;
final PayfortRepo payfortRepo;
MyFatoorahViewModel({
required this.appState,
required this.errorHandlerService,
required this.payfortRepo,
});
// Payment Method ID
// 2: Credit/Debit Card
// 6: Mada
initiateCardPayment({
num amount = 10.0,
paymentDescription = "",
String displayCurrencyIso = MFCurrencyISO.KUWAIT_KWD,
required String paymentOption,
required String liveServiceID,
required String isScheduleLiveCare,
required String appointmentDate,
required String appointmentNo,
required String doctorID,
required String fileNumber,
required String serviceID,
required String projectID,
Function(MFGetPaymentStatusResponse)? onSuccess,
Function(String)? onError,
}) async {
LoaderBottomSheet.showLoader();
await MFSDK.init(MyFatoorahConfig.configAPIKey, ApiConsts.myFatoorahCountry, ApiConsts.myFatoorahEnvironmentType);
MFSDK.setUpActionBar(toolBarTitle: paymentDescription, toolBarTitleColor: "#ffffff", toolBarBackgroundColor: '#ED1C2B', isShowToolBar: true);
var request = MFExecutePaymentRequest(paymentMethodId: paymentOption.toLowerCase() == "mada" ? 6 : 2, invoiceValue: amount);
request.displayCurrencyIso = displayCurrencyIso;
request.customerName = ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? "Test test" : "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}";
request.customerEmail = "CustID_${appState.getAuthenticatedUser()!.patientId}@HMG.com";
await MFSDK.executePayment(request, appState.isArabic() ? MFLanguage.ARABIC : MFLanguage.ENGLISH, (invoiceId) async {
PayfortRequestInsertModel payfortRequestInsertModel = PayfortRequestInsertModel();
payfortRequestInsertModel.commandType = "SALE";
payfortRequestInsertModel.amount = amount;
payfortRequestInsertModel.customerEmail = getIt.get<AppState>().getAuthenticatedUser()!.emailAddress;
payfortRequestInsertModel.orderDescription = paymentDescription;
payfortRequestInsertModel.serviceID = serviceID;
payfortRequestInsertModel.paymentOption = paymentOption;
payfortRequestInsertModel.clientRequestID = invoiceId;
payfortRequestInsertModel.projectID = projectID;
payfortRequestInsertModel.fileNumber = getIt.get<AppState>().getAuthenticatedUser()!.patientId.toString();
payfortRequestInsertModel.customerName = "${getIt.get<AppState>().getAuthenticatedUser()!.firstName} ${getIt.get<AppState>().getAuthenticatedUser()!.lastName}";
payfortRequestInsertModel.currency = getIt.get<AppState>().getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED";
payfortRequestInsertModel.liveServiceID = liveServiceID;
payfortRequestInsertModel.latitude = getIt.get<AppState>().userLat.toString();
payfortRequestInsertModel.longitude = getIt.get<AppState>().userLong.toString();
payfortRequestInsertModel.merchantReference = invoiceId;
payfortRequestInsertModel.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken);
payfortRequestInsertModel.language = getIt.get<AppState>().isArabic() ? "ar" : "en";
payfortRequestInsertModel.integrationId = "6"; // 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();
}).then((value) async {
var valJson = value.toString();
print(valJson);
// // Create PayfortResponseInsertModel (same as Payfort implementation)
PayfortResponseInsertModel payfortResponseInsertModel = PayfortResponseInsertModel();
payfortResponseInsertModel.fortId = value.invoiceTransactions!.first.transactionId ?? "";
payfortResponseInsertModel.commandType = "SALE";
// payfortResponseInsertModel.amount = paytabsTransactionResponseModel.tranTotal ?? 0;
payfortResponseInsertModel.amount = amount;
payfortResponseInsertModel.sadadOLP = "";
payfortResponseInsertModel.paymentOption = value.invoiceTransactions!.first.paymentGateway ?? "";
payfortResponseInsertModel.customerIP = "";
payfortResponseInsertModel.eCI = "";
payfortResponseInsertModel.responseMessage = value.invoiceTransactions!.first.transactionStatus ?? "";
payfortResponseInsertModel.cardNumber = value.invoiceTransactions!.first.cardNumber ?? "";
payfortResponseInsertModel.cardBin = "";
payfortResponseInsertModel.installmentsNumber = 0;
payfortResponseInsertModel.status = (value.invoiceStatus ?? "").toLowerCase() == "paid" ? "14" : "00";
payfortResponseInsertModel.merchantRef = value.invoiceId.toString();
payfortResponseInsertModel.isRefund = false;
payfortResponseInsertModel.remmeberMe = true;
payfortResponseInsertModel.reconciliationReference = "";
// Call response insert API after payment
await paytabsResponseInsert(payfortResponseInsertModel: payfortResponseInsertModel);
if ((value.invoiceStatus ?? "").toLowerCase() == "paid") {
if (onSuccess != null) {
onSuccess(value);
}
} else {
if (onError != null) {
onError(LocaleKeys.paymentFailedPleaseTryAgain.tr());
}
}
}).catchError((error) {
if (onError != null) {
onError(error.message);
}
});
}
executeApplePayPayment() {
MFApplepay.executeApplePayPayment(onInvoiceCreated: (invoiceID) {
log(
invoiceID.toString(),
);
}).then((value) {
log(
value.toString(),
);
}).catchError((error) {
log(error.message);
});
}
initApplePayPayment(num invoiceValue) async {
await MFSDK.init(MyFatoorahConfig.configAPIKey, ApiConsts.myFatoorahCountry, ApiConsts.myFatoorahEnvironmentType);
await MFSDK.initSession(MFInitiateSessionRequest(), MFLanguage.ENGLISH).then((value) async {
var executePaymentRequest = MFExecutePaymentRequest(invoiceValue: invoiceValue, sessionId: value.sessionId, displayCurrencyIso: MFCurrencyISO.SAUDIARABIA_SAR);
MFApplepay.setupApplePay(value, executePaymentRequest, MFLanguage.ENGLISH, merchantName: "Dr Sulaiman Al Habib");
}).catchError((error) {
log(error.message);
});
}
Future<void> 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<void> 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);
}
}
},
);
}
}

@ -35,6 +35,7 @@ import 'package:hmg_patient_app_new/features/my_appointments/appointment_rating_
import 'package:hmg_patient_app_new/features/my_appointments/appointment_via_region_viewmodel.dart'; import 'package:hmg_patient_app_new/features/my_appointments/appointment_via_region_viewmodel.dart';
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_view_model.dart'; import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_view_model.dart';
import 'package:hmg_patient_app_new/features/myfatoorah/myfatoorah_view_model.dart';
import 'package:hmg_patient_app_new/features/notifications/notifications_view_model.dart'; import 'package:hmg_patient_app_new/features/notifications/notifications_view_model.dart';
import 'package:hmg_patient_app_new/features/offers_and_discounts/offers_and_discounts_view_model.dart'; import 'package:hmg_patient_app_new/features/offers_and_discounts/offers_and_discounts_view_model.dart';
import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart'; import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart';
@ -303,6 +304,9 @@ void main() async {
ChangeNotifierProvider<PayTabsViewModel>( ChangeNotifierProvider<PayTabsViewModel>(
create: (_) => getIt.get<PayTabsViewModel>(), create: (_) => getIt.get<PayTabsViewModel>(),
), ),
ChangeNotifierProvider<MyFatoorahViewModel>(
create: (_) => getIt.get<MyFatoorahViewModel>(),
),
ChangeNotifierProvider<RefundRequestViewModel>( ChangeNotifierProvider<RefundRequestViewModel>(
create: (_) => getIt.get<RefundRequestViewModel>(), create: (_) => getIt.get<RefundRequestViewModel>(),
) )

@ -11,8 +11,10 @@ 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/cache_consts.dart';
import 'package:hmg_patient_app_new/core/dependencies.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/enums.dart';
import 'package:hmg_patient_app_new/core/myFatoorah_config.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart'; import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/features/immediate_livecare/immediate_livecare_view_model.dart'; import 'package:hmg_patient_app_new/features/immediate_livecare/immediate_livecare_view_model.dart';
import 'package:hmg_patient_app_new/features/myfatoorah/myfatoorah_view_model.dart';
import 'package:hmg_patient_app_new/features/payfort/models/apple_pay_request_insert_model.dart'; import 'package:hmg_patient_app_new/features/payfort/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/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
@ -33,6 +35,8 @@ 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/in_app_browser/InAppBrowser.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.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:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:myfatoorah_flutter/MFEnums.dart';
import 'package:myfatoorah_flutter/myfatoorah_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:smooth_corner/smooth_corner.dart'; import 'package:smooth_corner/smooth_corner.dart';
@ -49,6 +53,9 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
late MyAppointmentsViewModel myAppointmentsViewModel; late MyAppointmentsViewModel myAppointmentsViewModel;
late AppState appState; late AppState appState;
late PayTabsViewModel paytabsViewModel; late PayTabsViewModel paytabsViewModel;
late MyFatoorahViewModel myFatoorahViewModel;
late MFApplePayButton mfApplePayButton;
MyInAppBrowser? browser; MyInAppBrowser? browser;
String selectedPaymentMethod = ""; String selectedPaymentMethod = "";
@ -64,6 +71,11 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
Clarity.setCurrentScreenName('LiveCare Payment Page'); Clarity.setCurrentScreenName('LiveCare Payment Page');
scheduleMicrotask(() { scheduleMicrotask(() {
payfortViewModel.initPayfortViewModel(); payfortViewModel.initPayfortViewModel();
if (appState.isMyFatoorahEnabled) {
myFatoorahViewModel.initApplePayPayment(num.parse((immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0")));
}
myAppointmentsViewModel.getTamaraInstallmentsDetails().then((val) { myAppointmentsViewModel.getTamaraInstallmentsDetails().then((val) {
if (myAppointmentsViewModel.getTamaraInstallmentsDetailsResponseModel != null) { if (myAppointmentsViewModel.getTamaraInstallmentsDetailsResponseModel != null) {
if (num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total!) >= myAppointmentsViewModel.getTamaraInstallmentsDetailsResponseModel!.minLimit!.amount! && if (num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total!) >= myAppointmentsViewModel.getTamaraInstallmentsDetailsResponseModel!.minLimit!.amount! &&
@ -80,11 +92,15 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
mfApplePayButton = MFApplePayButton(
applePayStyle: MFApplePayStyle(),
);
appState = getIt.get<AppState>(); appState = getIt.get<AppState>();
myAppointmentsViewModel = Provider.of<MyAppointmentsViewModel>(context, listen: false); myAppointmentsViewModel = Provider.of<MyAppointmentsViewModel>(context, listen: false);
immediateLiveCareViewModel = Provider.of<ImmediateLiveCareViewModel>(context, listen: false); immediateLiveCareViewModel = Provider.of<ImmediateLiveCareViewModel>(context, listen: false);
payfortViewModel = Provider.of<PayfortViewModel>(context, listen: false); payfortViewModel = Provider.of<PayfortViewModel>(context, listen: false);
paytabsViewModel = Provider.of<PayTabsViewModel>(context, listen: false); paytabsViewModel = Provider.of<PayTabsViewModel>(context, listen: false);
myFatoorahViewModel = Provider.of<MyFatoorahViewModel>(context, listen: false);
return Scaffold( return Scaffold(
backgroundColor: AppColors.bgScaffoldColor, backgroundColor: AppColors.bgScaffoldColor,
body: Consumer<MyAppointmentsViewModel>(builder: (context, myAppointmentsVM, child) { body: Consumer<MyAppointmentsViewModel>(builder: (context, myAppointmentsVM, child) {
@ -131,7 +147,62 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
).paddingSymmetrical(16.h, 16.h), ).paddingSymmetrical(16.h, 16.h),
).paddingSymmetrical(24.h, 0.h).onPress(() async { ).paddingSymmetrical(24.h, 0.h).onPress(() async {
selectedPaymentMethod = "MADA"; selectedPaymentMethod = "MADA";
if (appState.isPaytabsEnabled) { if (appState.isMyFatoorahEnabled) {
myFatoorahViewModel.initiateCardPayment(
amount: num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0"),
paymentDescription: "LiveCare Payment",
displayCurrencyIso: appState.getAuthenticatedUser()!.outSa == 0
? ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat
? MFCurrencyISO.KUWAIT_KWD
: MFCurrencyISO.SAUDIARABIA_SAR
: MFCurrencyISO.UAE_AED,
paymentOption: selectedPaymentMethod,
liveServiceID: immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID.toString(),
isScheduleLiveCare: "false",
appointmentDate: DateUtil.convertDateToString(DateTime.now()),
appointmentNo: "0",
doctorID: "0",
fileNumber: appState.getAuthenticatedUser()!.patientId.toString(),
serviceID: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum().toString(),
projectID: (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12).toString(),
onSuccess: (response) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr());
await immediateLiveCareViewModel.addNewCallRequestForImmediateLiveCare(response.invoiceId.toString());
await immediateLiveCareViewModel.getPatientLiveCareHistory();
LoaderBottomSheet.hideLoader();
if (immediateLiveCareViewModel.patientHasPendingLiveCareRequest) {
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
Navigator.of(context).push(
CustomPageRoute(
page: ImmediateLiveCarePendingRequestPage(),
),
);
} else {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: "Unknown error occurred..."),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
}
},
onError: (errMessage) {
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: errMessage.toString()),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
});
} else if (appState.isPaytabsEnabled) {
transID = Utils.getAppointmentTransID( transID = Utils.getAppointmentTransID(
immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID!, immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID!,
ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12, ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12,
@ -298,7 +369,62 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
).paddingSymmetrical(16.h, 16.h), ).paddingSymmetrical(16.h, 16.h),
).paddingSymmetrical(24.h, 0.h).onPress(() async { ).paddingSymmetrical(24.h, 0.h).onPress(() async {
selectedPaymentMethod = "VISA"; selectedPaymentMethod = "VISA";
if (appState.isPaytabsEnabled) { if (appState.isMyFatoorahEnabled) {
myFatoorahViewModel.initiateCardPayment(
amount: num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0"),
paymentDescription: "LiveCare Payment",
displayCurrencyIso: appState.getAuthenticatedUser()!.outSa == 0
? ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat
? MFCurrencyISO.KUWAIT_KWD
: MFCurrencyISO.SAUDIARABIA_SAR
: MFCurrencyISO.UAE_AED,
paymentOption: selectedPaymentMethod,
liveServiceID: immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID.toString(),
isScheduleLiveCare: "false",
appointmentDate: DateUtil.convertDateToString(DateTime.now()),
appointmentNo: "0",
doctorID: "0",
fileNumber: appState.getAuthenticatedUser()!.patientId.toString(),
serviceID: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum().toString(),
projectID: (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12).toString(),
onSuccess: (response) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr());
await immediateLiveCareViewModel.addNewCallRequestForImmediateLiveCare(response.invoiceId.toString());
await immediateLiveCareViewModel.getPatientLiveCareHistory();
LoaderBottomSheet.hideLoader();
if (immediateLiveCareViewModel.patientHasPendingLiveCareRequest) {
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
Navigator.of(context).push(
CustomPageRoute(
page: ImmediateLiveCarePendingRequestPage(),
),
);
} else {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: "Unknown error occurred..."),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
}
},
onError: (errMessage) {
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: errMessage.toString()),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
});
} else if (appState.isPaytabsEnabled) {
transID = Utils.getAppointmentTransID( transID = Utils.getAppointmentTransID(
immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID!, immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID!,
ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12, ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12,
@ -610,16 +736,31 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
], ],
).paddingSymmetrical(24.h, 0.h), ).paddingSymmetrical(24.h, 0.h),
Platform.isIOS Platform.isIOS
? Utils.buildSvgWithAssets( ?
icon: AppAssets.apple_pay_button, // appState.isMyFatoorahEnabled
width: 200.h, // ? SizedBox(
height: 80.h, // height: 50.h,
fit: BoxFit.contain, // width: double.infinity,
applyThemeColor: false // child: Stack(
).paddingSymmetrical(24.h, 0.h).onPress(() { // children: [
// Positioned.fill(child: mfApplePayButton),
// Positioned.fill(
// child: GestureDetector(
// behavior: HitTestBehavior.opaque,
// onTap: () {},
// ),
// ),
// ],
// ),
// ).paddingSymmetrical(24.h, 16.h)
// :
Utils.buildSvgWithAssets(icon: AppAssets.apple_pay_button, width: 200.h, height: 80.h, fit: BoxFit.contain, applyThemeColor: false)
.paddingSymmetrical(24.h, 0.h)
.onPress(() async {
// payfortVM.setIsApplePayConfigurationLoading(true); // payfortVM.setIsApplePayConfigurationLoading(true);
if (Utils.havePrivilege(103)) { if (Utils.havePrivilege(103)) {
startApplePay(); // startApplePay();
myFatoorahViewModel.executeApplePayPayment();
} else { } else {
openPaymentURL("ApplePay"); openPaymentURL("ApplePay");
} }

@ -219,6 +219,9 @@ class DoctorCard extends StatelessWidget {
); );
} else { } else {
bookAppointmentsViewModel.setSelectedDoctor(doctorsListResponseModel); bookAppointmentsViewModel.setSelectedDoctor(doctorsListResponseModel);
GetClinicsListResponseModel selectedClinic = GetClinicsListResponseModel(
clinicID: doctorsListResponseModel.clinicID, clinicDescription: doctorsListResponseModel.clinicName, isLiveCareClinicAndOnline: false, liveCareServiceID: 0, liveCareClinicID: 0);
bookAppointmentsViewModel.setSelectedClinic(selectedClinic);
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
bookAppointmentsViewModel.isLiveCareSchedule bookAppointmentsViewModel.isLiveCareSchedule
? await bookAppointmentsViewModel.getLiveCareDoctorFreeSlots( ? await bookAppointmentsViewModel.getLiveCareDoctorFreeSlots(

@ -92,7 +92,7 @@ class HabibWalletCard extends StatelessWidget {
), ),
SizedBox(width: 8.h), SizedBox(width: 8.h),
(habibWalletVM.isWalletAmountHidden (habibWalletVM.isWalletAmountHidden
? "••••" ? "****"
: NumberFormat.decimalPattern().format(habibWalletVM.habibWalletAmount).toString()) : NumberFormat.decimalPattern().format(habibWalletVM.habibWalletAmount).toString())
.toText32(isBold: true, isEnglishOnly: true) .toText32(isBold: true, isEnglishOnly: true)
.toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h, width: 80.h, height: 40.h), .toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h, width: 80.h, height: 40.h),

@ -92,7 +92,7 @@ class LakumWalletCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
(habibWalletVM.isLakumPointsHidden (habibWalletVM.isLakumPointsHidden
? "••••" ? "****"
: NumberFormat.decimalPattern() : NumberFormat.decimalPattern()
.format(habibWalletVM.isLakumAccountInfoLoading .format(habibWalletVM.isLakumAccountInfoLoading
? 123 ? 123

@ -2,8 +2,8 @@ name: hmg_patient_app_new
description: "New HMG Patient App" description: "New HMG Patient App"
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.48+49 version: 0.0.49+50
#version: 0.0.16+1 #version: 0.0.17+1
environment: environment:
sdk: ">=3.6.0 <4.0.0" sdk: ">=3.6.0 <4.0.0"
@ -113,6 +113,7 @@ dependencies:
cloudflare_turnstile: ^3.7.2 cloudflare_turnstile: ^3.7.2
freerasp: ^8.2.1 freerasp: ^8.2.1
safe_device: ^1.4.1 safe_device: ^1.4.1
myfatoorah_flutter: ^3.3.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save