merge-requests/34/merge
haroon amjad 6 years ago
parent 28fde5c500
commit 3a9fa97c91

@ -5,7 +5,7 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
const MAX_SMALL_SCREEN = 660;
const BASE_URL = 'https://hmgwebservices.com/Services';
const BASE_URL = 'https://uat.hmgwebservices.com/Services';
const GET_PROJECT = '/Lists.svc/REST/GetProject';
@ -61,6 +61,12 @@ const GENERATE_QR_APPOINTMENT = "/Doctors.svc/REST/GenerateQRAppointmentNo";
//URL send email appointment QR
const EMAIL_QR_APPOINTMENT = "/Notifications.svc/REST/sendEmailForOnLineCheckin";
//URL check payment status
const CHECK_PAYMENT_STATUS = "/PayFort_Serv.svc/REST/GetRequestStatusByRequestID";
//URL create advance payment
const CREATE_ADVANCE_PAYMENT = "/Doctors.svc/REST/CreateAdvancePayment";
//URL to get medicine and pharmacies list
const CHANNEL = 3;
const GENERAL_ID = 'Cs2020@2016\$2958';

@ -40,23 +40,28 @@ class BaseAppClient {
onFailure('Error While Fetching data', statusCode);
} else {
var parsed = json.decode(response.body.toString());
if (!parsed['IsAuthenticated']) {
if (parsed['isSMSSent'] == true) {
onSuccess(parsed, statusCode);
}
// await helpers.logout();
//helpers.showErrorToast('Your session expired Please login agian');
var asd = "";
// TODO create logout fun
} else if (parsed['MessageStatus'] == 1 ||
parsed['SMSLoginRequired'] == true) {
if (parsed['Response_Message'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['SameClinicApptList'] != null) {
if (!parsed['IsAuthenticated']) {
if (parsed['isSMSSent'] == true) {
onSuccess(parsed, statusCode);
}
// await helpers.logout();
//helpers.showErrorToast('Your session expired Please login agian');
var asd = "";
// TODO create logout fun
} else if (parsed['MessageStatus'] == 1 ||
parsed['SMSLoginRequired'] == true) {
onSuccess(parsed, statusCode);
} else {
onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
if (parsed['SameClinicApptList'] != null) {
onSuccess(parsed, statusCode);
} else {
onFailure(
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
}
}
}
}

@ -12,8 +12,9 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.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:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:flutter/material.dart';
import 'package:rating_bar/rating_bar.dart';
@ -21,6 +22,7 @@ class ToDo extends StatefulWidget {
PatientShareResponse patientShareResponse;
List<AppoitmentAllHistoryResultList> appoList = [];
var languageID;
MyInAppBrowser browser;
@override
_ToDoState createState() => _ToDoState();
@ -485,7 +487,9 @@ class _ToDoState extends State<ToDo> {
builder: (context) => QRCode(
patientShareResponse: patientShareResponse,
appoQR: appoQR,
)));
))).then((value) {
getPatientAppointmentHistory();
});
}
openPaymentDialog(AppoitmentAllHistoryResultList appo,
@ -511,13 +515,125 @@ class _ToDoState extends State<ToDo> {
context: context,
pageBuilder: (context, animation1, animation2) {})
.then((value) {
// getPatientAppointmentHistory();
print(value);
if (value != null) {
navigateToPaymentMethod(context, value, 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);
});
}
Future navigateToPaymentMethod(context) async {
createAdvancePayment(res, AppoitmentAllHistoryResultList appo) {
DoctorsListService service = new DoctorsListService();
service
.createAdvancePayment(
appo, res['Amount'], res['Fort_id'], res['PaymentMethod'], context)
.then((res) {
print(res['OnlineCheckInAppointments']);
}).catchError((err) {
print(err);
});
}
Future navigateToPaymentMethod(
context,
PatientShareResponse patientShareResponse,
AppoitmentAllHistoryResultList appo) async {
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(
await this.sharedPref.getObject(USER_PROFILE));
setState(() {
authUser = data;
});
}
Navigator.push(
context, MaterialPageRoute(builder: (context) => PaymentMethod()));
context, MaterialPageRoute(builder: (context) => PaymentMethod()))
.then((value) {
print(value);
getPatientAppointmentHistory();
if (value != null) {
openPayment(
value,
authUser,
double.parse(patientShareResponse.patientShareWithTax.toString()),
patientShareResponse,
appo);
}
});
}
confirmAppointment(AppoitmentAllHistoryResultList appo) {

@ -9,7 +9,7 @@ class PaymentMethod extends StatefulWidget {
}
class _PaymentMethodState extends State<PaymentMethod> {
String selectedPaymentMethod = "mada";
String selectedPaymentMethod = "MADA";
@override
Widget build(BuildContext context) {
@ -40,7 +40,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
child: Container(
child: InkWell(
onTap: () {
updateSelectedPaymentMethod("mada");
updateSelectedPaymentMethod("MADA");
},
child: Card(
elevation: 3.0,
@ -48,7 +48,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: selectedPaymentMethod == "mada"
side: selectedPaymentMethod == "MADA"
? BorderSide(
color: Colors.green, width: 5.0)
: BorderSide(
@ -69,7 +69,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
child: Container(
child: InkWell(
onTap: () {
updateSelectedPaymentMethod("sadad");
updateSelectedPaymentMethod("SADAD");
},
child: Card(
elevation: 3.0,
@ -77,7 +77,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: selectedPaymentMethod == "sadad"
side: selectedPaymentMethod == "SADAD"
? BorderSide(
color: Colors.green, width: 5.0)
: BorderSide(
@ -106,7 +106,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
child: Container(
child: InkWell(
onTap: () {
updateSelectedPaymentMethod("visa");
updateSelectedPaymentMethod("VISA");
},
child: Card(
elevation: 3.0,
@ -114,7 +114,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: selectedPaymentMethod == "visa"
side: selectedPaymentMethod == "VISA"
? BorderSide(
color: Colors.green, width: 5.0)
: BorderSide(
@ -135,7 +135,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
child: Container(
child: InkWell(
onTap: () {
updateSelectedPaymentMethod("mastercard");
updateSelectedPaymentMethod("MASTERCARD");
},
child: Card(
elevation: 3.0,
@ -143,7 +143,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: selectedPaymentMethod == "mastercard"
side: selectedPaymentMethod == "MASTERCARD"
? BorderSide(
color: Colors.green, width: 5.0)
: BorderSide(
@ -172,7 +172,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
child: Container(
child: InkWell(
onTap: () {
updateSelectedPaymentMethod("installment");
updateSelectedPaymentMethod("Installment");
},
child: Card(
elevation: 3.0,
@ -180,7 +180,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: selectedPaymentMethod == "installment"
side: selectedPaymentMethod == "Installment"
? BorderSide(
color: Colors.green, width: 5.0)
: BorderSide(
@ -221,9 +221,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
disabledTextColor: Colors.white,
disabledColor: new Color(0xFFbcc2c4),
onPressed: () {
// navigateToBookSuccess(context);
// insertAppointment(context, widget.doctor);
openPayment();
Navigator.pop(context, selectedPaymentMethod);
},
child: Text(TranslationBase.of(context).confirm,
style: TextStyle(fontSize: 18.0)),
@ -233,16 +231,6 @@ class _PaymentMethodState extends State<PaymentMethod> {
);
}
openPayment() {
MyInAppBrowser browser = new MyInAppBrowser(onExitCallback: onBrowserExit);
browser.openUrl(url: "data:text/html;base64,PGh0bWw+IDxoZWFkPjwvaGVhZD48Ym9keT48Zm9ybSBpZD0icGF5bWVudEZvcm0iIGFjdGlvbj0iaHR0cHM6Ly9obWd3ZWJzZXJ2aWNlcy5jb20vUGF5Rm9ydFdlYkxpdmUvcGFnZXMvU2VuZFBheUZvcnRSZXF1ZXN0LmFzcHgiIG1ldGhvZD0icG9zdCI+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQW1vdW50IiB2YWx1ZT0iMTIyIj48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJQcm9qSUQiIHZhbHVlPSIxMiI+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iT3JkZXJfRGVzYyIgdmFsdWU9IkFkdmFuY2UgUGF5bWVudCI+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iT3JkZXJJRCIgdmFsdWU9IjEyLTEyMzE3NTUtMTU5NjY0MDY0MSI+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGF5bWVudE9wdGlvbiIgdmFsdWU9Ik1BREEiPjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkVtYWlsIiB2YWx1ZT0iVGFtZXIuZmFuYXNoZWhAZ21haWwuY29tIj48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJTZXJ2SUQiIHZhbHVlPSIzIiAgPjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkNoYW5uZWxJRCIgdmFsdWU9IjIiICA+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iTGFuZyIgdmFsdWU9IkVOIiAgPjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IlJldHVyblVSTCIgdmFsdWU9IiIgID48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJDdXN0TmFtZSIgdmFsdWU9IlRBKioqKiIgPjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IlBhdGllbnRPdXRTQSIgdmFsdWU9ImZhbHNlIiA+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iUGF0aWVudFR5cGVJRCIgdmFsdWU9IjEiID48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJEZXZpY2VUb2tlbiIgdmFsdWU9InVuZGVmaW5lZCx1bmRlZmluZWQiID48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJMb25naXR1ZGUiIHZhbHVlPSJ1bmRlZmluZWQiID48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJMYXRpdHVkZSIgdmFsdWU9InVuZGVmaW5lZCIgPjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkxpdmVfU2VydmljZUlEIiB2YWx1ZT0idW5kZWZpbmVkIiA+PGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iQ3VzdElEIiB2YWx1ZT0iMTIzMTc1NSIgID48aW5wdXQgdHlwZT0iaGlkZGVuIiBuYW1lPSJSZXNwb25zZUNvbnRpbnVlVVJMIiB2YWx1ZT0iaHR0cDovL2htZy5jb20vRG9jdW1lbnRzL3N1Y2Nlc3MuaHRtbCIgPjxpbnB1dCB0eXBlPSJoaWRkZW4iIG5hbWU9IkJhY2tDbGlja1VybCIgdmFsdWU9Imh0dHA6Ly9obWcuY29tL0RvY3VtZW50cy9zdWNjZXNzLmh0bWwiID48L2Zvcm0+PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPiBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgicGF5bWVudEZvcm0iKS5zdWJtaXQoKTsgPC9zY3JpcHQ+PC9ib2R5PjwvaHRtbD4=");
}
onBrowserExit() {
print("onBrowserExit Called!!!!");
}
updateSelectedPaymentMethod(String selectedMethod) {
setState(() {
selectedPaymentMethod = selectedMethod;

@ -1,6 +1,5 @@
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart';
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
@ -146,7 +145,7 @@ class _PaymentDialogState extends State<PaymentDialog> {
Expanded(
child: InkWell(
onTap: () {
Navigator.of(context).pop();
Navigator.pop(context, null);
},
child: Container(
child: Text("Cancel",
@ -159,8 +158,8 @@ class _PaymentDialogState extends State<PaymentDialog> {
Expanded(
child: InkWell(
onTap: () {
Navigator.of(context).pop();
widget.onPaymentMethodSelected();
Navigator.pop(context, widget.patientShareResponse);
// widget.onPaymentMethodSelected();
},
child: Container(
child: Text("Ok",

@ -115,7 +115,8 @@ class DoctorsListService extends BaseService {
return Future.value(localRes);
}
Future<Map> getDoctorsProfile(int docID, int clinicID, int projectID, context) async {
Future<Map> getDoctorsProfile(
int docID, int clinicID, int projectID, context) async {
Utils.showProgressDialog(context);
Map<String, dynamic> request;
var languageID = await sharedPref.getString(APP_LANGUAGE);
@ -146,7 +147,7 @@ class DoctorsListService extends BaseService {
localRes = response;
Utils.hideProgressDialog();
}, onFailure: (String error, int statusCode) {
Utils.hideProgressDialog();
Utils.hideProgressDialog();
throw error;
}, body: request);
return Future.value(localRes);
@ -575,4 +576,94 @@ class DoctorsListService extends BaseService {
}, body: request);
return Future.value(localRes);
}
Future<Map> checkPaymentStatus(
String transactionID, BuildContext context) async {
Map<String, dynamic> request;
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(
await this.sharedPref.getObject(USER_PROFILE));
authUser = data;
}
var languageID = await sharedPref.getString(APP_LANGUAGE);
Request req = appGlobal.getPublicRequest();
request = {
"ClientRequestID": transactionID,
"VersionID": req.VersionID,
"Channel": req.Channel,
"LanguageID": languageID == 'ar' ? 1 : 2,
"IPAdress": req.IPAdress,
"generalid": req.generalid,
"PatientOutSA": authUser.outSA,
"SessionID": "YckwoXhUmWBsnHKEKig",
"isDentalAllowedBackend": false,
"DeviceTypeID": req.DeviceTypeID,
"PatientID": authUser.patientID,
"TokenID": "@dm!n",
"PatientTypeID": authUser.patientType,
"PatientType": authUser.patientType
};
dynamic localRes;
await baseAppClient.post(CHECK_PAYMENT_STATUS,
onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: request);
return Future.value(localRes);
}
Future<Map> createAdvancePayment(
AppoitmentAllHistoryResultList appo,
double payedAmount,
String paymentReference,
String paymentMethodName,
BuildContext context) async {
Utils.showProgressDialog(context);
Map<String, dynamic> request;
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(
await this.sharedPref.getObject(USER_PROFILE));
authUser = data;
}
var languageID = await sharedPref.getString(APP_LANGUAGE);
Request req = appGlobal.getPublicRequest();
request = {
"ProjectID": appo.projectID.toString(),
"OnlineCheckInAppointment": {
"AppointmentNo": appo.appointmentNo.toString(),
"PaymentMethodName": paymentMethodName,
"PaymentAmount": payedAmount == 0 ? "0" : payedAmount.toString(),
"PaymentDate": payedAmount == 0 ? "" : "/Date(" + DateTime.now().millisecondsSinceEpoch.toString() + ")/",
"PaymentReferenceNumber": payedAmount == 0 ? "" : paymentReference,
"ProjectID": appo.projectID.toString(),
"PatientID": authUser.patientID,
"ClinicID": appo.clinicID,
"UserID": authUser.patientID,
"Status": authUser.patientType
},
"VersionID": req.VersionID,
"Channel": req.Channel,
"LanguageID": languageID == 'ar' ? 1 : 2,
"IPAdress": req.IPAdress,
"generalid": req.generalid,
"PatientOutSA": authUser.outSA,
"SessionID": "YckwoXhUmWBsnHKEKig",
"isDentalAllowedBackend": false,
"PatientID": authUser.patientID,
"TokenID": "@dm!n",
"PatientTypeID": authUser.patientType,
"PatientType": authUser.patientType
};
dynamic localRes;
await baseAppClient.post(CREATE_ADVANCE_PAYMENT,
onSuccess: (response, statusCode) async {
localRes = response;
Utils.hideProgressDialog();
}, onFailure: (String error, int statusCode) {
Utils.hideProgressDialog();
throw error;
}, body: request);
return Future.value(localRes);
}
}

@ -1,4 +1,5 @@
import 'package:connectivity/connectivity.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:progress_dialog/progress_dialog.dart';
@ -89,6 +90,14 @@ class Utils {
}
}
static String getAppointmentTransID(int projectID, int clinicID, int appoNo) {
return projectID.toString() +
'-' +
clinicID.toString() +
'-' +
appoNo.toString();
}
bool validateIDBox(String value, type) {
Pattern pattern = loginIDPattern(type); //r'^\d+(?:\.\d+)?$';

@ -1,20 +1,25 @@
import 'dart:convert';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
class MyInAppBrowser extends InAppBrowser {
// static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT
// ignore: non_constant_identifier_names
static String SERVICE_URL =
'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE
'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT
// ignore: non_constant_identifier_names
// static String SERVICE_URL =
// 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE
// static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT
static String PREAUTH_SERVICE_URL =
'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store
'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT
// static String PREAUTH_SERVICE_URL =
// 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store
static List<String> successURLS = [
'success',
@ -25,13 +30,18 @@ class MyInAppBrowser extends InAppBrowser {
static List<String> errorURLS = ['PayfortCancel'];
final Function onExitCallback;
final Function onLoadStartCallback;
AppSharedPreferences sharedPref = AppSharedPreferences();
AuthProvider authProvider = new AuthProvider();
InAppBrowser browser = new InAppBrowser();
AuthenticatedUser authUser;
AppoitmentAllHistoryResultList appo;
MyInAppBrowser({this.onExitCallback});
static bool isPaymentDone = false;
MyInAppBrowser({this.onExitCallback, this.appo, this.onLoadStartCallback});
Future onBrowserCreated() async {
print("\n\nBrowser Created!\n\n");
@ -39,7 +49,42 @@ class MyInAppBrowser extends InAppBrowser {
@override
Future onLoadStart(String url) async {
print("\n\nStarted $url\n\n");
onLoadStartCallback(url);
// print("\n\nStarted $url\n\n");
// if (successURLS.length != 0) {
// successURLS.forEach((element) {
// if (url.contains(element)) {
// try {
// if (browser.isOpened()) browser.close();
// isPaymentDone = true;
// Utils.hideProgressDialog();
// return;
// } on MissingPluginException catch (exception) {
// Utils.hideProgressDialog();
// } catch (error) {
// Utils.hideProgressDialog();
// }
// }
// });
// }
//
// if (errorURLS.length != 0) {
// errorURLS.forEach((element) {
// if (url.contains(element)) {
// try {
// if (browser.isOpened()) browser.close();
// isPaymentDone = false;
// Utils.hideProgressDialog();
// return;
// } on MissingPluginException catch (exception) {
// Utils.hideProgressDialog();
// } catch (error) {
// Utils.hideProgressDialog();
// }
// }
// });
// }
}
@override
@ -60,7 +105,7 @@ class MyInAppBrowser extends InAppBrowser {
@override
void onExit() {
print("\n\nBrowser closed!\n\n");
onExitCallback();
onExitCallback(appo, isPaymentDone);
}
@override
@ -70,31 +115,13 @@ class MyInAppBrowser extends InAppBrowser {
return ShouldOverrideUrlLoadingAction.ALLOW;
}
@override
void onLoadResource(LoadedResource response) {
print("Started at: " +
response.startTime.toString() +
"ms ---> duration: " +
response.duration.toString() +
"ms " +
response.url);
}
@override
void onConsoleMessage(ConsoleMessage consoleMessage) {
print("""
console output:
message: ${consoleMessage.message}
messageLevel: ${consoleMessage.messageLevel.toValue()}
""");
}
getLanguageID() async {
return await sharedPref.getString(APP_LANGUAGE);
}
getDeviceToken() async {
await sharedPref.getString(PUSH_TOKEN);
Future<String> getDeviceToken() async {
String deviceToken = await sharedPref.getString(PUSH_TOKEN);
return deviceToken;
}
getPatientData() async {
@ -105,12 +132,48 @@ class MyInAppBrowser extends InAppBrowser {
}
}
String generateURL(int amount, String orderDesc, String transactionID,
String projId, String emailId, String paymentMethod,
[var patientData, var servID, var LiveServID]) {
openPaymentBrowser(
double amount,
String orderDesc,
String transactionID,
String projId,
String emailId,
String paymentMethod,
AuthenticatedUser authenticatedUser,
InAppBrowser browser,
) {
this.browser = browser;
this.browser.openUrl(
url: generateURL(amount, orderDesc, transactionID, projId, emailId,
paymentMethod, authenticatedUser));
// this.browser.openData(
// data: generateURL(amount, orderDesc, transactionID, projId, emailId,
// paymentMethod, authenticatedUser),
// baseUrl:
// "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx");
}
String generateURL(
double amount,
String orderDesc,
String transactionID,
String projId,
String emailId,
String paymentMethod,
AuthenticatedUser authUser,
[var patientData,
var servID,
var LiveServID]) {
getPatientData();
String currentLanguageID = getLanguageID() == 'ar' ? 'AR' : 'EN';
String form = getForm();
String deviceToken;
getDeviceToken().then((value) {
print(value);
deviceToken = value;
});
if (authUser != null) {
form = form.replaceFirst("EMAIL_VALUE", authUser.emailAddress);
@ -125,9 +188,13 @@ class MyInAppBrowser extends InAppBrowser {
form = form.replaceFirst('PROJECT_ID_VALUE', projId);
form = form.replaceFirst('PAYMENT_OPTION_VALUE', paymentMethod);
form = form.replaceFirst('LANG_VALUE', currentLanguageID);
form = form.replaceFirst('PATIENT_OUT_SA', authUser.outSA.toString());
form = form.replaceFirst('PATIENT_TYPE_ID',
patientData == "" ? authUser.patientType : patientData.PatientType);
form = form.replaceFirst('PATIENT_OUT_SA',
authUser.outSA == 0 ? false.toString() : true.toString());
form = form.replaceFirst(
'PATIENT_TYPE_ID',
patientData == null
? authUser.patientType.toString()
: patientData.PatientType);
// form = form.replaceFirst('DEVICE_TOKEN', this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false) + "," + this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false));
// form = form.replaceFirst('LATITUDE_VALUE', this.cs.sharedService.getSharedData('userLat', false));
@ -135,7 +202,8 @@ class MyInAppBrowser extends InAppBrowser {
form = form.replaceFirst('LATITUDE_VALUE', "24.708488");
form = form.replaceFirst('LONGITUDE_VALUE', "46.665925");
form = form.replaceFirst('DEVICE_TOKEN', getDeviceToken());
form = form.replaceFirst('DEVICE_TOKEN',
"e8wKxa4EGK8:APA91bGtygxh5E22pSARVKlngyi0iQbyRUvvUWiCIsaAcbE0hiffhUR094WVx22O5bsvwc706LspzIuJthUyK_748jzuaedD-ZwDm9BX_yyYV2K2YnuFBlHQ9pOKy65RfoprtvqyTN1O");
if (servID == "4")
form = form.replaceFirst(
@ -143,7 +211,7 @@ class MyInAppBrowser extends InAppBrowser {
else
form = form.replaceFirst('SERVICE_URL_VALUE', MyInAppBrowser.SERVICE_URL);
if (servID) {
if (servID != null) {
form = form.replaceFirst('SERV_ID', servID);
form = form.replaceFirst('LIVE_SERVICE_ID', LiveServID);
} else {
@ -151,7 +219,7 @@ class MyInAppBrowser extends InAppBrowser {
form = form.replaceFirst('LIVE_SERVICE_ID', "2");
}
if (!patientData) {
if (patientData == null) {
form = form.replaceFirst('CUSTNAME_VALUE', authUser.firstName);
form = form.replaceFirst('CUSTID_VALUE', authUser.patientID.toString());
} else {
@ -159,13 +227,11 @@ class MyInAppBrowser extends InAppBrowser {
form = form.replaceFirst('CUSTID_VALUE', patientData.PatientID);
}
Codec<String, String> stringToBase64Url = utf8.fuse(base64Url);
String encoded = stringToBase64Url
.encode('data:text/html;base64,' + form); // dXNlcm5hbWU6cGFzc3dvcmQ=
String decoded = stringToBase64Url.decode(encoded); // username:password
var bytes = utf8.encode(form);
var base64Str = base64.encode(bytes);
print(form);
print(encoded);
return encoded;
print('data:text/html;base64,' + base64Str);
return 'data:text/html;base64,' + base64Str;
}
String getForm() {

Loading…
Cancel
Save