|
|
|
|
@ -221,85 +221,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|
|
|
|
() async {
|
|
|
|
|
if (widget.advanceModel.fileNumber == projectViewModel.user.patientID.toString()) {
|
|
|
|
|
if (widget.selectedPaymentMethod == "ApplePay") {
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber));
|
|
|
|
|
print("TransactionID: $transID");
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
LiveCareService service = new LiveCareService();
|
|
|
|
|
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
|
|
|
|
|
|
|
|
|
|
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
|
|
|
|
|
await context
|
|
|
|
|
.read<PayfortViewModel>()
|
|
|
|
|
.getProjectDetailsForPayfort(projectId: widget.advanceModel.hospitalsModel.iD, serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum())
|
|
|
|
|
.then((value) {
|
|
|
|
|
payfortProjectDetailsRespModel = value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
applePayInsertRequest.clientRequestID = transID;
|
|
|
|
|
applePayInsertRequest.clinicID = 0;
|
|
|
|
|
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 = 0;
|
|
|
|
|
applePayInsertRequest.projectID = widget.advanceModel.hospitalsModel.iD.toString();
|
|
|
|
|
applePayInsertRequest.serviceID = ServiceTypeEnum.advancePayment.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 = null;
|
|
|
|
|
applePayInsertRequest.appointmentNo = 0;
|
|
|
|
|
applePayInsertRequest.orderDescription = "Advance Payment";
|
|
|
|
|
applePayInsertRequest.liveServiceID = "0";
|
|
|
|
|
applePayInsertRequest.latitude = "0.0";
|
|
|
|
|
applePayInsertRequest.longitude = "0.0";
|
|
|
|
|
applePayInsertRequest.amount = widget.advanceModel.amount.toString();
|
|
|
|
|
applePayInsertRequest.isSchedule = "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 {
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
await context.read<PayfortViewModel>().initiateApplePayWithPayfort(
|
|
|
|
|
customerName: projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName,
|
|
|
|
|
customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
|
|
|
|
orderDescription: "Advance Payment",
|
|
|
|
|
orderAmount: double.parse(widget.advanceModel.amount),
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
|
|
|
|
|
onFailed: (failureResult) async {
|
|
|
|
|
log("failureResult: ${failureResult.toString()}");
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (successResult) async {
|
|
|
|
|
log("Payfort: ${successResult.responseMessage}");
|
|
|
|
|
await context.read<PayfortViewModel>().addPayfortApplePayResponse(result: successResult);
|
|
|
|
|
checkPaymentStatus(AppoitmentAllHistoryResultList());
|
|
|
|
|
},
|
|
|
|
|
projectId: widget.advanceModel.hospitalsModel.iD,
|
|
|
|
|
serviceTypeEnum: ServiceTypeEnum.advancePayment,
|
|
|
|
|
);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
});
|
|
|
|
|
startApplePay();
|
|
|
|
|
} else {
|
|
|
|
|
openPayment(widget.selectedPaymentMethod, widget.authenticatedUser, double.parse(widget.advanceModel.amount), AppoitmentAllHistoryResultList());
|
|
|
|
|
}
|
|
|
|
|
@ -311,14 +233,6 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
projectViewModel.analytics.advancePayments.payment_confirm(method: widget.selectedPaymentMethod.toLowerCase(), type: 'wallet');
|
|
|
|
|
|
|
|
|
|
// startApplePay();
|
|
|
|
|
// if()
|
|
|
|
|
// GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
// 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(model);
|
|
|
|
|
// });
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -327,7 +241,86 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addPayFortApplePayResponse() {}
|
|
|
|
|
void startApplePay() async {
|
|
|
|
|
transID = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber));
|
|
|
|
|
print("TransactionID: $transID");
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
LiveCareService service = new LiveCareService();
|
|
|
|
|
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
|
|
|
|
|
|
|
|
|
|
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
|
|
|
|
|
await context
|
|
|
|
|
.read<PayfortViewModel>()
|
|
|
|
|
.getProjectDetailsForPayfort(projectId: widget.advanceModel.hospitalsModel.iD, serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum())
|
|
|
|
|
.then((value) {
|
|
|
|
|
payfortProjectDetailsRespModel = value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
applePayInsertRequest.clientRequestID = transID;
|
|
|
|
|
applePayInsertRequest.clinicID = 0;
|
|
|
|
|
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 = 0;
|
|
|
|
|
applePayInsertRequest.projectID = widget.advanceModel.hospitalsModel.iD.toString();
|
|
|
|
|
applePayInsertRequest.serviceID = ServiceTypeEnum.advancePayment.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 = null;
|
|
|
|
|
applePayInsertRequest.appointmentNo = 0;
|
|
|
|
|
applePayInsertRequest.orderDescription = "Advance Payment";
|
|
|
|
|
applePayInsertRequest.liveServiceID = "0";
|
|
|
|
|
applePayInsertRequest.latitude = "0.0";
|
|
|
|
|
applePayInsertRequest.longitude = "0.0";
|
|
|
|
|
applePayInsertRequest.amount = widget.advanceModel.amount.toString();
|
|
|
|
|
applePayInsertRequest.isSchedule = "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: "Advance Payment",
|
|
|
|
|
orderAmount: double.parse(widget.advanceModel.amount),
|
|
|
|
|
merchantReference: transID,
|
|
|
|
|
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
|
|
|
|
|
onFailed: (failureResult) async {
|
|
|
|
|
log("failureResult: ${failureResult.toString()}");
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (successResult) async {
|
|
|
|
|
log("Payfort: ${successResult.responseMessage}");
|
|
|
|
|
await context.read<PayfortViewModel>().addPayfortApplePayResponse(result: successResult);
|
|
|
|
|
checkPaymentStatus(AppoitmentAllHistoryResultList());
|
|
|
|
|
},
|
|
|
|
|
projectId: widget.advanceModel.hospitalsModel.iD,
|
|
|
|
|
serviceTypeEnum: ServiceTypeEnum.advancePayment,
|
|
|
|
|
);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getApplePayPaymentType(dynamic paymentMethod) {
|
|
|
|
|
switch (paymentMethod) {
|
|
|
|
|
|