public static void CheckPendingPaymentsToConfirm() { try { string baseUrl = string.Format("{0}?ep_cin={1}&ep_user={2}&ep_entity={3}&o_list_type={4}&o_ini={5}" , InsuranceBusiness.BusinessLayer.GetSystemSetting(SystemSettingsEnum.EP_URL_FETCH_ALL_PAYMENT_URL).Value , InsuranceBusiness.BusinessLayer.GetSystemSetting(SystemSettingsEnum.EP_CIN).Value , InsuranceBusiness.BusinessLayer.GetSystemSetting(SystemSettingsEnum.EP_USER).Value , InsuranceBusiness.BusinessLayer.GetSystemSetting(SystemSettingsEnum.EP_ENTITY).Value , "last" , 100); using (var client = new WebClient()) { XmlDocument response = new XmlDocument(); InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.INFO, "WORKER", "TIMER JOB TASK - CheckPendingPaymentsToConfirm", string.Format("Base URL: {0}", baseUrl)); var result = client.DownloadString(baseUrl); response.LoadXml(result); var node = response.SelectSingleNode("get_ref/ep_status"); if (node.InnerText.Equals("ok0")) { // Sucesso int totalPayments = 0; if (!Int32.TryParse(response.SelectSingleNode("get_ref/ep_num_records").InnerText, out totalPayments)) { InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.ERROR, "WORKER", "TIMER JOB TASK - CheckPendingPaymentsToConfirm", string.Format("Cannot count [int32 parse error] received payments. {0}", response.SelectSingleNode("get_ref/ep_num_records").InnerText)); return; } var paymentsList = response.SelectSingleNode("get_ref/ref_detail").SelectNodes("ref"); if (null == paymentsList || paymentsList.Count == 0) { return; } foreach (XmlNode paymentInfo in paymentsList) { PaymentDTO payment = InsuranceBusiness.BusinessLayer.GetPayment(paymentInfo.SelectSingleNode("t_key").InnerText); if (null == payment) { InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.ERROR, "WORKER", "TIMER JOB TASK - CheckPendingPaymentsToConfirm", string.Format("Cannot find payment on database. {0}", paymentInfo.InnerXml)); continue; } if (payment.ID_PaymentStatus == (int)PaymentStatusEnum.PAYED && payment.NotificationSent) { continue; } long notificationId = InsuranceBusiness.BusinessLayer.CreatePaymentNotification(paymentInfo.SelectSingleNode("ep_cin").InnerText, paymentInfo.SelectSingleNode("ep_user").InnerText, paymentInfo.SelectSingleNode("ep_doc").InnerText, paymentInfo.SelectSingleNode("ep_payment_type").InnerText); PaymentNotificationDTO paymentNotification = InsuranceBusiness.BusinessLayer.GetPaymentNotification(notificationId); paymentNotification.ep_date = paymentInfo.SelectSingleNode("ep_date_read").InnerText; paymentNotification.ep_date_transf = paymentInfo.SelectSingleNode("ep_date_transf").InnerText; paymentNotification.ep_key = paymentInfo.SelectSingleNode("ep_key").InnerText; paymentNotification.ep_payment_type = paymentInfo.SelectSingleNode("ep_payment_type").InnerText; paymentNotification.ep_reference = paymentInfo.SelectSingleNode("ep_reference").InnerText; paymentNotification.ep_status = paymentInfo.SelectSingleNode("ep_status_read").InnerText; paymentNotification.ep_value = paymentInfo.SelectSingleNode("ep_value").InnerText; paymentNotification.ep_value_fixed = paymentInfo.SelectSingleNode("ep_value_fixed").InnerText; paymentNotification.ep_value_var = paymentInfo.SelectSingleNode("ep_value_var").InnerText; paymentNotification.ep_value_tax = paymentInfo.SelectSingleNode("ep_value_tax").InnerText; paymentNotification.ep_value_transf = paymentInfo.SelectSingleNode("ep_value_transf").InnerText; paymentNotification.t_key = paymentInfo.SelectSingleNode("t_key").InnerText; paymentNotification.LastChangeDate = DateTime.Now; paymentNotification.NotificationDate = DateTime.Now; payment.LastChangeDate = DateTime.Now; payment.PaymentDate = DateTime.Now; //payment.o_obs = paymentInfo.SelectSingleNode("o_obs").InnerText; //payment.o_email = paymentInfo.SelectSingleNode("o_email").InnerText; //payment.o_mobile = paymentInfo.SelectSingleNode("o_mobile").InnerText; payment.ep_doc = paymentInfo.SelectSingleNode("ep_doc").InnerText; payment.ep_key = paymentInfo.SelectSingleNode("ep_key").InnerText; payment.ID_PaymentStatus = (int)PaymentStatusEnum.PAYED; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); InsuranceBusiness.BusinessLayer.UpdatePaymentNotification(paymentNotification); if (payment.ID_Profile.HasValue) { UserProfileDTO profile = InsuranceBusiness.BusinessLayer.GetUserProfile(payment.ID_Profile.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateUser(payment.ID_Profile.Value); // Send user notification InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, false, payment.ID_Profile.Value, payment.ID); // Get Invoice to send to Client //LibaxUtils.LibaxUtils.CreateInvoice(profile, payment); // Send user email new NotificationsManagementController().SendPaymentConfirmationEmail(string.Format("{0} {1}", profile.FirstName, profile.LastName), profile.User.UserName, null); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); } else if (payment.ID_Garage.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_Garage.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateGarage(payment.ID_Garage.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_Garage.Value, payment.ID, CompanyTypeEnum.GARAGE); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email new NotificationsManagementController().SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today new NotificationsManagementController().RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_ConstructionCompany.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_ConstructionCompany.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateConstructionCompany(payment.ID_ConstructionCompany.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_ConstructionCompany.Value, payment.ID, CompanyTypeEnum.CONSTRUCTION_COMPANY); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email new NotificationsManagementController().SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today new NotificationsManagementController().RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_HomeApplianceRepair.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_HomeApplianceRepair.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateHomeApplianceRepair(payment.ID_HomeApplianceRepair.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_HomeApplianceRepair.Value, payment.ID, CompanyTypeEnum.HOME_APPLIANCES_REPAIR); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email new NotificationsManagementController().SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today new NotificationsManagementController().RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_InsuranceCompanyContact.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_InsuranceCompanyContact.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateInsuranceCompanyContact(payment.ID_InsuranceCompanyContact.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_InsuranceCompanyContact.Value, payment.ID, CompanyTypeEnum.INSURANCE_COMPANY_CONTACT); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email new NotificationsManagementController().SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today new NotificationsManagementController().RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_MedicalClinic.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_MedicalClinic.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateMedicalClinic(payment.ID_MedicalClinic.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_MedicalClinic.Value, payment.ID, CompanyTypeEnum.MEDICAL_CLINIC); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email new NotificationsManagementController().SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today new NotificationsManagementController().RequestDirectDebitOrder(payment, baseUrl); } } } else { // Erro InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.ERROR, "WORKER", "TIMER JOB TASK - CheckPendingPaymentsToConfirm", response.SelectSingleNode("get_ref/ep_message").InnerText); return; } } } catch (Exception ex) { InsuranceBusiness.BusinessLayer.LogException("WORKER", "TIMER JOB TASK - CheckPendingPaymentsToConfirm", ex); } }
public void EasypayPaymentNotification(string ep_cin, string ep_user, string ep_doc, string ep_type) { try { PaymentDTO payment = null; //payment = InsuranceBusiness.BusinessLayer.GetPayment(54); //CompanyDTO company2 = InsuranceBusiness.BusinessLayer.GetGarage(7); //byte[] invoiceDocument2 = LibaxUtils.LibaxUtils.CreateInvoice(company2, payment); //FileStream fs = new FileStream(@"c:\temp\fatura.pdf", FileMode.OpenOrCreate); //fs.Write(invoiceDocument2, 0, invoiceDocument2.Length); //fs.Close(); //return; InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.INFO, "", string.Format("Easypay payment notification received"), string.Format("Easypay infromation received is ep_cin {0}, ep_user {1}, ep_doc {2}, ep_type {3}", ep_cin, ep_user, ep_doc, ep_type)); long notificationId = InsuranceBusiness.BusinessLayer.CreatePaymentNotification(ep_cin, ep_user, ep_doc, ep_type); if (notificationId <= 0) { InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.ERROR, string.Format("{0}", Request.UserHostAddress), string.Format("{0}.{1}", this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()), string.Format("Cannot create notification. {0}, {1}, {2}, {3}", ep_cin, ep_user, ep_doc, ep_type)); return; } PaymentNotificationDTO paymentNotification = InsuranceBusiness.BusinessLayer.GetPaymentNotification(notificationId); string baseUrl = string.Format("{0}?ep_cin={1}&ep_user={2}&ep_doc={3}" , InsuranceBusiness.BusinessLayer.GetSystemSetting(SystemSettingsEnum.EP_URL_FETCH_PAYMENT_DETAIL_URL).Value , ep_cin , ep_user , ep_doc); if (!string.IsNullOrEmpty(ep_type)) { baseUrl += string.Format("&ep_type={0}", ep_type); } using (var client = new WebClient()) { XmlDocument response = new XmlDocument(); InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.INFO, Request.UserHostAddress, "NotificationsManagementController::EasypayPaymentNotification", baseUrl); var result = client.DownloadString(baseUrl); response.LoadXml(result); var node = response.SelectSingleNode("getautoMB_detail/ep_status"); if (node.InnerText.Equals("ok0")) { // Sucesso // Update Notification information paymentNotification.ep_date = response.SelectSingleNode("getautoMB_detail/ep_date_read").InnerText; paymentNotification.ep_date_transf = response.SelectSingleNode("getautoMB_detail/ep_date_transf").InnerText; paymentNotification.ep_key = response.SelectSingleNode("getautoMB_detail/ep_key").InnerText; paymentNotification.ep_payment_type = response.SelectSingleNode("getautoMB_detail/ep_payment_type").InnerText; paymentNotification.ep_reference = response.SelectSingleNode("getautoMB_detail/ep_reference").InnerText; paymentNotification.ep_status = response.SelectSingleNode("getautoMB_detail/ep_status_read").InnerText; paymentNotification.ep_value = response.SelectSingleNode("getautoMB_detail/ep_value").InnerText; paymentNotification.ep_value_fixed = response.SelectSingleNode("getautoMB_detail/ep_value_fixed").InnerText; paymentNotification.ep_value_var = response.SelectSingleNode("getautoMB_detail/ep_value_var").InnerText; paymentNotification.ep_value_tax = response.SelectSingleNode("getautoMB_detail/ep_value_tax").InnerText; paymentNotification.ep_value_transf = response.SelectSingleNode("getautoMB_detail/ep_value_transf").InnerText; paymentNotification.t_key = response.SelectSingleNode("getautoMB_detail/t_key").InnerText; paymentNotification.LastChangeDate = DateTime.Now; paymentNotification.NotificationDate = DateTime.Now; payment = InsuranceBusiness.BusinessLayer.GetPayment(paymentNotification.t_key); if (null == payment || payment.ep_cin != ep_cin || payment.ep_user != ep_user) { InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.ERROR, string.Format("{0}", Request.UserHostAddress), string.Format("{0}.{1}", this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()), string.Format("Easypay payment information doesn't match Payment information. {0}, {1}, {2}, {3}", ep_cin, ep_user, ep_doc, ep_type)); return; } if (payment.ID_PaymentStatus == (int)PaymentStatusEnum.PAYED && payment.NotificationSent) { InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.WARNING, string.Format("{0}", Request.UserHostAddress), string.Format("{0}.{1}", this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()), string.Format("Payment already payed and notification sent. {0}, {1}, {2}, {3}", ep_cin, ep_user, ep_doc, ep_type)); return; } payment.LastChangeDate = DateTime.Now; payment.PaymentDate = DateTime.Now; payment.o_obs = response.SelectSingleNode("getautoMB_detail/o_obs").InnerText; payment.o_email = response.SelectSingleNode("getautoMB_detail/o_email").InnerText; payment.o_mobile = response.SelectSingleNode("getautoMB_detail/o_mobile").InnerText; payment.ep_doc = response.SelectSingleNode("getautoMB_detail/ep_doc").InnerText; payment.ep_key = response.SelectSingleNode("getautoMB_detail/ep_key").InnerText; payment.ID_PaymentStatus = (int)PaymentStatusEnum.PAYED; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); InsuranceBusiness.BusinessLayer.UpdatePaymentNotification(paymentNotification); } else { // Erro InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.ERROR, string.Format("{0}", Request.UserHostAddress), string.Format("{0}.{1}", this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()), string.Format("Easypay returned error fetching payment details: {0} {1}, {2}, {3}, {4}", result, ep_cin, ep_user, ep_doc, ep_type)); payment = InsuranceBusiness.BusinessLayer.GetPayment(paymentNotification.t_key); if (null == payment || payment.ep_cin != ep_cin || payment.ep_user != ep_user) { InsuranceBusiness.BusinessLayer.Log(SystemLogLevelEnum.ERROR, string.Format("{0}", Request.UserHostAddress), string.Format("{0}.{1}", this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()), string.Format("Easypay payment information doesn't match Payment information. {0}, {1}, {2}, {3}", ep_cin, ep_user, ep_doc, ep_type)); return; } //payment = InsuranceBusiness.BusinessLayer.GetPayment(paymentNotification.t_key); payment.LastChangeDate = DateTime.Now; payment.Message = response.InnerXml; payment.ID_PaymentStatus = (int)PaymentStatusEnum.ERROR; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); return; } } if (payment.ID_Profile.HasValue) { UserProfileDTO profile = InsuranceBusiness.BusinessLayer.GetUserProfile(payment.ID_Profile.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateUser(payment.ID_Profile.Value); // Send user notification InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, false, payment.ID_Profile.Value, payment.ID); // Get Invoice to send to Client //LibaxUtils.LibaxUtils.CreateInvoice(profile, payment); // Send user email SendPaymentConfirmationEmail(string.Format("{0} {1}", profile.FirstName, profile.LastName), profile.User.UserName, null); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); } else if (payment.ID_Garage.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_Garage.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateUser(company.ID_User); InsuranceBusiness.BusinessLayer.ActivateGarage(payment.ID_Garage.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_Garage.Value, payment.ID, CompanyTypeEnum.GARAGE); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_ConstructionCompany.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_ConstructionCompany.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateUser(company.ID_User); InsuranceBusiness.BusinessLayer.ActivateConstructionCompany(payment.ID_ConstructionCompany.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_ConstructionCompany.Value, payment.ID, CompanyTypeEnum.CONSTRUCTION_COMPANY); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_HomeApplianceRepair.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_HomeApplianceRepair.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateUser(company.ID_User); InsuranceBusiness.BusinessLayer.ActivateHomeApplianceRepair(payment.ID_HomeApplianceRepair.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_HomeApplianceRepair.Value, payment.ID, CompanyTypeEnum.HOME_APPLIANCES_REPAIR); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_InsuranceCompanyContact.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_InsuranceCompanyContact.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateUser(company.ID_User); InsuranceBusiness.BusinessLayer.ActivateInsuranceCompanyContact(payment.ID_InsuranceCompanyContact.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_InsuranceCompanyContact.Value, payment.ID, CompanyTypeEnum.INSURANCE_COMPANY_CONTACT); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today RequestDirectDebitOrder(payment, baseUrl); } else if (payment.ID_MedicalClinic.HasValue) { CompanyDTO company = InsuranceBusiness.BusinessLayer.GetGarage(payment.ID_MedicalClinic.Value); // Activate user InsuranceBusiness.BusinessLayer.ActivateUser(company.ID_User); InsuranceBusiness.BusinessLayer.ActivateMedicalClinic(payment.ID_MedicalClinic.Value); // Send user notification //InsuranceBusiness.BusinessLayer.CreateNotificationForPaymentDone(NotificationTypeEnum.PAYMENT_CONFIRMED, true, payment.ID_MedicalClinic.Value, payment.ID, CompanyTypeEnum.MEDICAL_CLINIC); // Get Invoice to send to Client byte[] invoiceDocument = LibaxUtils.LibaxUtils.CreateInvoice(company, payment); // Send user email SendPaymentConfirmationEmail(company.Name, company.ContactEmail, invoiceDocument, payment.ID); payment.NotificationSent = true; InsuranceBusiness.BusinessLayer.UpdatePayment(payment); // Request Direct Debit payment - schedule for one year later since today RequestDirectDebitOrder(payment, baseUrl); } } catch (Exception ex) { InsuranceBusiness.BusinessLayer.LogException(string.Format("{0} [{1}]", Request.UserHostAddress, string.Format("ep_cin={0}&ep_user={1}&ep_doc={2}", ep_cin, ep_user, ep_doc)), string.Format("{0}.{1}", this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()), ex); return; } }