Paytabs dynamic keys implemented

pull/364/head
haroon amjad 1 month ago
parent 112c254416
commit f6459142e1

@ -101,9 +101,7 @@ class ImmediateLiveCareRepoImp implements ImmediateLiveCareRepo {
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final respObject = response['GetERAppointmentFeesList'];
final liveCareFeesObj = LiveCareImmediateAppointmentFeesList.fromJson(respObject);
apiResponse = GenericApiModel<LiveCareImmediateAppointmentFeesList>(
messageStatus: messageStatus,
statusCode: statusCode,

@ -58,7 +58,7 @@ class PayfortRepoImp implements PayfortRepo {
try {
final list = response;
if (list == null || list.isEmpty) {
throw Exception("payfort list is empty");
throw Exception("No project configuration found.");
}
final applePayConfigurationResponse = PayfortProjectDetailsRespModel.fromJson(list[0]);

@ -17,6 +17,7 @@ import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/paytabs_config.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/features/payfort/models/payfort_project_details_resp_model.dart';
import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart';
import 'package:hmg_patient_app_new/features/paytabs/models/paytabs_transaction_response_model.dart';
import 'package:hmg_patient_app_new/features/payfort/models/payfort_request_insert_model.dart';
@ -32,19 +33,26 @@ class PayTabsViewModel extends ChangeNotifier {
final ErrorHandlerService errorHandlerService;
late PaytabsTransactionResponseModel paytabsTransactionResponseModel;
PayfortProjectDetailsRespModel? paytabsProjectDetailsRespModel;
PayTabsViewModel({
required this.appState,
required this.payfortRepo,
required this.errorHandlerService,
});
setPaymentConfiguration(String paymentDescription, num amount, {bool isAddCard = false}) {
setPaymentConfiguration(String paymentDescription, num amount, int serviceID, int projectID, {bool isAddCard = false}) async {
String cartID = DateTime.now().millisecondsSinceEpoch.toString();
LoaderBottomSheet.showLoader();
await getPayTabsConfigurations(serviceId: serviceID, projectId: projectID);
paymentConfiguration = PaymentSdkConfigurationDetails(
profileId: PaymentSdkDefaultConfig.profileID,
serverKey: PaymentSdkDefaultConfig.serverKey,
clientKey: PaymentSdkDefaultConfig.clientKey,
transactionType: PaymentSdkTransactionType.SALE,
profileId: paytabsProjectDetailsRespModel!.merchantIdentifier,
serverKey: paytabsProjectDetailsRespModel!.accessCode,
clientKey: paytabsProjectDetailsRespModel!.shaResponse,
transactionType: PaymentSdkTransactionType.SALE,
cartId: cartID.substring((cartID.length - 5), cartID.length),
cartDescription: paymentDescription,
merchantName: PaymentSdkDefaultConfig.defaultMerchantName,
@ -112,12 +120,17 @@ class PayTabsViewModel extends ChangeNotifier {
notifyListeners();
}
setAlternatePaymentConfiguration(String paymentDescription, num amount, {bool isAddCard = false}) {
setAlternatePaymentConfiguration(String paymentDescription, num amount, int serviceID, int projectID, {bool isAddCard = false}) async {
String cartID = DateTime.now().millisecondsSinceEpoch.toString();
LoaderBottomSheet.showLoader();
await getPayTabsConfigurations(serviceId: serviceID, projectId: projectID);
paymentConfiguration = PaymentSdkConfigurationDetails(
profileId: PaymentSdkDefaultConfig.profileID,
serverKey: PaymentSdkDefaultConfig.serverKey,
clientKey: PaymentSdkDefaultConfig.clientKey,
profileId: paytabsProjectDetailsRespModel!.merchantIdentifier,
serverKey: paytabsProjectDetailsRespModel!.accessCode,
clientKey: paytabsProjectDetailsRespModel!.shaResponse,
transactionType: PaymentSdkTransactionType.SALE,
cartId: cartID.substring((cartID.length - 5), cartID.length),
cartDescription: paymentDescription,
@ -260,7 +273,7 @@ class PayTabsViewModel extends ChangeNotifier {
bool _callbackFired = false; // prevent duplicate callback invocations
try {
LoaderBottomSheet.showLoader();
// LoaderBottomSheet.showLoader();
// Create PayfortRequestInsertModel (same as Payfort implementation)
PayfortRequestInsertModel payfortRequestInsertModel = PayfortRequestInsertModel();
@ -382,7 +395,7 @@ class PayTabsViewModel extends ChangeNotifier {
required bool isSchedule,
Function(PaytabsTransactionResponseModel)? onSuccess,
Function(String)? onError}) async {
LoaderBottomSheet.showLoader();
// LoaderBottomSheet.showLoader();
TamaraRequestModel tamaraRequestModel = TamaraRequestModel();
@ -448,4 +461,23 @@ class PayTabsViewModel extends ChangeNotifier {
}
});
}
Future<void> getPayTabsConfigurations({int? serviceId, int? projectId, int integrationId = 5, Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await payfortRepo.getPayfortConfigurations(serviceId: serviceId, projectId: projectId, integrationId: integrationId);
result.fold(
(failure) async => await errorHandlerService.handleError(failure: failure),
(apiResponse) {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
paytabsProjectDetailsRespModel = apiResponse.data!;
notifyListeners();
if (onSuccess != null) {
onSuccess(apiResponse);
}
}
},
);
}
}

@ -150,10 +150,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
widget.patientAppointmentHistoryResponseModel.clinicID,
widget.patientAppointmentHistoryResponseModel.appointmentNo,
);
paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
);
await paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(),
widget.patientAppointmentHistoryResponseModel.projectID);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -179,7 +180,6 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
patientType: appState.getAuthenticatedUser()!.patientType!,
onSuccess: (value) async {
print(value);
await myAppointmentsViewModel.addAdvanceNumberRequest(
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID)
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
@ -263,7 +263,6 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
orderDescription: "Appointment Payment",
amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(),
onSucceeded: (paymentResult) async {
print("Payment Success Data: ${paymentResult.toString()}");
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context));
await myAppointmentsViewModel.createAdvancePayment(
paymentMethodName: selectedPaymentMethod,
@ -275,7 +274,6 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
patientType: appState.getAuthenticatedUser()!.patientType!,
onSuccess: (value) async {
print(value);
await myAppointmentsViewModel.addAdvanceNumberRequest(
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID)
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
@ -391,10 +389,11 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
widget.patientAppointmentHistoryResponseModel.clinicID,
widget.patientAppointmentHistoryResponseModel.appointmentNo,
);
paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
);
await paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(),
widget.patientAppointmentHistoryResponseModel.projectID);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -420,7 +419,6 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
patientType: appState.getAuthenticatedUser()!.patientType!,
onSuccess: (value) async {
print(value);
await myAppointmentsViewModel.addAdvanceNumberRequest(
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID)
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
@ -504,7 +502,6 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(),
orderDescription: "Appointment Payment",
onSucceeded: (paymentResult) async {
print("Payment Success Data: ${paymentResult.toString()}");
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context));
await myAppointmentsViewModel.createAdvancePayment(
paymentMethodName: selectedPaymentMethod,
@ -516,7 +513,6 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
patientType: appState.getAuthenticatedUser()!.patientType!,
onSuccess: (value) async {
print(value);
await myAppointmentsViewModel.addAdvanceNumberRequest(
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID)
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
@ -640,7 +636,10 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
if (appState.isPaytabsEnabled) {
paytabsViewModel.setAlternatePaymentConfiguration(
"Appointment Payment", num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()));
"Appointment Payment",
num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(),
widget.patientAppointmentHistoryResponseModel.projectID);
paytabsViewModel.startAlternatePayment(
liveServiceID: "0",
appointmentDate: widget.patientAppointmentHistoryResponseModel.appointmentDate!,
@ -1121,10 +1120,13 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest();
await payfortViewModel.getPayfortConfigurations(
serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(),
projectId: widget.patientAppointmentHistoryResponseModel.projectID,
integrationId: 2);
if (!appState.isPaytabsEnabled) {
await payfortViewModel.getPayfortConfigurations(
serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), projectId: widget.patientAppointmentHistoryResponseModel.projectID, integrationId: 2);
} else {
await paytabsViewModel.setPaymentConfiguration("Appointment Payment", num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), widget.patientAppointmentHistoryResponseModel.projectID);
}
applePayInsertRequest.clientRequestID = transID;
applePayInsertRequest.clinicID = widget.patientAppointmentHistoryResponseModel.clinicID;
@ -1173,10 +1175,6 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
if (appState.isPaytabsEnabled) {
selectedPaymentMethod = "VISA";
LoaderBottomSheet.hideLoader();
paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
);
paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context));
await myAppointmentsViewModel.createAdvancePayment(

@ -137,10 +137,8 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12,
DateTime.now().millisecondsSinceEpoch,
);
paytabsViewModel.setPaymentConfiguration(
"LiveCare Payment",
num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0"),
);
await paytabsViewModel.setPaymentConfiguration("LiveCare Payment", num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0"),
ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(), (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12));
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID.toString(),
@ -152,7 +150,7 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(),
fileNumber: appState.getAuthenticatedUser()!.patientId.toString(),
orderDescription: "LiveCare Payment",
serviceID: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(),
serviceID: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum().toString(),
projectID: (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12).toString(),
onSuccess: (PaytabsTransactionResponseModel transactionData) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr());
@ -306,10 +304,8 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12,
DateTime.now().millisecondsSinceEpoch,
);
paytabsViewModel.setPaymentConfiguration(
"LiveCare Payment",
num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0"),
);
await paytabsViewModel.setPaymentConfiguration("LiveCare Payment", num.parse(immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0"),
ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(), (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12));
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID.toString(),
@ -321,7 +317,7 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
amount: myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString(),
fileNumber: appState.getAuthenticatedUser()!.patientId.toString(),
orderDescription: "LiveCare Payment",
serviceID: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(),
serviceID: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum().toString(),
projectID: (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12).toString(),
onSuccess: (PaytabsTransactionResponseModel transactionData) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr());
@ -471,7 +467,10 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
);
if (appState.isPaytabsEnabled) {
paytabsViewModel.setAlternatePaymentConfiguration(
"LiveCare Payment", num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()));
"LiveCare Payment",
num.parse(myAppointmentsViewModel.patientAppointmentShareResponseModel!.patientShareWithTax!.toString()),
ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(),
(ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12));
paytabsViewModel.startAlternatePayment(
liveServiceID: immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID.toString(),
@ -817,9 +816,13 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
);
ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest();
await payfortViewModel.getPayfortConfigurations(
serviceId: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(), projectId: ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12, integrationId: 2);
if (!appState.isPaytabsEnabled) {
await payfortViewModel.getPayfortConfigurations(
serviceId: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(), projectId: ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12, integrationId: 2);
} else {
await paytabsViewModel.setPaymentConfiguration("LiveCare Payment", num.parse((immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0")),
ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(), (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? 15 : 12));
}
applePayInsertRequest.clientRequestID = transID;
applePayInsertRequest.clinicID = immediateLiveCareViewModel.immediateLiveCareSelectedClinic.serviceID!;
@ -865,11 +868,10 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
applePayInsertRequest.returnURL = "";
//TODO: Need to pass dynamic params to the Apple Pay instead of static values
await payfortViewModel.applePayRequestInsert(applePayInsertRequest: applePayInsertRequest).then((value) {
await payfortViewModel.applePayRequestInsert(applePayInsertRequest: applePayInsertRequest).then((value) async {
if (appState.isPaytabsEnabled) {
selectedPaymentMethod = "VISA";
LoaderBottomSheet.hideLoader();
paytabsViewModel.setPaymentConfiguration("Advance Payment", num.parse((immediateLiveCareViewModel.liveCareImmediateAppointmentFeesList.total ?? "0.0")));
paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr());
await immediateLiveCareViewModel.addNewCallRequestForImmediateLiveCare(transactionData.transactionReference!);

@ -146,7 +146,7 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
);
ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), bookAppointmentsViewModel.selectedDoctor.projectID!);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -316,7 +316,7 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
);
ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), bookAppointmentsViewModel.selectedDoctor.projectID!);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -854,7 +854,7 @@ class _WaitingAppointmentPaymentPageState extends State<WaitingAppointmentPaymen
paytabsViewModel.setPaymentConfiguration(
"Appointment Payment",
bookAppointmentsViewModel.patientWalkInAppointmentShareResponseModel!.patientShareWithTax!,
);
ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum(), bookAppointmentsViewModel.selectedDoctor.projectID!);
paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.bookingWaitingAppointment.tr(context: context));
await bookAppointmentsViewModel.insertSpecificAppointmentForWalkIn(onSuccess: (val) async {

@ -131,7 +131,7 @@ class _ErOnlineCheckinPaymentPageState extends State<ErOnlineCheckinPaymentPage>
paytabsViewModel.setPaymentConfiguration(
"ER Online Check-In Payment",
emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!,
);
ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum(), emergencyServicesViewModel.selectedHospital!.iD);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -238,7 +238,7 @@ class _ErOnlineCheckinPaymentPageState extends State<ErOnlineCheckinPaymentPage>
paytabsViewModel.setPaymentConfiguration(
"ER Online Check-In Payment",
emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!,
);
ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum(), emergencyServicesViewModel.selectedHospital!.iD);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -533,7 +533,7 @@ class _ErOnlineCheckinPaymentPageState extends State<ErOnlineCheckinPaymentPage>
paytabsViewModel.setPaymentConfiguration(
"ER Online Check-In Payment",
emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!,
);
ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum(), emergencyServicesViewModel.selectedHospital!.iD);
paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.checkingPaymentStatusPleaseWait.tr(context: context));
if (emergencyServicesViewModel.isERBookAppointment) {

@ -116,7 +116,8 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
selectedPaymentMethod = "MADA";
if (appState.isPaytabsEnabled) {
transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber));
paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount);
await paytabsViewModel.setPaymentConfiguration(
"Advance Payment", habibWalletVM.walletRechargeAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), habibWalletVM.selectedHospital!.iD!);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -313,7 +314,8 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
selectedPaymentMethod = "VISA";
if (appState.isPaytabsEnabled) {
transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber));
paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount);
await paytabsViewModel.setPaymentConfiguration(
"Advance Payment", habibWalletVM.walletRechargeAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), habibWalletVM.selectedHospital!.iD!);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -543,7 +545,11 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber));
await payfortViewModel.getPayfortConfigurations(serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), projectId: habibWalletVM.selectedHospital!.iD!, integrationId: 2);
if(!appState.isPaytabsEnabled) {
await payfortViewModel.getPayfortConfigurations(serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), projectId: habibWalletVM.selectedHospital!.iD!, integrationId: 2);
} else {
await paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), habibWalletVM.selectedHospital!.iD!);
}
applePayInsertRequest.clientRequestID = transID;
applePayInsertRequest.clinicID = 0;
@ -592,7 +598,6 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
if(appState.isPaytabsEnabled) {
selectedPaymentMethod = "VISA";
LoaderBottomSheet.hideLoader();
paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount);
paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
LoaderBottomSheet.showLoader();
await habibWalletVM.HISCreateAdvancePayment(

@ -150,10 +150,7 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
widget.projectID,
appState.getAuthenticatedUser()!.patientId!,
);
paytabsViewModel.setPaymentConfiguration(
"Ancillary Orders Payment",
widget.totalAmount,
);
await paytabsViewModel.setPaymentConfiguration("Ancillary Orders Payment", widget.totalAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), widget.projectID);
paytabsViewModel.startCardPayment(
paymentOption: selectedPaymentMethod,
liveServiceID: "0",
@ -289,10 +286,7 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
widget.projectID,
appState.getAuthenticatedUser()!.patientId!,
);
paytabsViewModel.setPaymentConfiguration(
"Ancillary Orders Payment",
widget.totalAmount,
);
await paytabsViewModel.setPaymentConfiguration("Ancillary Orders Payment", widget.totalAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), widget.projectID);
paytabsViewModel.startCardPayment(paymentOption: selectedPaymentMethod,
liveServiceID: "0",
isScheduleLiveCare: "false",
@ -721,11 +715,13 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
transID = Utils.getAdvancePaymentTransID(widget.projectID, user!.patientId!);
ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest();
await payfortViewModel.getPayfortConfigurations(
serviceId: ServiceTypeEnum.ancillaryOrder.getIdFromServiceEnum(),
projectId: widget.projectID,
integrationId: 2,
);
if (!appState.isPaytabsEnabled) {
await payfortViewModel.getPayfortConfigurations(
serviceId: ServiceTypeEnum.ancillaryOrder.getIdFromServiceEnum(),
projectId: widget.projectID,
integrationId: 2,
);
}
applePayInsertRequest.clientRequestID = transID;
applePayInsertRequest.clinicID = 0;
@ -770,6 +766,10 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
applePayInsertRequest.returnURL = "";
try {
if (appState.isPaytabsEnabled) {
await paytabsViewModel.setPaymentConfiguration("Ancillary Orders Payment", widget.totalAmount, ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), widget.projectID);
}
await payfortViewModel.applePayRequestInsert(applePayInsertRequest: applePayInsertRequest);
} catch (error) {
log("Apple Pay Insert Request Failed: $error");
@ -787,10 +787,6 @@ class _AncillaryOrderPaymentPageState extends State<AncillaryOrderPaymentPage> {
if(appState.isPaytabsEnabled) {
selectedPaymentMethod = "VISA";
LoaderBottomSheet.hideLoader();
paytabsViewModel.setPaymentConfiguration(
"Ancillary Orders Payment",
widget.totalAmount,
);
paytabsViewModel.startApplePayPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
final paymentAmount = widget.totalAmount;
final fortId = transactionData.transactionReference;

Loading…
Cancel
Save