|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
|
|
|
import 'dart:developer';
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/analytics/google-analytics.dart';
|
|
|
|
import 'package:diplomaticquarterapp/analytics/google-analytics.dart';
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/core/enum/PayfortEnums.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
|
|
@ -10,6 +12,7 @@ import 'package:diplomaticquarterapp/models/Appointments/OBGyneProcedureListResp
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/anicllary-orders/ancillary_order_list_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/models/anicllary-orders/ancillary_order_list_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/BookAppointment/QRCode.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/BookAppointment/QRCode.dart';
|
|
|
|
@ -21,6 +24,9 @@ import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dar
|
|
|
|
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
|
|
|
|
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
|
|
|
|
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
|
|
|
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
|
|
|
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/services/payfort_services/payfort_project_details_resp_model.dart';
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/services/payfort_services/payfort_view_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
@ -1299,12 +1305,96 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
|
|
|
|
|
|
|
|
|
|
|
|
if (value != null) {
|
|
|
|
if (value != null) {
|
|
|
|
final appType = appo.isLiveCareAppointment ? 'livecare' : 'regular';
|
|
|
|
final appType = appo.isLiveCareAppointment ? 'livecare' : 'regular';
|
|
|
|
|
|
|
|
if (selectedPaymentMethod == "ApplePay") {
|
|
|
|
|
|
|
|
startApplePay(appo, patientShareResponse);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
openPayment(value, projectViewModel.user, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo);
|
|
|
|
openPayment(value, projectViewModel.user, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo);
|
|
|
|
|
|
|
|
}
|
|
|
|
projectViewModel.analytics.appointment.payment_method(appointment_type: appType, clinic: appo.clinicName, payment_method: value[0], payment_type: 'appointment');
|
|
|
|
projectViewModel.analytics.appointment.payment_method(appointment_type: appType, clinic: appo.clinicName, payment_method: value[0], payment_type: 'appointment');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void startApplePay(AppoitmentAllHistoryResultList appo, PatientShareResponse patientShareResponse) async {
|
|
|
|
|
|
|
|
String transID = Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo);
|
|
|
|
|
|
|
|
print("TransactionID: $transID");
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LiveCareService service = new LiveCareService();
|
|
|
|
|
|
|
|
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
|
|
|
|
|
|
|
|
await context.read<PayfortViewModel>().getProjectDetailsForPayfort(projectId: appo.projectID, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) {
|
|
|
|
|
|
|
|
payfortProjectDetailsRespModel = value;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applePayInsertRequest.clientRequestID = transID;
|
|
|
|
|
|
|
|
applePayInsertRequest.clinicID = appo.clinicID;
|
|
|
|
|
|
|
|
applePayInsertRequest.currency = projectViewModel.authenticatedUserObject.user.outSA == 1 ? "AED" : "SAR";
|
|
|
|
|
|
|
|
applePayInsertRequest.customerEmail = projectViewModel.authenticatedUserObject.user.emailAddress;
|
|
|
|
|
|
|
|
applePayInsertRequest.customerID = projectViewModel.authenticatedUserObject.user.patientID;
|
|
|
|
|
|
|
|
applePayInsertRequest.customerName = projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName;
|
|
|
|
|
|
|
|
applePayInsertRequest.deviceToken = await AppSharedPreferences().getString(PUSH_TOKEN);
|
|
|
|
|
|
|
|
applePayInsertRequest.voipToken = await AppSharedPreferences().getString(ONESIGNAL_APNS_TOKEN);
|
|
|
|
|
|
|
|
applePayInsertRequest.doctorID = appo.doctorID;
|
|
|
|
|
|
|
|
applePayInsertRequest.projectID = appo.projectID.toString();
|
|
|
|
|
|
|
|
applePayInsertRequest.serviceID = ServiceTypeEnum.advancePayment.getIdFromServiceEnum().toString();
|
|
|
|
|
|
|
|
applePayInsertRequest.channelID = 3;
|
|
|
|
|
|
|
|
applePayInsertRequest.patientID = projectViewModel.authenticatedUserObject.user.patientID;
|
|
|
|
|
|
|
|
applePayInsertRequest.patientTypeID = projectViewModel.authenticatedUserObject.user.patientType;
|
|
|
|
|
|
|
|
applePayInsertRequest.patientOutSA = projectViewModel.authenticatedUserObject.user.outSA;
|
|
|
|
|
|
|
|
applePayInsertRequest.appointmentDate = appo.appointmentDate;
|
|
|
|
|
|
|
|
applePayInsertRequest.appointmentNo = appo.appointmentNo;
|
|
|
|
|
|
|
|
applePayInsertRequest.orderDescription = "Advance Payment";
|
|
|
|
|
|
|
|
applePayInsertRequest.liveServiceID = "0";
|
|
|
|
|
|
|
|
applePayInsertRequest.latitude = "0.0";
|
|
|
|
|
|
|
|
applePayInsertRequest.longitude = "0.0";
|
|
|
|
|
|
|
|
applePayInsertRequest.amount = patientShareResponse.patientShareWithTax.toString();
|
|
|
|
|
|
|
|
applePayInsertRequest.isSchedule = appo.isLiveCareAppointment ? "1" : "0";
|
|
|
|
|
|
|
|
applePayInsertRequest.language = projectViewModel.isArabic ? 'ar' : 'en';
|
|
|
|
|
|
|
|
applePayInsertRequest.userName = projectViewModel.authenticatedUserObject.user.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 = payfortProjectDetailsRespModel.merchantIdentifier;
|
|
|
|
|
|
|
|
applePayInsertRequest.commandType = "PURCHASE";
|
|
|
|
|
|
|
|
applePayInsertRequest.signature = payfortProjectDetailsRespModel.signature;
|
|
|
|
|
|
|
|
applePayInsertRequest.accessCode = payfortProjectDetailsRespModel.accessCode;
|
|
|
|
|
|
|
|
applePayInsertRequest.shaRequestPhrase = payfortProjectDetailsRespModel.shaRequest;
|
|
|
|
|
|
|
|
applePayInsertRequest.shaResponsePhrase = payfortProjectDetailsRespModel.shaResponse;
|
|
|
|
|
|
|
|
applePayInsertRequest.returnURL = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
service.applePayInsertRequest(applePayInsertRequest, context).then((res) async {
|
|
|
|
|
|
|
|
await context.read<PayfortViewModel>().initiateApplePayWithPayfort(
|
|
|
|
|
|
|
|
customerName: projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName,
|
|
|
|
|
|
|
|
customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
|
|
|
|
|
|
|
orderDescription: "Appointment Payment",
|
|
|
|
|
|
|
|
orderAmount: double.parse(patientShareResponse.patientShareWithTax.toString()),
|
|
|
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
|
|
|
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
|
|
|
|
|
|
|
|
onFailed: (failureResult) async {
|
|
|
|
|
|
|
|
log("failureResult: ${failureResult.toString()}");
|
|
|
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
|
|
|
AppToast.showErrorToast(message: failureResult.toString());
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onSuccess: (successResult) async {
|
|
|
|
|
|
|
|
log("Payfort: ${successResult.responseMessage}");
|
|
|
|
|
|
|
|
await context.read<PayfortViewModel>().addPayfortApplePayResponse(result: successResult);
|
|
|
|
|
|
|
|
checkPaymentStatus(appo);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
projectId: appo.projectID,
|
|
|
|
|
|
|
|
serviceTypeEnum: ServiceTypeEnum.appointmentPayment,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
|
|
|
print(err);
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
confirmAppointment(AppoitmentAllHistoryResultList appo) {
|
|
|
|
confirmAppointment(AppoitmentAllHistoryResultList appo) {
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|