public async Task <IHttpActionResult> GetBanks() { CustomDelegatingHandler customDelegatingHandler = new CustomDelegatingHandler(); HttpClient client = HttpClientFactory.Create(customDelegatingHandler); // var bodyString = "{\"Services\": {\"ServiceList\": [{\"Name\": \"emandate\",\"Action\": \"GetIssuerList\"}]}}"; //object body = Newtonsoft.Json.JsonConvert.DeserializeObject<object>(bodyString); ServicesRoot body = new ServicesRoot(); body.Services = new ServicesObject(); body.Services.ServiceList = new List <ServiceList>() { new ServiceList() { Name = "emandate", Action = "GetIssuerList" } }; HttpResponseMessage response = await client.PostAsJsonAsync(apiBaseAddress, body); var result = response.Content.ReadAsStringAsync().Result; var resultObject = Newtonsoft.Json.JsonConvert.DeserializeObject <ServicesObject>(result); return(Ok(resultObject.Services.FirstOrDefault().Parameters)); }
public async Task <List <string> > ListServices(bool includeSystemFolders = false) { Uri endpoint = new Uri(ServerUrl, "services"); ServicesRoot servicesRoot = await GetStringAsync <ServicesRoot>(endpoint, null); List <string> listService = new List <string>(); foreach (Service s in servicesRoot.services) { listService.Add(string.Format("{0}.{1}", s.serviceName, s.type)); } var folders = (from folderDetail in servicesRoot.foldersDetail select folderDetail.folderName); if (!includeSystemFolders) { folders = (from folder in folders where folder != "System" && folder != "Utilities" select folder); } foreach (string f in folders) { endpoint = new Uri(ServerUrl, string.Format("services/{0}", f)); JObject x = await GetStringAsync(endpoint, null); JArray a = (JArray)x.SelectToken("services"); foreach (JObject obj in a) { Service s = obj.ToObject <Service>(); listService.Add(string.Format("{0}/{1}.{2}", s.folderName, s.serviceName, s.type)); } } return(listService); }
public async Task <IHttpActionResult> UpdateStatus(long userID, string mandateId) { CustomDelegatingHandler customDelegatingHandler = new CustomDelegatingHandler(); HttpClient client = HttpClientFactory.Create(customDelegatingHandler); ServicesRoot body = new ServicesRoot(); body.Services = new ServicesObject(); body.Services.ServiceList = new List <ServiceList>() { new ServiceList() { Name = "emandate", Action = "GetStatus", Parameters = new List <ParameterObject>() { new ParameterObject() { Name = "mandateid", Value = mandateId } } } }; var user = _registerUser.Get(userID); if (user.IsMailSend) { return(BadRequest("Mail was send")); } HttpResponseMessage response = await client.PostAsJsonAsync(apiBaseAddress, body); var result = response.Content.ReadAsStringAsync().Result; if (user.MandateId == mandateId) { var resultObject = Newtonsoft.Json.JsonConvert.DeserializeObject <ServicesObject>(result); PaymentStatusEnumDto enumStatus; if (Enum.TryParse(resultObject.Services.FirstOrDefault().Parameters.Where(m => { return(m.Name == "EmandateStatus"); }).FirstOrDefault().Value, out enumStatus)) { string IBAN = resultObject.Services.FirstOrDefault().Parameters.Where(m => { return(m.Name == "Iban"); })?.FirstOrDefault()?.Value; user.IBAN = IBAN; user.Amount = resultObject.Services.FirstOrDefault().Parameters.Where(m => { return(m.Name == "MaxAmount"); })?.FirstOrDefault()?.Value; string modelXml = ""; XmlSerializator.XmlSerialize(user, ref modelXml); string xslt = Convert.ToString(Lips.Tool.Properties.Resources.PaymentNewClient); MailSend.SendMail(modelXml, xslt, user.Email, "WasApp " + user.Name + " - New user"); xslt = Convert.ToString(Lips.Tool.Properties.Resources.PaymentLastStatusClient); if (enumStatus == PaymentStatusEnumDto.Success) { MailSend.SendMail(modelXml, xslt, user.Email, "Ontvangstbevestiging van uw betaling"); xslt = Convert.ToString(Lips.Tool.Properties.Resources.PaymentNewClientLips); if (MailSend.SendMail(modelXml, xslt, ConfigurationManager.AppSettings["mail"], $"Automatische incasso {user.Name}, {user.InstitutionId}")) { user.IsMailSend = true; } } // else if (enumStatus == PaymentStatusEnumDto.Failure) // { // MailSend.SendMail(modelXml, xslt, user.Email, "WasApp " + user.Name + "- payment " + user.MandateId + " failured"); // } // else if (enumStatus == PaymentStatusEnumDto.Failure) // { // MailSend.SendMail(modelXml, xslt, user.Email, "WasApp " + user.Name + "- payment " + user.MandateId + " cancelled"); // } user.PaymentStatus = enumStatus; _registerUser.Update(user); return(Ok(resultObject.Services.FirstOrDefault().Parameters.Where(m => { return m.Name == "EmandateStatus"; }))); } else { return(BadRequest("Wrong Payment status")); } } else { return(BadRequest("Wrong MandateID")); } }
public async Task <IHttpActionResult> CreateMandate(string bank, RegisterUserDto user) { CustomDelegatingHandler customDelegatingHandler = new CustomDelegatingHandler(); HttpClient client = HttpClientFactory.Create(customDelegatingHandler); // var bodyString = "{\"Services\": {\"ServiceList\": [{\"Name\": \"emandate\",\"Action\": \"GetIssuerList\"}]}}"; //object body = Newtonsoft.Json.JsonConvert.DeserializeObject<object>(bodyString); ServicesRoot body = new ServicesRoot(); body.Currency = "EUR"; body.Services = new ServicesObject(); body.Services.ServiceList = new List <ServiceList>() { new ServiceList() { Name = "emandate", Action = "CreateMandate", Parameters = new List <ParameterObject> { new ParameterObject() { Name = "emandatereason", Value = "testing" }, new ParameterObject() { Name = "sequencetype", Value = "1" }, new ParameterObject() { Name = "purchaseid", Value = "purchaseid1234" }, new ParameterObject() { Name = "debtorbankid", Value = bank }, new ParameterObject() { Name = "debtorreference", Value = "klant1234" }, new ParameterObject() { Name = "language", Value = "nl" }, // new ParameterObject() // { // Name="maxamount", // Value =amount // } } } }; HttpResponseMessage response = await client.PostAsJsonAsync(apiBaseAddress, body); var result = response.Content.ReadAsStringAsync().Result; var resultObject = Newtonsoft.Json.JsonConvert.DeserializeObject <ServicesObject>(result); CreateMandateResult = new { Redirect = resultObject.RequiredAction.RedirectURL, EmandateId = resultObject.Services.FirstOrDefault().Parameters.FirstOrDefault().Value, User = user.Id }; user.MandateId = resultObject.Services.FirstOrDefault().Parameters.FirstOrDefault().Value; user.PaymentStatus = PaymentStatusEnumDto.Pending; _registerUser.UpdateByGuid(user); return(Ok(CreateMandateResult)); }