|
|
|
|
@ -89,6 +89,9 @@ class _clinic_listState extends State<ClinicList> {
|
|
|
|
|
String tamaraOrderID;
|
|
|
|
|
String selectedInstallmentPlan;
|
|
|
|
|
|
|
|
|
|
String transID;
|
|
|
|
|
BuildContext localContext;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
liveCareClinicsListResponse = new LiveCareClinicsListResponse();
|
|
|
|
|
@ -114,6 +117,7 @@ class _clinic_listState extends State<ClinicList> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
projectViewModel = Provider.of(context);
|
|
|
|
|
localContext = context;
|
|
|
|
|
getLanguageID();
|
|
|
|
|
return Container(
|
|
|
|
|
child: currentSelectedLiveCareType == "immediate" ? getLiveCareImmediateClinicList() : getLiveCareScheduleClinicList(),
|
|
|
|
|
@ -325,134 +329,123 @@ class _clinic_listState extends State<ClinicList> {
|
|
|
|
|
patientShare: num.parse(getERAppointmentFeesList.total),
|
|
|
|
|
isFromAdvancePayment: widget.isPharmacyLiveCare,
|
|
|
|
|
))).then((value) {
|
|
|
|
|
selectedPaymentMethod = value[0];
|
|
|
|
|
print(value);
|
|
|
|
|
widget.isPharmacyLiveCare = isPharmacyLiveCare;
|
|
|
|
|
widget.pharmacyLiveCareQRCode = pharmaLiveCareQRCodeValue;
|
|
|
|
|
if (value != null) {
|
|
|
|
|
if (selectedPaymentMethod == "ApplePay") {
|
|
|
|
|
startApplePay(appo, getERAppointmentFeesList.total);
|
|
|
|
|
} else {
|
|
|
|
|
openPayment(value, authUser, num.parse(getERAppointmentFeesList.total), appo);
|
|
|
|
|
selectedPaymentMethod = value[0];
|
|
|
|
|
print(value);
|
|
|
|
|
widget.isPharmacyLiveCare = isPharmacyLiveCare;
|
|
|
|
|
widget.pharmacyLiveCareQRCode = pharmaLiveCareQRCodeValue;
|
|
|
|
|
if (value != null) {
|
|
|
|
|
if (selectedPaymentMethod == "ApplePay") {
|
|
|
|
|
startApplePay(appo, getERAppointmentFeesList.total);
|
|
|
|
|
} else {
|
|
|
|
|
openPayment(value, authUser, num.parse(getERAppointmentFeesList.total), appo);
|
|
|
|
|
}
|
|
|
|
|
projectViewModel.analytics.liveCare.payment_method(appointment_type: 'livecare', clinic: selectedClinicName, payment_method: value[0], payment_type: 'appointment');
|
|
|
|
|
}
|
|
|
|
|
projectViewModel.analytics.liveCare.payment_method(appointment_type: 'livecare', clinic: selectedClinicName, payment_method: value[0], payment_type: 'appointment');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void startApplePay(AppoitmentAllHistoryResultList appo, String amount) 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.liveCareAppointment.getIdFromServiceEnum(), languageID: projectViewModel.isArabic ? 1 : 2)
|
|
|
|
|
.then((value) {
|
|
|
|
|
payfortProjectDetailsRespModel = value;
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
transID = Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo);
|
|
|
|
|
print("TransactionID: $transID");
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(localContext);
|
|
|
|
|
|
|
|
|
|
LiveCareService service = new LiveCareService();
|
|
|
|
|
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
|
|
|
|
|
|
|
|
|
|
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
|
|
|
|
|
await localContext
|
|
|
|
|
.read<PayfortViewModel>()
|
|
|
|
|
.getProjectDetailsForPayfort(projectId: appo.projectID, serviceId: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(), languageID: projectViewModel.isArabic ? 1 : 2)
|
|
|
|
|
.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.liveCareAppointment.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 = "LiveCare Payment";
|
|
|
|
|
applePayInsertRequest.liveServiceID = "0";
|
|
|
|
|
applePayInsertRequest.latitude = "0.0";
|
|
|
|
|
applePayInsertRequest.longitude = "0.0";
|
|
|
|
|
applePayInsertRequest.amount = amount;
|
|
|
|
|
applePayInsertRequest.isSchedule = appo.isLiveCareAppointment ? "1" : "0";
|
|
|
|
|
applePayInsertRequest.language = projectViewModel.isArabic ? 'ar' : 'en';
|
|
|
|
|
applePayInsertRequest.languageID = projectViewModel.isArabic ? 1 : 2;
|
|
|
|
|
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: "LiveCare Payment",
|
|
|
|
|
orderAmount: double.parse(amount),
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
|
|
|
|
|
currency: projectViewModel.authenticatedUserObject.user.outSA == 1 ? "AED" : "SAR",
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
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.liveCareAppointment.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 = "LiveCare Payment";
|
|
|
|
|
applePayInsertRequest.liveServiceID = "0";
|
|
|
|
|
applePayInsertRequest.latitude = "0.0";
|
|
|
|
|
applePayInsertRequest.longitude = "0.0";
|
|
|
|
|
applePayInsertRequest.amount = amount;
|
|
|
|
|
applePayInsertRequest.isSchedule = appo.isLiveCareAppointment ? "1" : "0";
|
|
|
|
|
applePayInsertRequest.language = projectViewModel.isArabic ? 'ar' : 'en';
|
|
|
|
|
applePayInsertRequest.languageID = projectViewModel.isArabic ? 1 : 2;
|
|
|
|
|
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, localContext).then((res) async {
|
|
|
|
|
await localContext.read<PayfortViewModel>().initiateApplePayWithPayfort(
|
|
|
|
|
customerName: projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName,
|
|
|
|
|
customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
|
|
|
|
orderDescription: "LiveCare Payment",
|
|
|
|
|
orderAmount: double.parse(amount),
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
|
|
|
|
|
currency: projectViewModel.authenticatedUserObject.user.outSA == 1 ? "AED" : "SAR",
|
|
|
|
|
onFailed: (failureResult) async {
|
|
|
|
|
log("failureResult: ${failureResult.toString()}");
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(localContext);
|
|
|
|
|
AppToast.showErrorToast(message: failureResult.toString());
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (successResult) async {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(localContext);
|
|
|
|
|
log("Payfort: ${successResult.responseMessage}");
|
|
|
|
|
await localContext.read<PayfortViewModel>().addPayfortApplePayResponse(result: successResult);
|
|
|
|
|
checkPaymentStatus(appo);
|
|
|
|
|
},
|
|
|
|
|
projectId: appo.projectID,
|
|
|
|
|
serviceTypeEnum: ServiceTypeEnum.appointmentPayment,
|
|
|
|
|
);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(localContext);
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
});
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
print(ex.toString());
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(localContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPayment(List<String> paymentMethod, AuthenticatedUser authenticatedUser, num amount, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart, context: context);
|
|
|
|
|
|
|
|
|
|
transID = Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo);
|
|
|
|
|
selectedPaymentMethod = paymentMethod[0];
|
|
|
|
|
selectedInstallmentPlan = paymentMethod[1];
|
|
|
|
|
this.amount = amount.toString();
|
|
|
|
|
|
|
|
|
|
browser.openPaymentBrowser(
|
|
|
|
|
amount,
|
|
|
|
|
"LiveCare Payment",
|
|
|
|
|
widget.isPharmacyLiveCare ? widget.pharmacyLiveCareQRCode : Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo),
|
|
|
|
|
"12",
|
|
|
|
|
authenticatedUser.emailAddress,
|
|
|
|
|
paymentMethod[0],
|
|
|
|
|
authenticatedUser.patientType,
|
|
|
|
|
authenticatedUser.firstName,
|
|
|
|
|
authenticatedUser.patientID,
|
|
|
|
|
authenticatedUser,
|
|
|
|
|
browser,
|
|
|
|
|
false,
|
|
|
|
|
"4",
|
|
|
|
|
selectedClinicID,
|
|
|
|
|
context,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
paymentMethod[1]);
|
|
|
|
|
browser.openPaymentBrowser(amount, "LiveCare Payment", widget.isPharmacyLiveCare ? widget.pharmacyLiveCareQRCode : transID, "12", authenticatedUser.emailAddress, paymentMethod[0],
|
|
|
|
|
authenticatedUser.patientType, authenticatedUser.firstName, authenticatedUser.patientID, authenticatedUser, browser, false, "4", selectedClinicID, context, "", "", "", "", paymentMethod[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserLoadStart(String url) {
|
|
|
|
|
@ -560,10 +553,7 @@ class _clinic_listState extends State<ClinicList> {
|
|
|
|
|
final currency = projectViewModel.user.outSA == 0 ? "sar" : 'aed';
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
service
|
|
|
|
|
.checkPaymentStatus(
|
|
|
|
|
widget.isPharmacyLiveCare ? widget.pharmacyLiveCareQRCode : Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), widget.isPharmacyLiveCare, context)
|
|
|
|
|
.then((res) {
|
|
|
|
|
service.checkPaymentStatus(widget.isPharmacyLiveCare ? widget.pharmacyLiveCareQRCode : transID, widget.isPharmacyLiveCare, context).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
String paymentInfo = res['Response_Message'];
|
|
|
|
|
amount = res['Amount'].toString();
|
|
|
|
|
@ -611,7 +601,7 @@ class _clinic_listState extends State<ClinicList> {
|
|
|
|
|
isDataLoaded = false;
|
|
|
|
|
LiveCareService service = new LiveCareService();
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
service.getLivecareClinics(languageID == 'ar' ? 1: 2, context).then((res) {
|
|
|
|
|
service.getLivecareClinics(languageID == 'ar' ? 1 : 2, context).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
print(res['PatientER_GetClinicsList'].length);
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
|