|
|
|
|
@ -52,6 +52,8 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
String transID = "";
|
|
|
|
|
|
|
|
|
|
bool isShowTamara = false;
|
|
|
|
|
String tamaraPaymentStatus = "";
|
|
|
|
|
String tamaraOrderID = "";
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -117,7 +119,7 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
Transform.flip(
|
|
|
|
|
flipX: appState.isArabic() ? true : false,
|
|
|
|
|
child: Utils.buildSvgWithAssets(
|
|
|
|
|
icon: AppAssets.forward_arrow_icon,
|
|
|
|
|
icon: AppAssets.forward_arrow_icon_small,
|
|
|
|
|
iconColor: AppColors.blackColor,
|
|
|
|
|
width: 18.h,
|
|
|
|
|
height: 13.h,
|
|
|
|
|
@ -159,7 +161,7 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
Transform.flip(
|
|
|
|
|
flipX: appState.isArabic() ? true : false,
|
|
|
|
|
child: Utils.buildSvgWithAssets(
|
|
|
|
|
icon: AppAssets.forward_arrow_icon,
|
|
|
|
|
icon: AppAssets.forward_arrow_icon_small,
|
|
|
|
|
iconColor: AppColors.blackColor,
|
|
|
|
|
width: 18.h,
|
|
|
|
|
height: 13.h,
|
|
|
|
|
@ -196,18 +198,18 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
Transform.flip(
|
|
|
|
|
flipX: appState.isArabic() ? true : false,
|
|
|
|
|
child: Utils.buildSvgWithAssets(
|
|
|
|
|
icon: AppAssets.forward_arrow_icon,
|
|
|
|
|
iconColor: AppColors.blackColor,
|
|
|
|
|
width: 18.h,
|
|
|
|
|
height: 13.h,
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
).toShimmer2(isShow: myAppointmentsVM.isAppointmentPatientShareLoading),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
selectedPaymentMethod = "TAMARA";
|
|
|
|
|
openPaymentURL("tamara");
|
|
|
|
|
icon: AppAssets.forward_arrow_icon_small,
|
|
|
|
|
iconColor: AppColors.blackColor,
|
|
|
|
|
width: 18.h,
|
|
|
|
|
height: 13.h,
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
).toShimmer2(isShow: myAppointmentsVM.isAppointmentPatientShareLoading),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
selectedPaymentMethod = "TAMARA";
|
|
|
|
|
openPaymentURL("tamara");
|
|
|
|
|
})
|
|
|
|
|
: SizedBox.shrink(),
|
|
|
|
|
],
|
|
|
|
|
@ -328,12 +330,12 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
if (selectedPaymentMethod == "tamara") {
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
|
Uri uri = new Uri.dataFromString(url);
|
|
|
|
|
// tamaraPaymentStatus = uri.queryParameters['status']!;
|
|
|
|
|
// tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!;
|
|
|
|
|
tamaraPaymentStatus = uri.queryParameters['status']!;
|
|
|
|
|
tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!;
|
|
|
|
|
} else {
|
|
|
|
|
Uri uri = new Uri.dataFromString(url);
|
|
|
|
|
// tamaraPaymentStatus = uri.queryParameters['paymentStatus']!;
|
|
|
|
|
// tamaraOrderID = uri.queryParameters['orderId']!;
|
|
|
|
|
tamaraPaymentStatus = uri.queryParameters['paymentStatus']!;
|
|
|
|
|
tamaraOrderID = uri.queryParameters['orderId']!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -359,95 +361,155 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserExit(bool isPaymentMade) async {
|
|
|
|
|
print("onBrowserExit Called!!!!");
|
|
|
|
|
if (selectedPaymentMethod == "TAMARA") {
|
|
|
|
|
// checkTamaraPaymentStatus(transID!, appo);
|
|
|
|
|
// if (tamaraPaymentStatus != null && tamaraPaymentStatus.toLowerCase() == "approved") {
|
|
|
|
|
// updateTamaraRequestStatus("success", "14", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo);
|
|
|
|
|
// } else {
|
|
|
|
|
// updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo);
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
checkPaymentStatus();
|
|
|
|
|
// checkPaymentStatus(appo);
|
|
|
|
|
}
|
|
|
|
|
checkPaymentStatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void checkPaymentStatus() async {
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
await payfortViewModel.checkPaymentStatus(
|
|
|
|
|
transactionID: transID,
|
|
|
|
|
onSuccess: (apiResponse) async {
|
|
|
|
|
print(apiResponse.data);
|
|
|
|
|
if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") {
|
|
|
|
|
await myAppointmentsViewModel.createAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
payedAmount: payfortViewModel.payfortCheckPaymentStatusResponseModel!.amount!,
|
|
|
|
|
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
|
|
|
|
|
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()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) {
|
|
|
|
|
//TODO: Implement LiveCare Check-In API Call
|
|
|
|
|
await myAppointmentsViewModel.insertLiveCareVIDARequest(
|
|
|
|
|
clientRequestID: transID,
|
|
|
|
|
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {});
|
|
|
|
|
} else {
|
|
|
|
|
await myAppointmentsViewModel.generateAppointmentQR(
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
// Navigator.of(context).push(
|
|
|
|
|
// CustomPageRoute(page: MyAppointmentsPage()),
|
|
|
|
|
// );
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: "Checking payment status, Please wait...".needTranslation);
|
|
|
|
|
if (selectedPaymentMethod == "TAMARA") {
|
|
|
|
|
await payfortViewModel.checkTamaraPaymentStatus(
|
|
|
|
|
transactionID: transID,
|
|
|
|
|
onSuccess: (apiResponse) async {
|
|
|
|
|
if (apiResponse.data["status"].toString().toLowerCase() == "success") {
|
|
|
|
|
tamaraOrderID = apiResponse.data["tamara_order_id"].toString();
|
|
|
|
|
await payfortViewModel.updateTamaraRequestStatus(responseMessage: "success", status: "14", clientRequestID: transID, tamaraOrderID: tamaraOrderID);
|
|
|
|
|
await payfortViewModel.markAppointmentAsTamaraPaid(
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID, appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo);
|
|
|
|
|
await myAppointmentsViewModel.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: "Tamara-Advance-0000",
|
|
|
|
|
paymentReference: tamaraOrderID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) {
|
|
|
|
|
//TODO: Implement LiveCare Check-In API Call
|
|
|
|
|
await myAppointmentsViewModel.insertLiveCareVIDARequest(
|
|
|
|
|
clientRequestID: tamaraOrderID,
|
|
|
|
|
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {});
|
|
|
|
|
} else {
|
|
|
|
|
await myAppointmentsViewModel.generateAppointmentQR(
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await payfortViewModel.updateTamaraRequestStatus(responseMessage: "Failed", status: "00", clientRequestID: transID, tamaraOrderID: tamaraOrderID);
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await payfortViewModel.checkPaymentStatus(
|
|
|
|
|
transactionID: transID,
|
|
|
|
|
onSuccess: (apiResponse) async {
|
|
|
|
|
print(apiResponse.data);
|
|
|
|
|
if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") {
|
|
|
|
|
await myAppointmentsViewModel.createAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
payedAmount: payfortViewModel.payfortCheckPaymentStatusResponseModel!.amount!,
|
|
|
|
|
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
|
|
|
|
|
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()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) {
|
|
|
|
|
//TODO: Implement LiveCare Check-In API Call
|
|
|
|
|
await myAppointmentsViewModel.insertLiveCareVIDARequest(
|
|
|
|
|
clientRequestID: transID,
|
|
|
|
|
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {});
|
|
|
|
|
} else {
|
|
|
|
|
await myAppointmentsViewModel.generateAppointmentQR(
|
|
|
|
|
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
|
|
|
|
|
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
|
|
|
|
|
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
|
|
|
|
|
isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!,
|
|
|
|
|
onSuccess: (apiResponse) {
|
|
|
|
|
Future.delayed(Duration(milliseconds: 500), () {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPaymentURL(String paymentMethod) {
|
|
|
|
|
|