From efced34ffa002d398eae4c08185eb2bc6e829e44 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 19 Jan 2022 14:20:40 +0300 Subject: [PATCH] Updates --- applepay.json | 22 +++ assets/applepay.json | 22 +++ lib/models/apple_pay_request.dart | 135 ++++++++++++++++ lib/models/apple_pay_response.dart | 112 ++++++++++++++ .../all_habib_medical_service_page2.dart | 2 +- .../ancillaryOrdersDetails.dart | 8 +- lib/pages/BookAppointment/BookConfirm.dart | 3 +- lib/pages/BookAppointment/DoctorProfile.dart | 5 +- lib/pages/ToDoList/payment_method_select.dart | 82 ++++++---- .../fragments/home_page_fragment2.dart | 9 ++ .../medical/balance/confirm_payment_page.dart | 145 ++++++++---------- lib/pages/webRTC/signaling.dart | 74 ++++----- .../appointment_services/GetDoctorsList.dart | 44 ++++++ .../livecare_services/livecare_provider.dart | 5 +- lib/uitl/app_shared_preferences.dart | 4 +- lib/widgets/in_app_browser/InAppBrowser.dart | 11 +- pubspec.yaml | 9 +- 17 files changed, 526 insertions(+), 166 deletions(-) create mode 100644 applepay.json create mode 100644 assets/applepay.json create mode 100644 lib/models/apple_pay_request.dart create mode 100644 lib/models/apple_pay_response.dart diff --git a/applepay.json b/applepay.json new file mode 100644 index 00000000..5b00d6d5 --- /dev/null +++ b/applepay.json @@ -0,0 +1,22 @@ +{ + "provider": "apple_pay", + "data": { + "merchantIdentifier": "merchant.com.hmgwebservices", + "displayName": "Sulaiman Al Habib", + "merchantCapabilities": [ + "3DS", + "debit", + "credit" + ], + "supportedNetworks": [ + "amex", + "visa", + "discover", + "masterCard" + ], + "countryCode": "SA", + "currencyCode": "SAR", + "requiredBillingContactFields": null, + "requiredShippingContactFields": null + } +} \ No newline at end of file diff --git a/assets/applepay.json b/assets/applepay.json new file mode 100644 index 00000000..5b00d6d5 --- /dev/null +++ b/assets/applepay.json @@ -0,0 +1,22 @@ +{ + "provider": "apple_pay", + "data": { + "merchantIdentifier": "merchant.com.hmgwebservices", + "displayName": "Sulaiman Al Habib", + "merchantCapabilities": [ + "3DS", + "debit", + "credit" + ], + "supportedNetworks": [ + "amex", + "visa", + "discover", + "masterCard" + ], + "countryCode": "SA", + "currencyCode": "SAR", + "requiredBillingContactFields": null, + "requiredShippingContactFields": null + } +} \ No newline at end of file diff --git a/lib/models/apple_pay_request.dart b/lib/models/apple_pay_request.dart new file mode 100644 index 00000000..88e16316 --- /dev/null +++ b/lib/models/apple_pay_request.dart @@ -0,0 +1,135 @@ +class ApplePayRequest { + String currency; + String language; + String customername; + dynamic customerEmail; + String orderdescription; + String liveServiceid; + String longitude; + String latitude; + String devicetoken; + String clientrequestid; + String projectid; + String serviceid; + String patientid; + String amount; + String appleData; + String appleSignature; + AppleHeader appleHeader; + ApplePaymentMethod applePaymentMethod; + + ApplePayRequest( + {this.currency, + this.language, + this.customername, + this.customerEmail, + this.orderdescription, + this.liveServiceid, + this.longitude, + this.latitude, + this.devicetoken, + this.clientrequestid, + this.projectid, + this.serviceid, + this.patientid, + this.amount, + this.appleData, + this.appleSignature, + this.appleHeader, + this.applePaymentMethod}); + + ApplePayRequest.fromJson(Map json) { + currency = json['currency']; + language = json['language']; + customername = json['customername']; + customerEmail = json['customer_email']; + orderdescription = json['orderdescription']; + liveServiceid = json['live_serviceid']; + longitude = json['longitude']; + latitude = json['latitude']; + devicetoken = json['devicetoken']; + clientrequestid = json['clientrequestid']; + projectid = json['projectid']; + serviceid = json['serviceid']; + patientid = json['patientid']; + amount = json['Amount']; + appleData = json['apple_data']; + appleSignature = json['apple_signature']; + appleHeader = json['apple_header'] != null ? new AppleHeader.fromJson(json['apple_header']) : null; + applePaymentMethod = json['apple_paymentMethod'] != null ? new ApplePaymentMethod.fromJson(json['apple_paymentMethod']) : null; + } + + Map toJson() { + final Map data = new Map(); + data['currency'] = this.currency; + data['language'] = this.language; + data['customername'] = this.customername; + data['customer_email'] = this.customerEmail; + data['orderdescription'] = this.orderdescription; + data['live_serviceid'] = this.liveServiceid; + data['longitude'] = this.longitude; + data['latitude'] = this.latitude; + data['devicetoken'] = this.devicetoken; + data['clientrequestid'] = this.clientrequestid; + data['projectid'] = this.projectid; + data['serviceid'] = this.serviceid; + data['patientid'] = this.patientid; + data['Amount'] = this.amount; + data['apple_data'] = this.appleData; + data['apple_signature'] = this.appleSignature; + if (this.appleHeader != null) { + data['apple_header'] = this.appleHeader.toJson(); + } + if (this.applePaymentMethod != null) { + data['apple_paymentMethod'] = this.applePaymentMethod.toJson(); + } + return data; + } +} + +class AppleHeader { + String appleApplicationData; + String appleEphemeralPublicKey; + String applePublicKeyHash; + String appleTransactionId; + + AppleHeader({this.appleApplicationData, this.appleEphemeralPublicKey, this.applePublicKeyHash, this.appleTransactionId}); + + AppleHeader.fromJson(Map json) { + appleApplicationData = json['apple_applicationData']; + appleEphemeralPublicKey = json['apple_ephemeralPublicKey']; + applePublicKeyHash = json['apple_publicKeyHash']; + appleTransactionId = json['apple_transactionId']; + } + + Map toJson() { + final Map data = new Map(); + data['apple_applicationData'] = this.appleApplicationData; + data['apple_ephemeralPublicKey'] = this.appleEphemeralPublicKey; + data['apple_publicKeyHash'] = this.applePublicKeyHash; + data['apple_transactionId'] = this.appleTransactionId; + return data; + } +} + +class ApplePaymentMethod { + String appleDisplayName; + String appleNetwork; + String appleType; + + ApplePaymentMethod({this.appleDisplayName, this.appleNetwork, this.appleType}); + + ApplePaymentMethod.fromJson(Map json) { + appleDisplayName = json['apple_displayName']; + appleNetwork = json['apple_network']; + appleType = json['apple_type']; + } + + Map toJson() { + final Map data = new Map(); + data['apple_displayName'] = this.appleDisplayName; + data['apple_network'] = this.appleNetwork; + data['apple_type'] = this.appleType; + return data; + } +} diff --git a/lib/models/apple_pay_response.dart b/lib/models/apple_pay_response.dart new file mode 100644 index 00000000..f53b3d50 --- /dev/null +++ b/lib/models/apple_pay_response.dart @@ -0,0 +1,112 @@ +import 'dart:convert'; + +class ApplePayResponse { + PaymentMethod paymentMethod; + dynamic billingContact; + dynamic shippingMethod; + dynamic shippingContact; + Token token; + + ApplePayResponse( + {this.paymentMethod, + this.billingContact, + this.shippingMethod, + this.shippingContact, + this.token}); + + ApplePayResponse.fromJson(Map jsonValue) { + paymentMethod = jsonValue['paymentMethod'] != null + ? new PaymentMethod.fromJson(jsonValue['paymentMethod']) + : null; + // billingContact = json['billingContact'] != null ? json['billingContact'] : ""; + // shippingMethod = json['shippingMethod'] != null ? json['shippingMethod'] : ""; + // shippingContact = json['shippingContact'] != null ? json['shippingContact'] : ""; + token = jsonValue['token'] != null ? new Token.fromJson(json.decode(jsonValue['token'])) : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.paymentMethod != null) { + data['paymentMethod'] = this.paymentMethod.toJson(); + } + data['billingContact'] = this.billingContact; + data['shippingMethod'] = this.shippingMethod; + data['shippingContact'] = this.shippingContact; + if (this.token != null) { + data['token'] = this.token.toJson(); + } + return data; + } +} + +class PaymentMethod { + dynamic network; + dynamic displayName; + dynamic type; + + PaymentMethod({this.network, this.displayName, this.type}); + + PaymentMethod.fromJson(Map json) { + network = json['network']; + displayName = json['displayName']; + type = json['type']; + } + + Map toJson() { + final Map data = new Map(); + data['network'] = this.network; + data['displayName'] = this.displayName; + data['type'] = this.type; + return data; + } +} + +class Token { + String version; + String data; + String signature; + Header header; + + Token({this.version, this.data, this.signature, this.header}); + + Token.fromJson(Map json) { + version = json['version']; + data = json['data']; + signature = json['signature']; + header = + json['header'] != null ? new Header.fromJson(json['header']) : null; + } + + Map toJson() { + final Map data = new Map(); + data['version'] = this.version; + data['data'] = this.data; + data['signature'] = this.signature; + if (this.header != null) { + data['header'] = this.header.toJson(); + } + return data; + } +} + +class Header { + String ephemeralPublicKey; + String publicKeyHash; + String transactionId; + + Header({this.ephemeralPublicKey, this.publicKeyHash, this.transactionId}); + + Header.fromJson(Map json) { + ephemeralPublicKey = json['ephemeralPublicKey']; + publicKeyHash = json['publicKeyHash']; + transactionId = json['transactionId']; + } + + Map toJson() { + final Map data = new Map(); + data['ephemeralPublicKey'] = this.ephemeralPublicKey; + data['publicKeyHash'] = this.publicKeyHash; + data['transactionId'] = this.transactionId; + return data; + } +} diff --git a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart index 37bc5fe6..b6608d1c 100644 --- a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart +++ b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page2.dart @@ -50,7 +50,7 @@ class _AllHabibMedicalSevicePage2State extends State hmgServices.clear(); hmgServices.add(new HmgServices(0, TranslationBase.of(context).liveCareTitle, TranslationBase.of(context).liveCareSubtitle, "assets/images/new/Live_Care.svg", isLogin)); - hmgServices.add(new HmgServices(1, TranslationBase.of(context).covidTest, TranslationBase.of(context).driveThru, "assets/images/new/covid_test_drive_thru.svg", isLogin)); + hmgServices.add(new HmgServices(1, TranslationBase.of(context).covidTest, TranslationBase.of(context).driveThru, "assets/images/new/CoronaIcon.svg", isLogin)); hmgServices.add(new HmgServices(2, TranslationBase.of(context).onlinePayment, TranslationBase.of(context).onlinePaymentSubtitle, "assets/images/new/paymentMethods.png", isLogin)); hmgServices.add(new HmgServices(3, TranslationBase.of(context).hhcHome, TranslationBase.of(context).healthCare, "assets/images/new/HHC.svg", isLogin)); hmgServices.add(new HmgServices(4, TranslationBase.of(context).cmcTitle, TranslationBase.of(context).cmcSubtitle, "assets/images/new/comprehensive_checkup.svg", isLogin)); diff --git a/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart b/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart index 17ac18da..f2bc4091 100644 --- a/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart +++ b/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart @@ -367,10 +367,10 @@ class _AnicllaryOrdersState extends State with SingleTic addSelectedProcedure(value[i]); }); }), - Utils.tableColumnValue('${value[i].procedureName}', isLast: true, isCapitable: false), - Utils.tableColumnValue('${value[i].patientShare.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true, isCapitable: false), - Utils.tableColumnValue('${value[i].patientTaxAmount.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true, isCapitable: false), - Utils.tableColumnValue('${value[i].patientShareWithTax.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true, isCapitable: false), + Utils.tableColumnValue('${value[i].procedureName}', isLast: true, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue('${value[i].patientShare.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue('${value[i].patientTaxAmount.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue('${value[i].patientShareWithTax.toString() + " " + TranslationBase.of(context).sar.toUpperCase()}', isLast: true, isCapitable: false, mProjectViewModel: projectViewModel), ]), ); } diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 59b8eeda..105bb4db 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -200,7 +200,8 @@ class _BookConfirmState extends State { disabledTextColor: Colors.white, disabledColor: new Color(0xFFbcc2c4), onPressed: () async { - if (await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT) != null && !await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT)) { + bool isLiveCareSchedule = await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT); + if (isLiveCareSchedule != null && isLiveCareSchedule) { insertLiveCareScheduledAppointment(context, widget.doctor); } else { insertAppointment(context, widget.doctor); diff --git a/lib/pages/BookAppointment/DoctorProfile.dart b/lib/pages/BookAppointment/DoctorProfile.dart index 0357acb6..87941ed5 100644 --- a/lib/pages/BookAppointment/DoctorProfile.dart +++ b/lib/pages/BookAppointment/DoctorProfile.dart @@ -148,12 +148,13 @@ class _DoctorProfileState extends State with TickerProviderStateM onTap: (index) { setState(() { if (index == 1) { - // if (widget.doctor.clinicID == 17 || widget.doctor.clinicID == 23 || widget.doctor.clinicID == 47 || widget.isLiveCareAppointment) { - // _tabController.index = _tabController.previousIndex; + if (widget.doctor.clinicID == 17 || widget.doctor.clinicID == 23 || widget.doctor.clinicID == 47 || widget.isLiveCareAppointment) { + _tabController.index = _tabController.previousIndex; showFooterButton = false; } else { showFooterButton = true; } + } print(showFooterButton); }); }, diff --git a/lib/pages/ToDoList/payment_method_select.dart b/lib/pages/ToDoList/payment_method_select.dart index ea583477..b0f65e13 100644 --- a/lib/pages/ToDoList/payment_method_select.dart +++ b/lib/pages/ToDoList/payment_method_select.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:pay/pay.dart'; class PaymentMethod extends StatefulWidget { Function onSelectedMethod; @@ -300,35 +301,58 @@ class _PaymentMethodState extends State { bottomSheet: Container( padding: EdgeInsets.all(16), color: Colors.white, - child: Container( - width: MediaQuery.of(context).size.width, - height: 50.0, - color: Colors.white, - // margin: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 20.0), - child: ButtonTheme( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10.0), - ), - minWidth: MediaQuery.of(context).size.height * 0.1, - height: 45.0, - child: RaisedButton( - color: CustomColors.green, - textColor: Colors.white, - disabledTextColor: Colors.white, - disabledColor: new Color(0xFFbcc2c4), - elevation: 0, - onPressed: () { - widget.onSelectedMethod(selectedPaymentMethod); - Navigator.pop(context, selectedPaymentMethod); - }, - child: Text(TranslationBase.of(context).confirm.toUpperCase(), - style: TextStyle( - fontSize: 14.0, - fontWeight: FontWeight.w600, - )), - ), - ), - ), + child: + // selectedPaymentMethod == "ApplePay" + // ? ApplePayButton( + // paymentConfigurationAsset: 'applepay.json', + // paymentItems: _paymentItems, + // style: ApplePayButtonStyle.black, + // type: ApplePayButtonType.inStore, + // width: MediaQuery.of(context).size.width, + // height: 50, + // margin: const EdgeInsets.only(top: 15.0), + // onPaymentResult: (value) { + // print(value); + // // applePayResponse = ApplePayResponse.fromJson(value); + // // print(applePayResponse.token.data); + // }, + // onError: (error) { + // print(error); + // }, + // loadingIndicator: const Center( + // child: CircularProgressIndicator(), + // ), + // ) + // : + Container( + width: MediaQuery.of(context).size.width, + height: 50.0, + color: Colors.white, + // margin: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 20.0), + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + minWidth: MediaQuery.of(context).size.height * 0.1, + height: 45.0, + child: RaisedButton( + color: CustomColors.green, + textColor: Colors.white, + disabledTextColor: Colors.white, + disabledColor: new Color(0xFFbcc2c4), + elevation: 0, + onPressed: () { + widget.onSelectedMethod(selectedPaymentMethod); + Navigator.pop(context, selectedPaymentMethod); + }, + child: Text(TranslationBase.of(context).confirm.toUpperCase(), + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.w600, + )), + ), + ), + ), ), ); } diff --git a/lib/pages/landing/fragments/home_page_fragment2.dart b/lib/pages/landing/fragments/home_page_fragment2.dart index 07728d91..87722fac 100644 --- a/lib/pages/landing/fragments/home_page_fragment2.dart +++ b/lib/pages/landing/fragments/home_page_fragment2.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:math' as math; import 'package:auto_size_text/auto_size_text.dart'; @@ -7,6 +8,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/models/apple_pay_response.dart'; import 'package:diplomaticquarterapp/models/gradient_color.dart'; import 'package:diplomaticquarterapp/models/hmg_services.dart'; import 'package:diplomaticquarterapp/models/slider_data.dart'; @@ -23,7 +25,9 @@ import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; +import 'package:pay/pay.dart'; class HomePageFragment2 extends StatefulWidget { DashboardViewModel model; @@ -39,6 +43,7 @@ class _HomePageFragment2State extends State { ProjectViewModel projectViewModel; List hmgServices = []; List appoList = []; + ApplePayResponse applePayResponse; @override void initState() { @@ -561,6 +566,10 @@ class _HomePageFragment2State extends State { ); } + callPayfortApplePayAPI(ApplePayResponse applePayResponse) { + + } + Widget showFloating(String icon) { return Container( width: MediaQuery.of(context).size.width * 0.06, diff --git a/lib/pages/medical/balance/confirm_payment_page.dart b/lib/pages/medical/balance/confirm_payment_page.dart index d838d6eb..57548633 100644 --- a/lib/pages/medical/balance/confirm_payment_page.dart +++ b/lib/pages/medical/balance/confirm_payment_page.dart @@ -15,13 +15,12 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.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/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; +import 'package:pay/pay.dart'; import 'new_text_Field.dart'; @@ -31,11 +30,7 @@ class ConfirmPaymentPage extends StatefulWidget { final String selectedPaymentMethod; AuthenticatedUser authenticatedUser; - ConfirmPaymentPage( - {this.advanceModel, - this.patientInfoAndMobileNumber, - this.selectedPaymentMethod, - this.authenticatedUser}); + ConfirmPaymentPage({this.advanceModel, this.patientInfoAndMobileNumber, this.selectedPaymentMethod, this.authenticatedUser}); @override _ConfirmPaymentPageState createState() => _ConfirmPaymentPageState(); @@ -48,19 +43,50 @@ class _ConfirmPaymentPageState extends State { String transID = ""; + Pay _payClient = Pay.withAssets([ + 'applepay.json', + ]); + + var _paymentItems = [ + PaymentItem( + label: 'Total', + amount: '99.99', + status: PaymentItemStatus.final_price, + ) + ]; + void submit(MyBalanceViewModel model, code) { final activationCode = code; GifLoaderDialogUtils.showMyDialog(AppGlobal.context); - model - .checkActivationCodeForAdvancePayment(activationCode: activationCode) - .then((value) { + model.checkActivationCodeForAdvancePayment(activationCode: activationCode).then((value) { GifLoaderDialogUtils.hideDialog(AppGlobal.context); Navigator.pop(context, true); - AppoitmentAllHistoryResultList appo = - new AppoitmentAllHistoryResultList(); + AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList(); appo.projectID = widget.patientInfoAndMobileNumber.projectID; - openPayment(widget.selectedPaymentMethod, widget.authenticatedUser, - double.parse(widget.advanceModel.amount), null); + if (widget.selectedPaymentMethod == "ApplePay") { + + // _payClient.userCanPay(PayProvider.apple_pay).then((value) { + // print(value); + // }); + + // return FutureBuilder( + // builder: (context, snapshot) { + // if (snapshot.connectionState == ConnectionState.done) { + // if (snapshot.data == true) { + // return RawGooglePayButton( + // style: GooglePayButtonStyle.black, + // type: GooglePayButtonType.pay, + // onPressed: onGooglePayPressed); + // } else { + // // userCanPay returned false + // // Consider showing an alternative payment method + // } + // } + // }, + // ); + } else { + openPayment(widget.selectedPaymentMethod, widget.authenticatedUser, double.parse(widget.advanceModel.amount), null); + } }); } @@ -113,12 +139,10 @@ class _ConfirmPaymentPageState extends State { height: 100.0, padding: EdgeInsets.all(7.0), width: MediaQuery.of(context).size.width * 0.30, - child: Image.asset( - getImagePath(widget.selectedPaymentMethod)), + child: Image.asset(getImagePath(widget.selectedPaymentMethod)), ), Text( - '${widget.advanceModel.amount} ' + - TranslationBase.of(context).sar, + '${widget.advanceModel.amount} ' + TranslationBase.of(context).sar, style: TextStyle( fontSize: 20, fontWeight: FontWeight.w900, @@ -147,8 +171,7 @@ class _ConfirmPaymentPageState extends State { margin: EdgeInsets.all(3), child: NewTextFields( hintText: TranslationBase.of(context).name, - initialValue: - widget.patientInfoAndMobileNumber.firstName, + initialValue: widget.patientInfoAndMobileNumber.firstName, isEnabled: false, ), ), @@ -168,11 +191,7 @@ class _ConfirmPaymentPageState extends State { ), NewTextFields( hintText: TranslationBase.of(context).depositorName, - initialValue: model.user.firstName + - " " + - model.user.middleName + - " " + - model.user.lastName, + initialValue: model.user.firstName + " " + model.user.middleName + " " + model.user.lastName, isEnabled: false, ), SizedBox( @@ -196,16 +215,19 @@ class _ConfirmPaymentPageState extends State { child: DefaultButton( TranslationBase.of(context).confirm.toUpperCase(), () { - 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); + _payClient.userCanPay(PayProvider.apple_pay).then((value) async { + print(value); + final result = await _payClient.showPaymentSelector( + provider: PayProvider.apple_pay, + paymentItems: _paymentItems, + ); + print(result); }); + // 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); + // }); }, ), ), @@ -239,32 +261,13 @@ class _ConfirmPaymentPageState extends State { return 'assets/images/new-design/mada.png'; } - openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, - double amount, AppoitmentAllHistoryResultList appo) { - browser = new MyInAppBrowser( - onExitCallback: onBrowserExit, - appo: appo, - onLoadStartCallback: onBrowserLoadStart); + openPayment(String paymentMethod, AuthenticatedUser authenticatedUser, double amount, AppoitmentAllHistoryResultList appo) { + browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart); - transID = Utils.getAdvancePaymentTransID( - widget.advanceModel.hospitalsModel.iD, - int.parse(widget.advanceModel.fileNumber)); + transID = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber)); - browser.openPaymentBrowser( - amount, - "Advance Payment", - transID, - widget.advanceModel.hospitalsModel.iD.toString(), - widget.advanceModel.email, - paymentMethod, - widget.patientInfoAndMobileNumber.patientType, - widget.advanceModel.patientName, - widget.advanceModel.fileNumber, - authenticatedUser, - browser, - false, - "3", - ""); + browser.openPaymentBrowser(amount, "Advance Payment", transID, widget.advanceModel.hospitalsModel.iD.toString(), widget.advanceModel.email, paymentMethod, + widget.patientInfoAndMobileNumber.patientType, widget.advanceModel.patientName, widget.advanceModel.fileNumber, authenticatedUser, browser, false, "3", ""); } onBrowserLoadStart(String url) { @@ -314,22 +317,10 @@ class _ConfirmPaymentPageState extends State { createAdvancePayment(res, AppoitmentAllHistoryResultList appo) { DoctorsListService service = new DoctorsListService(); String paymentReference = res['Fort_id'].toString(); - service.HIS_createAdvancePayment( - appo, - widget.advanceModel.hospitalsModel.iD.toString(), - res['Amount'], - res['Fort_id'], - res['PaymentMethod'], - widget.patientInfoAndMobileNumber.patientType, - widget.advanceModel.patientName, - widget.advanceModel.fileNumber, - AppGlobal.context) + service.HIS_createAdvancePayment(appo, widget.advanceModel.hospitalsModel.iD.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], widget.patientInfoAndMobileNumber.patientType, + widget.advanceModel.patientName, widget.advanceModel.fileNumber, AppGlobal.context) .then((res) { - addAdvancedNumberRequest( - res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), - paymentReference, - 0, - appo); + addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, 0, appo); }).catchError((err) { GifLoaderDialogUtils.hideDialog(AppGlobal.context); AppToast.showErrorToast(message: err); @@ -337,13 +328,9 @@ class _ConfirmPaymentPageState extends State { }); } - addAdvancedNumberRequest(String advanceNumber, String paymentReference, - dynamic appointmentID, AppoitmentAllHistoryResultList appo) { + addAdvancedNumberRequest(String advanceNumber, String paymentReference, dynamic appointmentID, AppoitmentAllHistoryResultList appo) { DoctorsListService service = new DoctorsListService(); - service - .addAdvancedNumberRequest( - advanceNumber, paymentReference, appointmentID, AppGlobal.context) - .then((res) { + service.addAdvancedNumberRequest(advanceNumber, paymentReference, appointmentID, AppGlobal.context).then((res) { print(res); GifLoaderDialogUtils.hideDialog(AppGlobal.context); navigateToHome(AppGlobal.context); diff --git a/lib/pages/webRTC/signaling.dart b/lib/pages/webRTC/signaling.dart index 1e50c534..44de7488 100644 --- a/lib/pages/webRTC/signaling.dart +++ b/lib/pages/webRTC/signaling.dart @@ -1,50 +1,50 @@ import 'dart:convert'; -// import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:diplomaticquarterapp/pages/webRTC/fcm/FCMSendNotification.dart'; import 'package:diplomaticquarterapp/uitl/SignalRUtil.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart'; -import 'call_page.dart'; - typedef void StreamStateCallback(MediaStream stream); typedef void RTCIceGatheringStateCallback(RTCIceGatheringState state); typedef void RTCPeerConnectionStateCallback(RTCPeerConnectionState state); typedef void RTCSignalingStateCallback(RTCSignalingState state); class Signaling { - - dispose(){ - if(peerConnection != null) - peerConnection.dispose(); + dispose() { + if (peerConnection != null) peerConnection.dispose(); signalR.closeConnection(); } - init(){ + init() { // Create Peer Connection - createPeerConnection(configuration).then((value){ + createPeerConnection(configuration).then((value) { peerConnection = value; registerPeerConnectionListeners(); }); } - - initializeSignalR(String userName) async{ - if(signalR != null) - await signalR.closeConnection(); + initializeSignalR(String userName) async { + if (signalR != null) await signalR.closeConnection(); // https://vcallapi.hmg.com/webRTCHub?source=web&username=zohaib signalR = SignalRUtil(hubName: "https://vcallapi.hmg.com/webRTCHub?source=mobile&username=$userName"); final connected = await signalR.openConnection(); - if(!connected) - throw 'Failed to connect SignalR'; + if (!connected) throw 'Failed to connect SignalR'; } Map configuration = { + // 'iceServers': [ + // { + // 'urls': ['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302'] + // } + // ] + 'iceServers': [ - { - 'urls': ['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302'] - } + // { + // 'urls': ['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302'] + // } + + {'url': "stun:ec2-15-185-116-59.me-south-1.compute.amazonaws.com:3478"}, + {'url': "turn:ec2-15-185-116-59.me-south-1.compute.amazonaws.com:3479", 'credential': "admin", 'username': "admin"} ] }; @@ -65,8 +65,7 @@ class Signaling { // return isCallPlaced; // } - - Future acceptCall(String caller, String receiver, {@required MediaStream localMediaStream, @required Function(MediaStream) onRemoteMediaStream}) async{ + Future acceptCall(String caller, String receiver, {@required MediaStream localMediaStream, @required Function(MediaStream) onRemoteMediaStream}) async { await initializeSignalR(receiver); signalR.setContributors(caller: caller, receiver: receiver); await signalR.acceptCall(receiver, caller).catchError((e) => throw 'Failed to inform signalR that i accepted a call'); @@ -81,35 +80,28 @@ class Signaling { return true; } - Future hangupCall(String caller, String receiver) async{ + Future hangupCall(String caller, String receiver) async { await signalR.hangupCall(caller, receiver); dispose(); } - answerOffer(String sdp) async{ + answerOffer(String sdp) async { final offer = jsonDecode(sdp); final caller = offer['caller']; final receiver = offer['target']; final offerSdp = offer['sdp']; - peerConnection.setRemoteDescription(rtcSessionDescriptionFrom(offerSdp)) - .then((value) { + peerConnection.setRemoteDescription(rtcSessionDescriptionFrom(offerSdp)).then((value) { return peerConnection.createAnswer(); - }) - .then((anwser) { + }).then((anwser) { return peerConnection.setLocalDescription(anwser); - }) - .then((value) { + }).then((value) { return peerConnection.getLocalDescription(); - }) - .then((answer) { + }).then((answer) { return signalR.answerOffer(answer, caller, receiver); }); - } - Future hangUp(RTCVideoRenderer localVideo) async { - - } + Future hangUp(RTCVideoRenderer localVideo) async {} Future createSdpAnswer(String toOfferSdp) async { final offerSdp = rtcSessionDescriptionFrom(jsonDecode(toOfferSdp)); @@ -128,12 +120,12 @@ class Signaling { return offerSdp; } - addCandidate(String candidateJson){ + addCandidate(String candidateJson) { peerConnection.addCandidate(rtcIceCandidateFrom(candidateJson)); } void registerPeerConnectionListeners() { - peerConnection.onIceCandidate = (RTCIceCandidate candidate){ + peerConnection.onIceCandidate = (RTCIceCandidate candidate) { // print(json.encode(candidate.toMap())); signalR.addIceCandidate(json.encode(candidate.toMap())); }; @@ -152,14 +144,14 @@ class Signaling { } } - -rtcSessionDescriptionFrom(Map sdp){ +rtcSessionDescriptionFrom(Map sdp) { return RTCSessionDescription( - sdp['sdp'],sdp['type'], + sdp['sdp'], + sdp['type'], ); } -rtcIceCandidateFrom(String json){ +rtcIceCandidateFrom(String json) { final map = jsonDecode(json)['candidate']; return RTCIceCandidate(map['candidate'], map['sdpMid'], map['sdpMLineIndex']); } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 6e819f60..139d847c 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -9,10 +9,12 @@ import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.da import 'package:diplomaticquarterapp/models/Appointments/doctor_pre_post_image.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; +import 'package:diplomaticquarterapp/models/apple_pay_request.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:flutter/cupertino.dart'; class DoctorsListService extends BaseService { @@ -391,6 +393,7 @@ class DoctorsListService extends BaseService { "StrAppointmentDate": selectedDate, "IsVirtual": false, "DeviceType": Platform.isIOS ? 'iOS' : 'Android', + "DeviceToken": await sharedPref.getString(PUSH_TOKEN), "BookedBy": 102, "VisitType": 1, "VisitFor": 1, @@ -1343,6 +1346,47 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } + Future callPayfortApplePayAPI(ApplePayRequest applePayRequest, BuildContext context) async { + Map request; + + request = { + "currency": applePayRequest.currency, + "language": applePayRequest.language, + "customername": applePayRequest.customername, + "customer_email": applePayRequest.customerEmail, + "orderdescription": applePayRequest.orderdescription, + "live_serviceid": applePayRequest.liveServiceid, + "longitude": applePayRequest.longitude, + "latitude": applePayRequest.latitude, + "devicetoken": applePayRequest.devicetoken, + "clientrequestid": applePayRequest.clientrequestid, + "projectid": applePayRequest.projectid, + "serviceid": applePayRequest.serviceid, + "patientid": applePayRequest.patientid, + "Amount": applePayRequest.amount, + "apple_data": applePayRequest.appleData, + "apple_signature": applePayRequest.appleSignature, + "apple_header": { + "apple_applicationData": "76a9a9cb2d9811e8de56d8e7713601bfa6acda3d488b1cf03b9b115bc3ff12b4", + "apple_ephemeralPublicKey": applePayRequest.appleHeader.appleEphemeralPublicKey, + "apple_publicKeyHash": applePayRequest.appleHeader.applePublicKeyHash, + "apple_transactionId": applePayRequest.appleHeader.appleTransactionId + }, + "apple_paymentMethod": { + "apple_displayName": applePayRequest.applePaymentMethod.appleDisplayName, + "apple_network": applePayRequest.applePaymentMethod.appleNetwork, + "apple_type": applePayRequest.applePaymentMethod.appleType + } + }; + dynamic localRes; + await baseAppClient.post(MyInAppBrowser.APPLE_PAY_PAYFORT_URL, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isExternal: true); + return Future.value(localRes); + } + Future getLaserBodyPartsList(int laserCategoryID) async { Map request; diff --git a/lib/services/livecare_services/livecare_provider.dart b/lib/services/livecare_services/livecare_provider.dart index 6553da40..552b7d16 100644 --- a/lib/services/livecare_services/livecare_provider.dart +++ b/lib/services/livecare_services/livecare_provider.dart @@ -209,8 +209,9 @@ class LiveCareService extends BaseService { "ClientRequestID": clientRequestID, "DeviceToken": deviceToken, "VoipToken": "", - "Latitude": "24.708488", - "Longitude": "46.665925", + "IsFlutter": true, + "Latitude": await this.sharedPref.getDouble(USER_LAT), + "Longitude": await this.sharedPref.getDouble(USER_LONG), "DeviceType": Platform.isIOS ? 'iOS' : 'Android', "Age": authUser.age != null ? authUser.age : 0, "PatientID": authUser.patientID != null ? authUser.patientID : 0, diff --git a/lib/uitl/app_shared_preferences.dart b/lib/uitl/app_shared_preferences.dart index 7142761a..ed8321eb 100644 --- a/lib/uitl/app_shared_preferences.dart +++ b/lib/uitl/app_shared_preferences.dart @@ -121,6 +121,8 @@ class AppSharedPreferences { /// remove value based on [key] the key was saved remove(String key) async { final SharedPreferences prefs = await _prefs; - prefs.remove(key); + prefs.remove(key).then((value) { + print(value); + }); } } diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index d7bc9623..960b6224 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -28,13 +28,16 @@ var _InAppBrowserOptions = InAppBrowserClassOptions( class MyInAppBrowser extends InAppBrowser { _PAYMENT_TYPE paymentType; - // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + // 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/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE + static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - // static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT + // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE - 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/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 PRESCRIPTION_PAYMENT_WITH_ORDERID = // 'https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID='; diff --git a/pubspec.yaml b/pubspec.yaml index 7205970d..ab0a256d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,7 +42,10 @@ dependencies: permission_handler: ^8.3.0 # Flutter Html View - flutter_html: ^2.1.5 + flutter_html: ^2.2.1 + + #Apple Pay + pay: ^1.0.7 # Pagnation pull_to_refresh: ^2.0.0 @@ -107,7 +110,7 @@ dependencies: syncfusion_flutter_calendar: ^19.3.55 # SVG Images - flutter_svg: ^0.23.0+1 +# flutter_svg: ^0.23.0+1 #Calendar Events manage_calendar_events: ^2.0.1 @@ -200,6 +203,7 @@ dependencies: dependency_overrides: provider : ^5.0.0 permission_handler : ^6.0.1+1 + flutter_svg: ^1.0.0 dev_dependencies: @@ -211,6 +215,7 @@ flutter: uses-material-design: true # assets: assets: + - assets/ - assets/images/ - assets/images/map_markers/ - assets/images/pharmacy/