|
|
|
|
@ -17,42 +17,74 @@ import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
|
|
|
|
|
import 'dialogs/ConfirmSMSDialog.dart';
|
|
|
|
|
import 'new_text_Field.dart';
|
|
|
|
|
|
|
|
|
|
class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
class ConfirmPaymentPage extends StatefulWidget {
|
|
|
|
|
final AdvanceModel advanceModel;
|
|
|
|
|
final PatientInfoAndMobileNumber patientInfoAndMobileNumber;
|
|
|
|
|
final String selectedPaymentMethod;
|
|
|
|
|
MyInAppBrowser browser;
|
|
|
|
|
AuthenticatedUser authenticatedUser;
|
|
|
|
|
|
|
|
|
|
ConfirmPaymentPage({this.advanceModel, this.patientInfoAndMobileNumber, this.selectedPaymentMethod, this.authenticatedUser});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ConfirmPaymentPageState createState() => _ConfirmPaymentPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|
|
|
|
MyInAppBrowser browser;
|
|
|
|
|
|
|
|
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
|
|
|
|
|
|
String transID = "";
|
|
|
|
|
|
|
|
|
|
ConfirmPaymentPage({this.advanceModel, this.patientInfoAndMobileNumber, this.selectedPaymentMethod, this.authenticatedUser});
|
|
|
|
|
void submit(MyBalanceViewModel model, code) {
|
|
|
|
|
final activationCode = code;
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
|
|
|
|
|
model.checkActivationCodeForAdvancePayment(activationCode: activationCode).then((value) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
|
|
|
|
|
Navigator.pop(context, true);
|
|
|
|
|
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
appo.projectID = widget.patientInfoAndMobileNumber.projectID;
|
|
|
|
|
openPayment(widget.selectedPaymentMethod, widget.authenticatedUser, double.parse(widget.advanceModel.amount), null);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
void showSMSDialog() {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
child: ConfirmSMSDialog(
|
|
|
|
|
phoneNumber: patientInfoAndMobileNumber.mobileNumber,
|
|
|
|
|
),
|
|
|
|
|
).then((value) {
|
|
|
|
|
print("dialog dismissed");
|
|
|
|
|
print(value);
|
|
|
|
|
if (value != null && value) {
|
|
|
|
|
AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
appo.projectID = patientInfoAndMobileNumber.projectID;
|
|
|
|
|
openPayment(selectedPaymentMethod, authenticatedUser, double.parse(advanceModel.amount), null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
void showSMSDialog(MyBalanceViewModel model) {
|
|
|
|
|
new SMSOTP(
|
|
|
|
|
context,
|
|
|
|
|
1,
|
|
|
|
|
widget.patientInfoAndMobileNumber.mobileNumber,
|
|
|
|
|
(value) {
|
|
|
|
|
submit(model, value);
|
|
|
|
|
},
|
|
|
|
|
() => {
|
|
|
|
|
Navigator.pop(context),
|
|
|
|
|
},
|
|
|
|
|
).displayDialog(context);
|
|
|
|
|
|
|
|
|
|
// showDialog(
|
|
|
|
|
// context: context,
|
|
|
|
|
// barrierDismissible: false,
|
|
|
|
|
// child: ConfirmSMSDialog(
|
|
|
|
|
// phoneNumber: patientInfoAndMobileNumber.mobileNumber,
|
|
|
|
|
// ),
|
|
|
|
|
// ).then((value) {
|
|
|
|
|
// print("dialog dismissed");
|
|
|
|
|
// print(value);
|
|
|
|
|
// if (value != null && value) {
|
|
|
|
|
// AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList();
|
|
|
|
|
// appo.projectID = patientInfoAndMobileNumber.projectID;
|
|
|
|
|
// openPayment(selectedPaymentMethod, authenticatedUser, double.parse(advanceModel.amount), null);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return BaseView<MyBalanceViewModel>(
|
|
|
|
|
@ -88,10 +120,10 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
height: 100.0,
|
|
|
|
|
padding: EdgeInsets.all(7.0),
|
|
|
|
|
width: MediaQuery.of(context).size.width * 0.45,
|
|
|
|
|
child: selectedPaymentMethod == "ApplePay" ? SvgPicture.asset(getImagePath(selectedPaymentMethod)) : Image.asset(getImagePath(selectedPaymentMethod)),
|
|
|
|
|
child: widget.selectedPaymentMethod == "ApplePay" ? SvgPicture.asset(getImagePath(widget.selectedPaymentMethod)) : Image.asset(getImagePath(widget.selectedPaymentMethod)),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
'${advanceModel.amount} SAR',
|
|
|
|
|
'${widget.advanceModel.amount} SAR',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
|
@ -110,7 +142,7 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
margin: EdgeInsets.all(3),
|
|
|
|
|
child: NewTextFields(
|
|
|
|
|
hintText: TranslationBase.of(context).fileNumber,
|
|
|
|
|
initialValue: advanceModel.fileNumber,
|
|
|
|
|
initialValue: widget.advanceModel.fileNumber,
|
|
|
|
|
isEnabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -120,7 +152,7 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
margin: EdgeInsets.all(3),
|
|
|
|
|
child: NewTextFields(
|
|
|
|
|
hintText: TranslationBase.of(context).name,
|
|
|
|
|
initialValue: patientInfoAndMobileNumber.firstName,
|
|
|
|
|
initialValue: widget.patientInfoAndMobileNumber.firstName,
|
|
|
|
|
isEnabled: false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -132,7 +164,7 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
NewTextFields(
|
|
|
|
|
hintText: TranslationBase.of(context).mobileNumber,
|
|
|
|
|
initialValue: patientInfoAndMobileNumber.mobileNumber,
|
|
|
|
|
initialValue: widget.patientInfoAndMobileNumber.mobileNumber,
|
|
|
|
|
isEnabled: false,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
@ -148,7 +180,7 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
NewTextFields(
|
|
|
|
|
hintText: TranslationBase.of(context).notes,
|
|
|
|
|
initialValue: advanceModel.note,
|
|
|
|
|
initialValue: widget.advanceModel.note,
|
|
|
|
|
isEnabled: false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -168,9 +200,9 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
disabled: model.state == ViewState.Busy,
|
|
|
|
|
onTap: () {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
model.sendActivationCodeForAdvancePayment(patientID: int.parse(advanceModel.fileNumber), projectID: advanceModel.hospitalsModel.iD).then((value) {
|
|
|
|
|
model.sendActivationCodeForAdvancePayment(patientID: int.parse(widget.advanceModel.fileNumber), projectID: widget.advanceModel.hospitalsModel.iD).then((value) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (model.state != ViewState.ErrorLocal && model.state != ViewState.Error) showSMSDialog();
|
|
|
|
|
if (model.state != ViewState.ErrorLocal && model.state != ViewState.Error) showSMSDialog(model);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
@ -208,10 +240,10 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, double amount, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart);
|
|
|
|
|
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(advanceModel.hospitalsModel.iD, int.parse(advanceModel.fileNumber));
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber));
|
|
|
|
|
|
|
|
|
|
browser.openPaymentBrowser(amount, "Advance Payment", transID, advanceModel.hospitalsModel.iD.toString(), advanceModel.email, paymentMethod, patientInfoAndMobileNumber.patientType,
|
|
|
|
|
advanceModel.patientName, advanceModel.fileNumber, authenticatedUser, browser, false, "3", "");
|
|
|
|
|
browser.openPaymentBrowser(amount, "Advance Payment", transID, widget.advanceModel.hospitalsModel.iD.toString(), widget.advanceModel.email, paymentMethod,
|
|
|
|
|
widget.patientInfoAndMobileNumber.patientType, widget.advanceModel.patientName, widget.advanceModel.fileNumber, authenticatedUser, browser, false, "3", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBrowserLoadStart(String url) {
|
|
|
|
|
@ -263,8 +295,8 @@ class ConfirmPaymentPage extends StatelessWidget {
|
|
|
|
|
createAdvancePayment(res, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
String paymentReference = res['Fort_id'].toString();
|
|
|
|
|
service.HIS_createAdvancePayment(appo, advanceModel.hospitalsModel.iD.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], patientInfoAndMobileNumber.patientType,
|
|
|
|
|
advanceModel.patientName, advanceModel.fileNumber, AppGlobal.context)
|
|
|
|
|
service.HIS_createAdvancePayment(appo, widget.advanceModel.hospitalsModel.iD.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], widget.patientInfoAndMobileNumber.patientType,
|
|
|
|
|
widget.advanceModel.patientName, widget.advanceModel.fileNumber, AppGlobal.context)
|
|
|
|
|
.then((res) {
|
|
|
|
|
print(res['OnlineCheckInAppointments'][0]['AdvanceNumber']);
|
|
|
|
|
addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, 0, appo);
|
|
|
|
|
|