Exemple #1
0
        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));
        }
Exemple #2
0
        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"));
            }
        }
Exemple #3
0
        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));
        }