|
|
|
@ -1,8 +1,16 @@
|
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/routes.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'QRCode.dart';
|
|
|
|
@ -11,6 +19,8 @@ class BookSuccess extends StatefulWidget {
|
|
|
|
|
PatientShareResponse patientShareResponse;
|
|
|
|
|
DoctorList docObject;
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser browser;
|
|
|
|
|
|
|
|
|
|
String appoDateFormatted;
|
|
|
|
|
String appoTimeFormatted;
|
|
|
|
|
|
|
|
|
@ -25,6 +35,9 @@ class BookSuccess extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _BookSuccessState extends State<BookSuccess> {
|
|
|
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
|
AuthenticatedUser authUser;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
// TODO: implement initState
|
|
|
|
@ -34,12 +47,6 @@ class _BookSuccessState extends State<BookSuccess> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
// appBar: AppBar(
|
|
|
|
|
// title: Text("Book Success"),
|
|
|
|
|
// bottomOpacity: 0.0,
|
|
|
|
|
// elevation: 0.0,
|
|
|
|
|
// backgroundColor: new Color(0xFF20bc44),
|
|
|
|
|
// ),
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
@ -320,12 +327,15 @@ class _BookSuccessState extends State<BookSuccess> {
|
|
|
|
|
margin: EdgeInsets.only(top: 20.0, bottom: 0.0),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Text(TranslationBase.of(context).payNowBookSuccess,
|
|
|
|
|
style: TextStyle(fontSize: 20.0, letterSpacing: 0.8, fontWeight: FontWeight.bold)),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 20.0,
|
|
|
|
|
letterSpacing: 0.8,
|
|
|
|
|
fontWeight: FontWeight.bold)),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Image.asset("assets/images/new-design/no-wait-queue.png", width: 120.0,
|
|
|
|
|
height: 120.0),
|
|
|
|
|
child: Image.asset("assets/images/new-design/no-wait-queue.png",
|
|
|
|
|
width: 120.0, height: 120.0),
|
|
|
|
|
),
|
|
|
|
|
Flex(
|
|
|
|
|
direction: Axis.horizontal,
|
|
|
|
@ -396,7 +406,9 @@ class _BookSuccessState extends State<BookSuccess> {
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
disabledTextColor: Colors.white,
|
|
|
|
|
disabledColor: new Color(0xFFbcc2c4),
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
onPressed: () {
|
|
|
|
|
startPaymentProcess();
|
|
|
|
|
},
|
|
|
|
|
child: Text(TranslationBase.of(context).payNow.toUpperCase(),
|
|
|
|
|
style: TextStyle(fontSize: 18.0)),
|
|
|
|
|
),
|
|
|
|
@ -427,6 +439,154 @@ class _BookSuccessState extends State<BookSuccess> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startPaymentProcess() {
|
|
|
|
|
navigateToPaymentMethod(context, widget.patientShareResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future navigateToPaymentMethod(
|
|
|
|
|
context, PatientShareResponse patientShareResponse) async {
|
|
|
|
|
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
|
|
|
|
|
var data = AuthenticatedUser.fromJson(
|
|
|
|
|
await this.sharedPref.getObject(USER_PROFILE));
|
|
|
|
|
setState(() {
|
|
|
|
|
authUser = data;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
appo.projectID = widget.patientShareResponse.projectID;
|
|
|
|
|
appo.clinicID = widget.patientShareResponse.clinicID;
|
|
|
|
|
appo.appointmentNo = widget.patientShareResponse.appointmentNo;
|
|
|
|
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context, MaterialPageRoute(builder: (context) => PaymentMethod()))
|
|
|
|
|
.then((value) {
|
|
|
|
|
print(value);
|
|
|
|
|
if (value != null) {
|
|
|
|
|
openPayment(
|
|
|
|
|
value,
|
|
|
|
|
authUser,
|
|
|
|
|
double.parse(patientShareResponse.patientShareWithTax.toString()),
|
|
|
|
|
patientShareResponse,
|
|
|
|
|
appo);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPayment(
|
|
|
|
|
String paymentMethod,
|
|
|
|
|
AuthenticatedUser authenticatedUser,
|
|
|
|
|
double amount,
|
|
|
|
|
PatientShareResponse patientShareResponse,
|
|
|
|
|
AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
widget.browser = new MyInAppBrowser(
|
|
|
|
|
onExitCallback: onBrowserExit,
|
|
|
|
|
appo: appo,
|
|
|
|
|
onLoadStartCallback: onBrowserLoadStart);
|
|
|
|
|
|
|
|
|
|
widget.browser.openPaymentBrowser(
|
|
|
|
|
amount,
|
|
|
|
|
"Appointment check in",
|
|
|
|
|
Utils.getAppointmentTransID(
|
|
|
|
|
appo.projectID, appo.clinicID, appo.appointmentNo),
|
|
|
|
|
appo.projectID.toString(),
|
|
|
|
|
authenticatedUser.emailAddress,
|
|
|
|
|
paymentMethod,
|
|
|
|
|
authenticatedUser,
|
|
|
|
|
widget.browser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserLoadStart(String url) {
|
|
|
|
|
print("onBrowserLoadStart");
|
|
|
|
|
print(url);
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser.successURLS.forEach((element) {
|
|
|
|
|
if (url.contains(element)) {
|
|
|
|
|
if (widget.browser.isOpened()) widget.browser.close();
|
|
|
|
|
MyInAppBrowser.isPaymentDone = true;
|
|
|
|
|
Utils.hideProgressDialog();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MyInAppBrowser.errorURLS.forEach((element) {
|
|
|
|
|
if (url.contains(element)) {
|
|
|
|
|
if (widget.browser.isOpened()) widget.browser.close();
|
|
|
|
|
MyInAppBrowser.isPaymentDone = false;
|
|
|
|
|
Utils.hideProgressDialog();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) {
|
|
|
|
|
print("onBrowserExit Called!!!!");
|
|
|
|
|
if (isPaymentMade) checkPaymentStatus(appo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkPaymentStatus(AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
service
|
|
|
|
|
.checkPaymentStatus(
|
|
|
|
|
Utils.getAppointmentTransID(
|
|
|
|
|
appo.projectID, appo.clinicID, appo.appointmentNo),
|
|
|
|
|
context)
|
|
|
|
|
.then((res) {
|
|
|
|
|
print("Printing Payment Status Reponse!!!!");
|
|
|
|
|
print(res);
|
|
|
|
|
String paymentInfo = res['Response_Message'];
|
|
|
|
|
if (paymentInfo == 'Success') {
|
|
|
|
|
createAdvancePayment(res, appo);
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: res['Response_Message']);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createAdvancePayment(res, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
String paymentReference = res['Fort_id'].toString();
|
|
|
|
|
service
|
|
|
|
|
.createAdvancePayment(
|
|
|
|
|
appo, res['Amount'], res['Fort_id'], res['PaymentMethod'], context)
|
|
|
|
|
.then((res) {
|
|
|
|
|
print(res['OnlineCheckInAppointments'][0]['AdvanceNumber']);
|
|
|
|
|
addAdvancedNumberRequest(
|
|
|
|
|
res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference,
|
|
|
|
|
appo.appointmentNo.toString());
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// Future navigateToQR(
|
|
|
|
|
// context, String appoQR, PatientShareResponse patientShareResponse) async {
|
|
|
|
|
// Navigator.push(
|
|
|
|
|
// context,
|
|
|
|
|
// MaterialPageRoute(
|
|
|
|
|
// builder: (context) => QRCode(
|
|
|
|
|
// patientShareResponse: patientShareResponse,
|
|
|
|
|
// appoQR: appoQR,
|
|
|
|
|
// ))).then((value) {});
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
addAdvancedNumberRequest(String advanceNumber, String paymentReference,
|
|
|
|
|
String appointmentID) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
service
|
|
|
|
|
.addAdvancedNumberRequest(
|
|
|
|
|
advanceNumber, paymentReference, appointmentID, context)
|
|
|
|
|
.then((res) {
|
|
|
|
|
print(res);
|
|
|
|
|
getAppoQR(context);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _getQRAppo() {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
@ -440,8 +600,8 @@ class _BookSuccessState extends State<BookSuccess> {
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Image.asset("assets/images/new-design/device_icon.png", width: 120.0,
|
|
|
|
|
height: 120.0),
|
|
|
|
|
child: Image.asset("assets/images/new-design/device_icon.png",
|
|
|
|
|
width: 120.0, height: 120.0),
|
|
|
|
|
),
|
|
|
|
|
Flex(
|
|
|
|
|
direction: Axis.horizontal,
|
|
|
|
|