Advance payment API updates

merge-update-with-lab-changes
haroon amjad 5 years ago
parent 1fa6a4409b
commit 6c4afaf114

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

Loading…
Cancel
Save