diff --git a/lib/analytics/flows/advance_payments.dart b/lib/analytics/flows/advance_payments.dart index db52eb59..6bd43a08 100644 --- a/lib/analytics/flows/advance_payments.dart +++ b/lib/analytics/flows/advance_payments.dart @@ -79,4 +79,20 @@ class AdvancePayments{ 'transaction_currency' : txn_currency }); } + + // New + payment_fail({@required String appointment_type, clinic, hospital, payment_method, payment_type, txn_amount, txn_currency, error_code, error_message}){ + logger('payment_fail', parameters: { + 'appointment_type' : appointment_type, + 'clinic_type_online' : clinic, + 'payment_method' : payment_method, + 'payment_type' : payment_type, + 'hospital_name' : hospital, + 'transaction_number' : "", + 'transaction_amount' : txn_amount, + 'transaction_currency' : txn_currency, + "error_code" : error_code, + "error_message" : error_message, + }); + } } \ No newline at end of file diff --git a/lib/analytics/flows/appointments.dart b/lib/analytics/flows/appointments.dart index 50a02c76..0e911d75 100644 --- a/lib/analytics/flows/appointments.dart +++ b/lib/analytics/flows/appointments.dart @@ -232,14 +232,17 @@ class Appointment{ // R036 payment_success({@required String appointment_type, clinic, hospital, payment_method, payment_type, txn_number, txn_amount, txn_currency}){ - // appointment_type - // clinic_type_online - // payment_method - // payment_type: 'appointment' - // hospital_name - // transaction_number - // transaction_amount - // transaction_currency + + logger('payment_success', parameters: { + 'appointment_type' : appointment_type, + 'clinic_type_online' : clinic, + 'payment_method' : payment_method, + 'payment_type' : payment_type, + 'hospital_name' : hospital, + 'transaction_number' : txn_number, + 'transaction_amount' : txn_amount, + 'transaction_currency' : txn_currency, + }); } diff --git a/lib/analytics/google-analytics.dart b/lib/analytics/google-analytics.dart index 081bd29e..a8252051 100644 --- a/lib/analytics/google-analytics.dart +++ b/lib/analytics/google-analytics.dart @@ -27,7 +27,7 @@ typedef GALogger = Function(String name, {Map parameters}); var _analytics = FirebaseAnalytics(); _logger(String name, {Map parameters}) async { - return; + // return; if (name != null && name.isNotEmpty) { if (name.contains(' ')) name = name.replaceAll(' ', '_'); diff --git a/lib/config/config.dart b/lib/config/config.dart index 082c6bde..a724605b 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/'; diff --git a/lib/pages/BookAppointment/BookSuccess.dart b/lib/pages/BookAppointment/BookSuccess.dart index 693f98e9..e16c618f 100644 --- a/lib/pages/BookAppointment/BookSuccess.dart +++ b/lib/pages/BookAppointment/BookSuccess.dart @@ -544,6 +544,9 @@ class _BookSuccessState extends State { }); } + String _paymentMethod; + String _amount; + openPayment(List paymentMethod, AuthenticatedUser authenticatedUser, double amount, PatientShareResponse patientShareResponse, AppoitmentAllHistoryResultList appo) async { widget.browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart, context: context); @@ -567,6 +570,7 @@ class _BookSuccessState extends State { widget.patientShareResponse.clinicID, widget.patientShareResponse.doctorID, paymentMethod[1]); + _paymentMethod = paymentMethod.first; // } } @@ -600,24 +604,33 @@ class _BookSuccessState extends State { service.checkPaymentStatus(Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), context).then((res) { String paymentInfo = res['Response_Message']; if (paymentInfo == 'Success') { + createAdvancePayment(res, appo); String txn_ref = res['Merchant_Reference']; - String amount = res['Amount']; + String amount = res['Amount'].toString(); String payment_method = res['PaymentMethod']; final currency = projectViewModel.user.outSA == 0 ? "sar" : 'aed'; projectViewModel.analytics.appointment.payment_success( appointment_type: 'regular', payment_method: payment_method, clinic: appo.clinicName, hospital: appo.projectName, txn_amount: "$amount", txn_currency: currency, txn_number: txn_ref); - createAdvancePayment(res, appo); } else { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: res['Response_Message']); + paymentFail("400", res['Response_Message']); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); + paymentFail("400", err.toString()); print(err); }); } + paymentFail(String errorCode, errorMessage){ + final currency = projectViewModel.user.outSA == 0 ? "sar" : 'aed'; + projectViewModel.analytics.advancePayments.payment_fail( + appointment_type: 'livecare', payment_method: _paymentMethod, payment_type: 'appointment', clinic: widget.patientShareResponse.clinicName, hospital: "", txn_amount: widget.patientShareResponse.patientShareWithTax.toString(), txn_currency: currency, error_code: errorCode, error_message: errorMessage + ); + } + getApplePayAPQ(AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index 1b2b4384..74d25f5a 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -296,7 +296,11 @@ class _clinic_listState extends State { }); } + String _paymentMethod; + String _amount; openPayment(List paymentMethod, AuthenticatedUser authenticatedUser, double amount, AppoitmentAllHistoryResultList appo) { + _paymentMethod = paymentMethod.first; + _amount = amount.toString(); browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart, context: context); browser.openPaymentBrowser(amount, "LiveCare Payment", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), "12", authenticatedUser.emailAddress, paymentMethod[0], @@ -337,16 +341,30 @@ class _clinic_listState extends State { String paymentInfo = res['Response_Message']; if (paymentInfo == 'Success') { addNewCallForPatientER(Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo)); + String txn_ref = res['Merchant_Reference']; + String amount = res['Amount'].toString(); + String payment_method = res['PaymentMethod']; + final currency = projectViewModel.user.outSA == 0 ? "sar" : 'aed'; + projectViewModel.analytics.appointment.payment_success( + appointment_type: 'livecare', payment_method: payment_method, clinic: selectedClinicName, hospital: "", payment_type: 'appointment', txn_amount: "$amount", txn_currency: currency, txn_number: txn_ref); } else { AppToast.showErrorToast(message: res['Response_Message']); + paymentFail("400", res['Response_Message'], _amount); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); - print(err); + paymentFail("400", err.toString(),_amount); }); } + paymentFail(String errorCode, errorMessage, String amount,){ + final currency = projectViewModel.user.outSA == 0 ? "sar" : 'aed'; + projectViewModel.analytics.advancePayments.payment_fail( + appointment_type: 'livecare', payment_method: _paymentMethod, payment_type: 'appointment', clinic: selectedClinicName, hospital: "", txn_amount: "$amount", txn_currency: currency, error_code: errorCode, error_message: errorMessage + ); + } + addNewCallForPatientER(String clientRequestID) { LiveCareService service = new LiveCareService(); GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/pages/medical/balance/confirm_payment_page.dart b/lib/pages/medical/balance/confirm_payment_page.dart index fcb893a2..12bcc439 100644 --- a/lib/pages/medical/balance/confirm_payment_page.dart +++ b/lib/pages/medical/balance/confirm_payment_page.dart @@ -407,17 +407,39 @@ class _ConfirmPaymentPageState extends State { String paymentInfo = res['Response_Message']; if (paymentInfo == 'Success') { createAdvancePayment(res, appo); + String txn_ref = res['Merchant_Reference']; + String amount = res['Amount'].toString(); + String payment_method = res['PaymentMethod']; + final currency = projectViewModel.user.outSA == 0 ? "sar" : 'aed'; + + final hospital = widget.advanceModel.hospitalsModel.name; + + projectViewModel.analytics.advancePayments.payment_success( + appointment_type: '', payment_method: payment_method, payment_type: 'wallet', clinic: '', hospital: hospital, txn_amount: "$amount", txn_currency: currency, txn_number: txn_ref + ); } else { GifLoaderDialogUtils.hideDialog(AppGlobal.context); AppToast.showErrorToast(message: res['Response_Message']); + paymentFail("400", paymentInfo); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(AppGlobal.context); AppToast.showErrorToast(message: err); - print(err); + paymentFail("400", err.toString()); }); } + paymentFail(String errorCode, errorMessage){ + + final hospital = widget.advanceModel.hospitalsModel.name; + final amount = widget.advanceModel.amount; + final currency = projectViewModel.user.outSA == 0 ? "sar" : 'aed'; + projectViewModel.analytics.advancePayments.payment_fail( + appointment_type: '', payment_method: widget.selectedPaymentMethod, payment_type: 'wallet', clinic: '', hospital: hospital, txn_amount: "$amount", txn_currency: currency, error_code: errorCode, error_message: errorMessage + ); + + } + createAdvancePayment(res, AppoitmentAllHistoryResultList appo) { DoctorsListService service = new DoctorsListService(); String paymentReference = res['Fort_id'].toString(); diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index b258a7ff..a21028f8 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -33,13 +33,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=';