Ejemplo n.º 1
0
        public void CreatePaymentRelease()
        {
            var rep = new PaymentReleaseRepository();

            var paymentRelease = new PaymentRelease()
            {
                OrderIdentifier = new OrderIdentifier("27567", "108751"),
                PAYMENT_RELEASE = 1
            };

            rep.Insert(paymentRelease);
        }
Ejemplo n.º 2
0
        public IHttpActionResult CreatePaymentRelease([FromBody] PaymentReleaseData data)
        {
            string apiKey;

            try
            {
                apiKey = data.header.apikey;
            }
            catch (System.Exception)
            {
                logger.Log(ErrorType.ERR, "CreatePaymentRelease()", RequestContext.Principal.Identity.Name, "API key is missing.", "api/woood-payment-release/create");

                return(Content(HttpStatusCode.Unauthorized, "API key is missing."));
            }

            var user = userRepository.GetByUsername(data.header.username);

            if (apiKey != user.ApiKey)
            {
                logger.Log(ErrorType.ERR, "CreatePaymentRelease()", RequestContext.Principal.Identity.Name, "API key is not correct. Get a right API key from the service provider.", "api/woood-payment-release/create");

                return(Content(HttpStatusCode.Unauthorized, "API key is not correct. Get a right API key from the service provider."));
            }

            if (!ModelState.IsValid)
            {
                logger.Log(ErrorType.ERR, "CreatePaymentRelease()", RequestContext.Principal.Identity.Name, ModelState.ToString(), "api/woood-payment-release/create");

                return(BadRequest(ModelState));
            }

            try
            {
                var orderIdentifier = new OrderIdentifier(data.body.REFERENTIE, data.body.DEBITEURNR);

                var existingOrders = orderRepository.GetByIdentifier(orderIdentifier);
                if (existingOrders.Count() == 0)
                {
                    logger.Log(ErrorType.ERR, "CreatePaymentRelease()", RequestContext.Principal.Identity.Name, "DEBITEURNR-REFERENTIE UNKNOWN", "api/woood-payment-release/create");

                    return(Content(HttpStatusCode.BadRequest, "DEBITEURNR-REFERENTIE UNKNOWN"));
                }

                var paymentToPost = new APIWoood.Logic.Models.PaymentRelease()
                {
                    OrderIdentifier = orderIdentifier,
                    PAYMENT_RELEASE = data.body.PAYMENT_RELEASE,
                };

                paymentReleaseRepository.Insert(paymentToPost);

                logger.Log(ErrorType.INFO, "CreatePaymentRelease()", RequestContext.Principal.Identity.Name, "The Release Payment was succesfully added", "api/woood-payment-release/create", startDate);

                return(Ok(new
                {
                    body = new
                    {
                        message = "The Release Payment was succesfully added"
                    }
                }));
            }
            catch (Exception e)
            {
                logger.Log(ErrorType.ERR, "CreatePaymentRelease()", RequestContext.Principal.Identity.Name, e.Message, "api/woood-payment-release/create");

                return(InternalServerError(e));
            }
        }