|
|
|
|
@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/enum/PayfortEnums.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
|
|
|
|
|
@ -22,12 +23,16 @@ import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/dragable_sheet.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class EROnlineCheckInPaymentDetails extends StatefulWidget {
|
|
|
|
|
const EROnlineCheckInPaymentDetails();
|
|
|
|
|
|
|
|
|
|
int projectID = 0;
|
|
|
|
|
|
|
|
|
|
EROnlineCheckInPaymentDetails({@required this.projectID});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<EROnlineCheckInPaymentDetails> createState() => _EROnlineCheckInPaymentDetailsState();
|
|
|
|
|
@ -39,6 +44,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
String selectedPaymentMethod;
|
|
|
|
|
String selectedInstallmentPlan;
|
|
|
|
|
String transID = "";
|
|
|
|
|
MyInAppBrowser browser;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -299,10 +305,12 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
if (projectViewModel.havePrivilege(103)) {
|
|
|
|
|
startApplePay();
|
|
|
|
|
} else {
|
|
|
|
|
// openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null, selectedInstallmentPlan);
|
|
|
|
|
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
appo.projectID = widget.projectID;
|
|
|
|
|
openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null, selectedInstallmentPlan);
|
|
|
|
|
openPayment(selectedPaymentMethod, projectViewModel.user, erOnlineCheckInPaymentDetailsResponse.patientShareWithTax, null);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
patientShare: erOnlineCheckInPaymentDetailsResponse.patientShareWithTax,
|
|
|
|
|
@ -311,8 +319,43 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, num amount, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(widget.projectID, projectViewModel.user.patientID);
|
|
|
|
|
|
|
|
|
|
browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart);
|
|
|
|
|
|
|
|
|
|
browser.openPaymentBrowser(amount, "ER Online Check-In Payment", transID, widget.projectID.toString(), authenticatedUser.emailAddress,
|
|
|
|
|
paymentMethod, authenticatedUser.patientType, authenticatedUser.firstName, authenticatedUser.patientID, authenticatedUser, browser, false, "3", "", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserLoadStart(String url) {
|
|
|
|
|
print("onBrowserLoadStart");
|
|
|
|
|
print(url);
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser.successURLS.forEach((element) {
|
|
|
|
|
if (url.contains(element)) {
|
|
|
|
|
if (browser.isOpened()) browser.close();
|
|
|
|
|
MyInAppBrowser.isPaymentDone = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser.errorURLS.forEach((element) {
|
|
|
|
|
if (url.contains(element)) {
|
|
|
|
|
if (browser.isOpened()) browser.close();
|
|
|
|
|
MyInAppBrowser.isPaymentDone = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) {
|
|
|
|
|
print("onBrowserExit Called!!!!");
|
|
|
|
|
checkPaymentStatus(appo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void startApplePay() async {
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(15, projectViewModel.user.patientID);
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(widget.projectID, projectViewModel.user.patientID);
|
|
|
|
|
|
|
|
|
|
print("TransactionID: $transID");
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
@ -321,7 +364,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
|
|
|
|
|
|
|
|
|
|
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
|
|
|
|
|
await context.read<PayfortViewModel>().getProjectDetailsForPayfort(projectId: 15, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) {
|
|
|
|
|
await context.read<PayfortViewModel>().getProjectDetailsForPayfort(projectId: widget.projectID, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) {
|
|
|
|
|
payfortProjectDetailsRespModel = value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -335,7 +378,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
applePayInsertRequest.deviceToken = await AppSharedPreferences().getString(PUSH_TOKEN);
|
|
|
|
|
applePayInsertRequest.voipToken = await AppSharedPreferences().getString(ONESIGNAL_APNS_TOKEN);
|
|
|
|
|
applePayInsertRequest.doctorID = 0;
|
|
|
|
|
applePayInsertRequest.projectID = "15";
|
|
|
|
|
applePayInsertRequest.projectID = widget.projectID.toString();
|
|
|
|
|
applePayInsertRequest.serviceID = ServiceTypeEnum.advancePayment.getIdFromServiceEnum().toString();
|
|
|
|
|
applePayInsertRequest.channelID = 3;
|
|
|
|
|
applePayInsertRequest.patientID = projectViewModel.user.patientID;
|
|
|
|
|
@ -343,7 +386,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
applePayInsertRequest.patientOutSA = projectViewModel.user.outSA;
|
|
|
|
|
applePayInsertRequest.appointmentDate = null;
|
|
|
|
|
applePayInsertRequest.appointmentNo = 0;
|
|
|
|
|
applePayInsertRequest.orderDescription = "Ancillary Order Payment";
|
|
|
|
|
applePayInsertRequest.orderDescription = "ER Online Check-In Payment";
|
|
|
|
|
applePayInsertRequest.liveServiceID = "0";
|
|
|
|
|
applePayInsertRequest.latitude = "0.0";
|
|
|
|
|
applePayInsertRequest.longitude = "0.0";
|
|
|
|
|
@ -372,7 +415,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
customerName: projectViewModel.user.firstName + " " + projectViewModel.user.lastName,
|
|
|
|
|
// customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
|
|
|
|
customerEmail: "CustID_${projectViewModel.user.patientID}@HMG.com",
|
|
|
|
|
orderDescription: "Ancillary Order Payment",
|
|
|
|
|
orderDescription: "ER Online Check-In Payment",
|
|
|
|
|
orderAmount: erOnlineCheckInPaymentDetailsResponse.patientShareWithTax,
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
|
|
|
|
|
@ -387,7 +430,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
checkPaymentStatus(AppoitmentAllHistoryResultList());
|
|
|
|
|
},
|
|
|
|
|
projectId: 15,
|
|
|
|
|
projectId: widget.projectID,
|
|
|
|
|
serviceTypeEnum: ServiceTypeEnum.appointmentPayment,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
@ -423,11 +466,11 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
createAdvancePayment(paymentRes, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
String paymentReference = paymentRes['Fort_id'].toString();
|
|
|
|
|
service.HIS_createAdvancePayment(appo, "15", paymentRes['Amount'], paymentRes['Fort_id'], paymentRes['PaymentMethod'], projectViewModel.user.patientType,
|
|
|
|
|
service.HIS_createAdvancePayment(appo, widget.projectID.toString(), paymentRes['Amount'], paymentRes['Fort_id'], paymentRes['PaymentMethod'], projectViewModel.user.patientType,
|
|
|
|
|
projectViewModel.user.firstName + " " + projectViewModel.user.lastName, projectViewModel.user.patientID, context)
|
|
|
|
|
.then((res) {
|
|
|
|
|
addAdvancedNumberRequest(
|
|
|
|
|
Utils.isVidaPlusProject(projectViewModel, 15) ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
Utils.isVidaPlusProject(projectViewModel, widget.projectID) ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference,
|
|
|
|
|
0,
|
|
|
|
|
appo,
|
|
|
|
|
@ -452,7 +495,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
|
|
|
|
|
autoGenerateInvoiceER(res) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
service.autoGenerateInvoiceERClinic(15, 4, res['Fort_id'], res['Amount'], res['PaymentMethod'], res['CardNumber'], res['Merchant_Reference'], res['RRN']).then((res) {
|
|
|
|
|
service.autoGenerateInvoiceERClinic(widget.projectID, 4, res['Fort_id'], res['Amount'], res['PaymentMethod'], res['CardNumber'], res['Merchant_Reference'], res['RRN']).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
@ -464,7 +507,7 @@ class _EROnlineCheckInPaymentDetailsState extends State<EROnlineCheckInPaymentDe
|
|
|
|
|
getEROnlineCheckInPaymentDetails() {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
ClinicListService ancillaryOrdersService = new ClinicListService();
|
|
|
|
|
ancillaryOrdersService.getEROnlineCheckInPaymentDetails(15, 10).then((response) {
|
|
|
|
|
ancillaryOrdersService.getEROnlineCheckInPaymentDetails(widget.projectID, 10).then((response) {
|
|
|
|
|
erOnlineCheckInPaymentDetailsResponse = EROnlineCheckInPaymentDetailsResponse.fromJson(response["ResponsePatientShare"]);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
|