|
|
|
|
@ -24,25 +24,24 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class CovidPaymentSummary extends StatefulWidget {
|
|
|
|
|
PatientShareResponse patientShareResponse;
|
|
|
|
|
|
|
|
|
|
PatientShareResponse? patientShareResponse;
|
|
|
|
|
String selectedPaymentMethod;
|
|
|
|
|
String selectedInstallmentPlan;
|
|
|
|
|
MyInAppBrowser browser;
|
|
|
|
|
AuthenticatedUser authenticatedUser;
|
|
|
|
|
String? selectedInstallmentPlan;
|
|
|
|
|
MyInAppBrowser? browser;
|
|
|
|
|
AuthenticatedUser? authenticatedUser;
|
|
|
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
|
String transID = "";
|
|
|
|
|
|
|
|
|
|
CovidPaymentSummary({@required this.patientShareResponse, this.selectedPaymentMethod});
|
|
|
|
|
CovidPaymentSummary({required this.patientShareResponse, required this.selectedPaymentMethod});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_CovidPaymentSummaryState createState() => _CovidPaymentSummaryState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
ProjectViewModel projectViewModel;
|
|
|
|
|
String tamaraPaymentStatus;
|
|
|
|
|
String tamaraOrderID;
|
|
|
|
|
late ProjectViewModel projectViewModel;
|
|
|
|
|
late String tamaraPaymentStatus;
|
|
|
|
|
late String tamaraOrderID;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -81,7 +80,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${widget.patientShareResponse.patientShareWithTax} ' + TranslationBase.of(context).sar,
|
|
|
|
|
'${widget.patientShareResponse!.patientShareWithTax} ' + TranslationBase.of(context).sar,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
@ -103,7 +102,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
Container(
|
|
|
|
|
height: 100.0,
|
|
|
|
|
padding: EdgeInsets.all(7.0),
|
|
|
|
|
child: Image.asset(getImagePath(widget.selectedPaymentMethod), width: 100, height: 100),
|
|
|
|
|
child: Image.asset(getImagePath(widget.selectedPaymentMethod!), width: 100, height: 100),
|
|
|
|
|
),
|
|
|
|
|
mFlex(1),
|
|
|
|
|
InkWell(
|
|
|
|
|
@ -111,12 +110,12 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
showDraggableDialog(
|
|
|
|
|
context,
|
|
|
|
|
PaymentMethod(
|
|
|
|
|
onSelectedMethod: (String metohd, [String selectedInstallmentPlan]) {
|
|
|
|
|
onSelectedMethod: (String metohd, [String? selectedInstallmentPlan]) {
|
|
|
|
|
widget.selectedPaymentMethod = metohd;
|
|
|
|
|
widget.selectedInstallmentPlan = selectedInstallmentPlan;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
patientShare: widget.patientShareResponse.patientShareWithTax,
|
|
|
|
|
patientShare: widget.patientShareResponse!.patientShareWithTax,
|
|
|
|
|
));
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
@ -135,7 +134,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
flex: 1,
|
|
|
|
|
child: showDetail(
|
|
|
|
|
TranslationBase.of(context).fileNumber,
|
|
|
|
|
projectViewModel.user.patientID.toString(),
|
|
|
|
|
projectViewModel.user!.patientID.toString(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
mWidth(6),
|
|
|
|
|
@ -143,7 +142,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
flex: 1,
|
|
|
|
|
child: showDetail(
|
|
|
|
|
TranslationBase.of(context).name,
|
|
|
|
|
projectViewModel.user.firstName.toString(),
|
|
|
|
|
projectViewModel.user!.firstName.toString(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -151,13 +150,13 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 6,
|
|
|
|
|
),
|
|
|
|
|
showDetail(TranslationBase.of(context).mobileNumber, projectViewModel.user.mobileNumber),
|
|
|
|
|
showDetail(TranslationBase.of(context).mobileNumber, projectViewModel.user!.mobileNumber!),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 6,
|
|
|
|
|
),
|
|
|
|
|
showDetail(
|
|
|
|
|
TranslationBase.of(context).depositorName,
|
|
|
|
|
projectViewModel.user.firstName + " " + projectViewModel.user.middleName + " " + projectViewModel.user.lastName,
|
|
|
|
|
projectViewModel.user!.firstName! + " " + projectViewModel.user!.middleName! + " " + projectViewModel.user!.lastName!,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -171,7 +170,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
child: DefaultButton(
|
|
|
|
|
TranslationBase.of(context).confirm.toUpperCase(),
|
|
|
|
|
() {
|
|
|
|
|
startPaymentProcess(projectViewModel.user);
|
|
|
|
|
startPaymentProcess(projectViewModel.user!);
|
|
|
|
|
},
|
|
|
|
|
color: CustomColors.green,
|
|
|
|
|
),
|
|
|
|
|
@ -207,36 +206,37 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
|
|
|
|
|
startPaymentProcess(AuthenticatedUser authenticatedUser) {
|
|
|
|
|
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
appo.projectID = widget.patientShareResponse.projectID;
|
|
|
|
|
appo.clinicID = widget.patientShareResponse.clinicID;
|
|
|
|
|
appo.appointmentNo = widget.patientShareResponse.appointmentNo;
|
|
|
|
|
appo.projectID = widget.patientShareResponse!.projectID;
|
|
|
|
|
appo.clinicID = widget.patientShareResponse!.clinicID;
|
|
|
|
|
appo.appointmentNo = widget.patientShareResponse!.appointmentNo;
|
|
|
|
|
|
|
|
|
|
openPayment(widget.selectedPaymentMethod, authenticatedUser, double.parse(widget.patientShareResponse.patientShareWithTax.toString()), widget.patientShareResponse, appo);
|
|
|
|
|
openPayment(widget.selectedPaymentMethod, authenticatedUser, double.parse(widget.patientShareResponse!.patientShareWithTax.toString()), widget.patientShareResponse!, appo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, num amount, PatientShareResponse patientShareResponse, AppoitmentAllHistoryResultList appo) async {
|
|
|
|
|
widget.browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart, context: context);
|
|
|
|
|
|
|
|
|
|
widget.browser.openPaymentBrowser(
|
|
|
|
|
amount,
|
|
|
|
|
"Covid appointment payment",
|
|
|
|
|
Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo),
|
|
|
|
|
appo.projectID.toString(),
|
|
|
|
|
authenticatedUser.emailAddress,
|
|
|
|
|
paymentMethod,
|
|
|
|
|
authenticatedUser.patientType,
|
|
|
|
|
authenticatedUser.firstName,
|
|
|
|
|
authenticatedUser.patientID,
|
|
|
|
|
authenticatedUser,
|
|
|
|
|
widget.browser,
|
|
|
|
|
widget.patientShareResponse.isLiveCareAppointment,
|
|
|
|
|
"2",
|
|
|
|
|
"",
|
|
|
|
|
widget.patientShareResponse.appointmentDate,
|
|
|
|
|
widget.patientShareResponse.appointmentNo,
|
|
|
|
|
widget.patientShareResponse.clinicID,
|
|
|
|
|
widget.patientShareResponse.doctorID,
|
|
|
|
|
widget.selectedInstallmentPlan);
|
|
|
|
|
widget.browser!.openPaymentBrowser(
|
|
|
|
|
amount,
|
|
|
|
|
"Covid appointment payment",
|
|
|
|
|
Utils.getAppointmentTransID(appo.projectID!, appo.clinicID!, appo.appointmentNo!),
|
|
|
|
|
appo.projectID.toString(),
|
|
|
|
|
authenticatedUser.emailAddress!,
|
|
|
|
|
paymentMethod,
|
|
|
|
|
authenticatedUser.patientType,
|
|
|
|
|
authenticatedUser.firstName!,
|
|
|
|
|
authenticatedUser.patientID,
|
|
|
|
|
authenticatedUser,
|
|
|
|
|
widget.browser!,
|
|
|
|
|
widget.patientShareResponse!.isLiveCareAppointment!,
|
|
|
|
|
"2",
|
|
|
|
|
"",
|
|
|
|
|
widget.patientShareResponse!.appointmentDate,
|
|
|
|
|
widget.patientShareResponse!.appointmentNo!,
|
|
|
|
|
widget.patientShareResponse!.clinicID!,
|
|
|
|
|
widget.patientShareResponse!.doctorID!,
|
|
|
|
|
widget.selectedInstallmentPlan,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserLoadStart(String url) {
|
|
|
|
|
@ -246,18 +246,18 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
if (widget.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']!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser.successURLS.forEach((element) {
|
|
|
|
|
if (url.contains(element)) {
|
|
|
|
|
if (widget.browser.isOpened()) widget.browser.close();
|
|
|
|
|
if (widget.browser!.isOpened()) widget.browser!.close();
|
|
|
|
|
MyInAppBrowser.isPaymentDone = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -265,7 +265,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser.errorURLS.forEach((element) {
|
|
|
|
|
if (url.contains(element)) {
|
|
|
|
|
if (widget.browser.isOpened()) widget.browser.close();
|
|
|
|
|
if (widget.browser!.isOpened()) widget.browser!.close();
|
|
|
|
|
MyInAppBrowser.isPaymentDone = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -276,7 +276,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
print("onBrowserExit Called!!!!");
|
|
|
|
|
try {
|
|
|
|
|
if (widget.selectedPaymentMethod == "TAMARA") {
|
|
|
|
|
checkTamaraPaymentStatus(Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), appo);
|
|
|
|
|
checkTamaraPaymentStatus(Utils.getAppointmentTransID(appo.projectID!, appo.clinicID!, appo.appointmentNo!), appo);
|
|
|
|
|
// if (tamaraPaymentStatus != null && tamaraPaymentStatus.toLowerCase() == "approved") {
|
|
|
|
|
// updateTamaraRequestStatus("success", "14", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(widget.selectedInstallmentPlan), appo);
|
|
|
|
|
// } else {
|
|
|
|
|
@ -297,10 +297,10 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
service.getTamaraPaymentStatus(orderID).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (res["status"].toString().toLowerCase() == "success") {
|
|
|
|
|
updateTamaraRequestStatus("success", "14", orderID, tamaraOrderID, num.parse(widget.selectedInstallmentPlan), appo);
|
|
|
|
|
updateTamaraRequestStatus("success", "14", orderID, tamaraOrderID, int.parse(widget.selectedInstallmentPlan!), appo);
|
|
|
|
|
} else {
|
|
|
|
|
updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID != null ? tamaraOrderID : "",
|
|
|
|
|
num.parse(widget.selectedInstallmentPlan), appo);
|
|
|
|
|
updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID!, appo.clinicID!, appo.appointmentNo!), tamaraOrderID != null ? tamaraOrderID : "",
|
|
|
|
|
int.parse(widget.selectedInstallmentPlan!), appo);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
@ -341,7 +341,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
markAppointmentForTamara(AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
service.markAppointmentForTamara(appo.projectID, appo.appointmentNo.toString()).then((res) {
|
|
|
|
|
service.markAppointmentForTamara(appo.projectID!, appo.appointmentNo.toString()).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
getAppoQR(context);
|
|
|
|
|
// autoGenerateInvoiceTamara(appo);
|
|
|
|
|
@ -363,7 +363,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
"AppointmentDate": appo.appointmentDate.toString(),
|
|
|
|
|
};
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
service.autoGenerateInvoiceTamara(appo.projectID, appo.appointmentNo.toString(), projectViewModel.user.mobileNumber).then((res) {
|
|
|
|
|
service.autoGenerateInvoiceTamara(appo.projectID!, appo.appointmentNo.toString(), projectViewModel.user!.mobileNumber!).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
getAppoQR(context);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
@ -376,7 +376,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
checkPaymentStatus(AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
service.checkPaymentStatus(Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), false, context).then((res) {
|
|
|
|
|
service.checkPaymentStatus(Utils.getAppointmentTransID(appo.projectID!, appo.clinicID!, appo.appointmentNo!), false, context).then((res) {
|
|
|
|
|
print("Printing Payment Status Reponse!!!!");
|
|
|
|
|
print(res);
|
|
|
|
|
String paymentInfo = res['Response_Message'];
|
|
|
|
|
@ -403,7 +403,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
String paymentReference = res['Fort_id'].toString();
|
|
|
|
|
service.createAdvancePayment(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], context).then((res) {
|
|
|
|
|
addAdvancedNumberRequest(
|
|
|
|
|
Utils.isVidaPlusProject(projectViewModel, appo.projectID)
|
|
|
|
|
Utils.isVidaPlusProject(projectViewModel, appo.projectID!)
|
|
|
|
|
? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference,
|
|
|
|
|
@ -429,7 +429,7 @@ class _CovidPaymentSummaryState extends State<CovidPaymentSummary> {
|
|
|
|
|
|
|
|
|
|
getAppoQR(context) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
service.generateAppointmentQR(widget.patientShareResponse, context).then((res) {
|
|
|
|
|
service.generateAppointmentQR(widget.patientShareResponse!, context).then((res) {
|
|
|
|
|
print(res);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
navigateToQR(context, res['AppointmentQR']);
|
|
|
|
|
|