From 60a44f9a42b92db8fcf03b1e3806fd67e9740e18 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 13 Mar 2022 19:42:58 +0300 Subject: [PATCH] OpenTok fixes --- lib/config/config.dart | 7 ++++-- lib/pages/livecare/incoming_call.dart | 19 ++++++++++++---- .../medical/balance/confirm_payment_page.dart | 20 ++++++++--------- lib/pages/webRTC/OpenTok/OpenTok.dart | 11 ++++++++++ .../livecare_services/livecare_provider.dart | 22 ++++++++++++++++++- lib/widgets/in_app_browser/InAppBrowser.dart | 8 +++---- 6 files changed, 66 insertions(+), 21 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index a2fb00eb..fee1b035 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -19,8 +19,8 @@ var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; // var BASE_URL = 'http://10.50.100.198:3334/'; - var BASE_URL = 'https://uat.hmgwebservices.com/'; -// var BASE_URL = 'https://hmgwebservices.com/'; +// var BASE_URL = 'https://uat.hmgwebservices.com/'; +var BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs // var BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; @@ -364,6 +364,9 @@ var CANCEL_LIVECARE_REQUEST = var SEND_LIVECARE_INVOICE_EMAIL = 'Services/Notifications.svc/REST/SendInvoiceForLiveCare'; +var CHANGE_PATIENT_ER_SESSION = + 'Services/DoctorApplication.svc/REST/ChangePatientERSession'; + var APPLE_PAY_INSERT_REQUEST = 'Services/PayFort_Serv.svc/REST/PayFort_ApplePayRequestData_Insert'; diff --git a/lib/pages/livecare/incoming_call.dart b/lib/pages/livecare/incoming_call.dart index db2882f0..7f264712 100644 --- a/lib/pages/livecare/incoming_call.dart +++ b/lib/pages/livecare/incoming_call.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/livecare/video-call-web-page.dart'; import 'package:diplomaticquarterapp/pages/webRTC/OpenTok/OpenTok.dart'; import 'package:diplomaticquarterapp/pages/webRTC/signaling.dart'; +import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -42,10 +43,10 @@ class _IncomingCallState extends State with SingleTickerProviderSt isCameraReady = false; WidgetsBinding.instance.addPostFrameCallback((_) => _runAnimation()); - - print(widget.incomingCallData.doctorname); - print(widget.incomingCallData.clinicname); - print(widget.incomingCallData.speciality); + // + // print(widget.incomingCallData.doctorname); + // print(widget.incomingCallData.clinicname); + // print(widget.incomingCallData.speciality); super.initState(); } @@ -235,6 +236,7 @@ class _IncomingCallState extends State with SingleTickerProviderSt // backToHome(); // final roomModel = RoomModel(name: widget.incomingCallData.name, token: widget.incomingCallData.sessionId, identity: widget.incomingCallData.identity); await _controller.dispose(); + changeCallStatusAPI(4); await Navigator.of(context).pushReplacement( MaterialPageRoute( // fullscreenDialog: true, @@ -262,10 +264,19 @@ class _IncomingCallState extends State with SingleTickerProviderSt } } + void changeCallStatusAPI(int sessionStatus) { + LiveCareService service = new LiveCareService(); + service.endCallAPI(widget.incomingCallData.sessionId, sessionStatus, context).then((res) { + }).catchError((err) { + print(err); + }); + } + void backToHome() async { // final connected = await signaling.declineCall(widget.incomingCallData.callerID, widget.incomingCallData.receiverID); LandingPage.isOpenCallPage = false; player.stop(); + changeCallStatusAPI(3); Navigator.of(context).pop(); } diff --git a/lib/pages/medical/balance/confirm_payment_page.dart b/lib/pages/medical/balance/confirm_payment_page.dart index 486d5c5d..e7115837 100644 --- a/lib/pages/medical/balance/confirm_payment_page.dart +++ b/lib/pages/medical/balance/confirm_payment_page.dart @@ -61,12 +61,12 @@ class _ConfirmPaymentPageState extends State { Navigator.pop(context, true); AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList(); appo.projectID = widget.patientInfoAndMobileNumber.projectID; - if (widget.selectedPaymentMethod == "ApplePay") { - startApplePay(); - } else { + // if (widget.selectedPaymentMethod == "ApplePay") { + // startApplePay(); + // } else { projectViewModel.analytics.advancePayments.payment_otp_confirmation(method: widget.selectedPaymentMethod.toLowerCase(), type: 'wallet'); openPayment(widget.selectedPaymentMethod, widget.authenticatedUser, double.parse(widget.advanceModel.amount), null); - } + // } }); } @@ -209,13 +209,13 @@ class _ConfirmPaymentPageState extends State { if (model.state != ViewState.ErrorLocal && model.state != ViewState.Error) showSMSDialog(model); }); - startApplePay(); + // 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); - // }); + 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); + }); }, ), ), diff --git a/lib/pages/webRTC/OpenTok/OpenTok.dart b/lib/pages/webRTC/OpenTok/OpenTok.dart index 68bc815e..4246049d 100644 --- a/lib/pages/webRTC/OpenTok/OpenTok.dart +++ b/lib/pages/webRTC/OpenTok/OpenTok.dart @@ -2,6 +2,8 @@ import 'dart:async'; import 'package:diplomaticquarterapp/pages/conference/conference_button_bar.dart'; import 'package:diplomaticquarterapp/pages/conference/draggable_publisher.dart'; +import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; @@ -194,9 +196,18 @@ class OpenTokState extends State{ Future _onHangup() async { print('onHangup'); await openTokPlatform.hangupCall(); + endCallAPI(); Navigator.of(context).pop(); } + void endCallAPI() { + LiveCareService service = new LiveCareService(); + service.endCallAPI(widget.sessionId, 2, context).then((res) { + }).catchError((err) { + print(err); + }); + } + void _onShowBar() { setState(() { }); diff --git a/lib/services/livecare_services/livecare_provider.dart b/lib/services/livecare_services/livecare_provider.dart index 441de08d..7d4950a9 100644 --- a/lib/services/livecare_services/livecare_provider.dart +++ b/lib/services/livecare_services/livecare_provider.dart @@ -216,7 +216,7 @@ class LiveCareService extends BaseService { "ClientRequestID": clientRequestID, "DeviceToken": deviceToken, "VoipToken": "", - "IsFlutter": true, + // "IsFlutter": true, "Latitude": await this.sharedPref.getDouble(USER_LAT), "Longitude": await this.sharedPref.getDouble(USER_LONG), "DeviceType": Platform.isIOS ? 'iOS' : 'Android', @@ -293,4 +293,24 @@ class LiveCareService extends BaseService { }, body: request); return Future.value(localRes); } + + Future endCallAPI(String sessionID, int sessionStatus, BuildContext context) async { + Map request; + + if (await this.sharedPref.getObject(USER_PROFILE) != null) { + var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); + authUser = data; + } + request = {"Open_SessionID": sessionID, "SessionStatus": sessionStatus, "SessionEndedBy": "Patient"}; + + dynamic localRes; + + await baseAppClient.post(CHANGE_PATIENT_ER_SESSION, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + } diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index 960b6224..66b9a342 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -31,13 +31,13 @@ class MyInAppBrowser extends InAppBrowser { // static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWeb/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT - static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE + 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/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 String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store // static String PRESCRIPTION_PAYMENT_WITH_ORDERID = // 'https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID=';