|
|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/enum/PayfortEnums.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/LiveCare/ERAppointmentFeesResponse.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/LiveCare/LiveCareClinicsListResponse.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/LiveCare/LiveCareScheduleClinicsListResponse.dart';
|
|
|
|
|
@ -18,6 +22,8 @@ import 'package:diplomaticquarterapp/pages/livecare/widgets/clinic_card.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/payfort_services/payfort_project_details_resp_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/payfort_services/payfort_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
@ -296,7 +302,8 @@ class _clinic_listState extends State<ClinicList> {
|
|
|
|
|
|
|
|
|
|
appo.clinicID = selectedClinicID;
|
|
|
|
|
appo.appointmentNo = DateTime.now().millisecondsSinceEpoch;
|
|
|
|
|
appo.projectID = 12;
|
|
|
|
|
appo.projectID = BASE_URL.contains("uat.") ? 15 : 12;
|
|
|
|
|
appo.isLiveCareAppointment = false;
|
|
|
|
|
|
|
|
|
|
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
|
|
|
|
|
var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE));
|
|
|
|
|
@ -318,16 +325,100 @@ class _clinic_listState extends State<ClinicList> {
|
|
|
|
|
patientShare: num.parse(getERAppointmentFeesList.total),
|
|
|
|
|
isFromAdvancePayment: widget.isPharmacyLiveCare,
|
|
|
|
|
))).then((value) {
|
|
|
|
|
selectedPaymentMethod = value[0];
|
|
|
|
|
print(value);
|
|
|
|
|
widget.isPharmacyLiveCare = isPharmacyLiveCare;
|
|
|
|
|
widget.pharmacyLiveCareQRCode = pharmaLiveCareQRCodeValue;
|
|
|
|
|
if (value != null) {
|
|
|
|
|
openPayment(value, authUser, num.parse(getERAppointmentFeesList.total), appo);
|
|
|
|
|
if (selectedPaymentMethod == "ApplePay") {
|
|
|
|
|
startApplePay(appo, getERAppointmentFeesList.total);
|
|
|
|
|
} else {
|
|
|
|
|
openPayment(value, authUser, num.parse(getERAppointmentFeesList.total), appo);
|
|
|
|
|
}
|
|
|
|
|
projectViewModel.analytics.liveCare.payment_method(appointment_type: 'livecare', clinic: selectedClinicName, payment_method: value[0], payment_type: 'appointment');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void startApplePay(AppoitmentAllHistoryResultList appo, String amount) async {
|
|
|
|
|
String transID = Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo);
|
|
|
|
|
print("TransactionID: $transID");
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
LiveCareService service = new LiveCareService();
|
|
|
|
|
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
|
|
|
|
|
|
|
|
|
|
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
|
|
|
|
|
await context.read<PayfortViewModel>().getProjectDetailsForPayfort(projectId: appo.projectID, serviceId: ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum(), languageID: projectViewModel.isArabic ? 1 : 2).then((value) {
|
|
|
|
|
payfortProjectDetailsRespModel = value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
applePayInsertRequest.clientRequestID = transID;
|
|
|
|
|
applePayInsertRequest.clinicID = appo.clinicID;
|
|
|
|
|
applePayInsertRequest.currency = projectViewModel.authenticatedUserObject.user.outSA == 1 ? "AED" : "SAR";
|
|
|
|
|
applePayInsertRequest.customerEmail = projectViewModel.authenticatedUserObject.user.emailAddress;
|
|
|
|
|
applePayInsertRequest.customerID = projectViewModel.authenticatedUserObject.user.patientID;
|
|
|
|
|
applePayInsertRequest.customerName = projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName;
|
|
|
|
|
applePayInsertRequest.deviceToken = await AppSharedPreferences().getString(PUSH_TOKEN);
|
|
|
|
|
applePayInsertRequest.voipToken = await AppSharedPreferences().getString(ONESIGNAL_APNS_TOKEN);
|
|
|
|
|
applePayInsertRequest.doctorID = appo.doctorID;
|
|
|
|
|
applePayInsertRequest.projectID = appo.projectID.toString();
|
|
|
|
|
applePayInsertRequest.serviceID = ServiceTypeEnum.liveCareAppointment.getIdFromServiceEnum().toString();
|
|
|
|
|
applePayInsertRequest.channelID = 3;
|
|
|
|
|
applePayInsertRequest.patientID = projectViewModel.authenticatedUserObject.user.patientID;
|
|
|
|
|
applePayInsertRequest.patientTypeID = projectViewModel.authenticatedUserObject.user.patientType;
|
|
|
|
|
applePayInsertRequest.patientOutSA = projectViewModel.authenticatedUserObject.user.outSA;
|
|
|
|
|
applePayInsertRequest.appointmentDate = appo.appointmentDate;
|
|
|
|
|
applePayInsertRequest.appointmentNo = appo.appointmentNo;
|
|
|
|
|
applePayInsertRequest.orderDescription = "LiveCare Payment";
|
|
|
|
|
applePayInsertRequest.liveServiceID = "0";
|
|
|
|
|
applePayInsertRequest.latitude = "0.0";
|
|
|
|
|
applePayInsertRequest.longitude = "0.0";
|
|
|
|
|
applePayInsertRequest.amount = amount;
|
|
|
|
|
applePayInsertRequest.isSchedule = appo.isLiveCareAppointment ? "1" : "0";
|
|
|
|
|
applePayInsertRequest.language = projectViewModel.isArabic ? 'ar' : 'en';
|
|
|
|
|
applePayInsertRequest.userName = projectViewModel.authenticatedUserObject.user.patientID;
|
|
|
|
|
applePayInsertRequest.responseContinueURL = "http://hmg.com/Documents/success.html";
|
|
|
|
|
applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html";
|
|
|
|
|
applePayInsertRequest.paymentOption = "ApplePay";
|
|
|
|
|
|
|
|
|
|
applePayInsertRequest.isMobSDK = true;
|
|
|
|
|
applePayInsertRequest.merchantReference = transID;
|
|
|
|
|
applePayInsertRequest.merchantIdentifier = payfortProjectDetailsRespModel.merchantIdentifier;
|
|
|
|
|
applePayInsertRequest.commandType = "PURCHASE";
|
|
|
|
|
applePayInsertRequest.signature = payfortProjectDetailsRespModel.signature;
|
|
|
|
|
applePayInsertRequest.accessCode = payfortProjectDetailsRespModel.accessCode;
|
|
|
|
|
applePayInsertRequest.shaRequestPhrase = payfortProjectDetailsRespModel.shaRequest;
|
|
|
|
|
applePayInsertRequest.shaResponsePhrase = payfortProjectDetailsRespModel.shaResponse;
|
|
|
|
|
applePayInsertRequest.returnURL = "";
|
|
|
|
|
|
|
|
|
|
service.applePayInsertRequest(applePayInsertRequest, context).then((res) async {
|
|
|
|
|
await context.read<PayfortViewModel>().initiateApplePayWithPayfort(
|
|
|
|
|
customerName: projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName,
|
|
|
|
|
customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
|
|
|
|
orderDescription: "LiveCare Payment",
|
|
|
|
|
orderAmount: double.parse(amount),
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
|
|
|
|
|
onFailed: (failureResult) async {
|
|
|
|
|
log("failureResult: ${failureResult.toString()}");
|
|
|
|
|
AppToast.showErrorToast(message: failureResult.toString());
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (successResult) async {
|
|
|
|
|
log("Payfort: ${successResult.responseMessage}");
|
|
|
|
|
await context.read<PayfortViewModel>().addPayfortApplePayResponse(result: successResult);
|
|
|
|
|
checkPaymentStatus(appo);
|
|
|
|
|
},
|
|
|
|
|
projectId: appo.projectID,
|
|
|
|
|
serviceTypeEnum: ServiceTypeEnum.appointmentPayment,
|
|
|
|
|
);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPayment(List<String> paymentMethod, AuthenticatedUser authenticatedUser, num amount, AppoitmentAllHistoryResultList appo) {
|
|
|
|
|
browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart, context: context);
|
|
|
|
|
|
|
|
|
|
|