Esempio n. 1
0
        public async Task <IHttpActionResult> CancelAndRefund([FromBody] Payment valPayment)
        {
            string vResult = "4";

            IPaymentData vPaymentData = new PaymentData();

            try {
                bool vNullField = VerifyNullFiledsCancelAndRefund(valPayment);
                if (vNullField)
                {
                    vResult = "2";
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotAcceptable, new { Code = HttpStatusCode.NotAcceptable, Message = Messages.vListContainNullValue, Result = vResult })));
                }
                string vResponse = await vPaymentData.CancelAndRefund(valPayment);

                if (!string.IsNullOrEmpty(vResponse))
                {
                    if (vResponse == "1")
                    {
                        return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, new { Code = HttpStatusCode.OK, Message = Messages.vOkUpdated, Result = vResponse })));
                    }
                    else if (vResponse == "3")
                    {
                        return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, new { Code = HttpStatusCode.InternalServerError, Message = Messages.vCancelPaymentError, Result = vResponse })));
                    }
                    else if (vResponse != "4")
                    {
                        return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, new { Code = HttpStatusCode.InternalServerError, Message = Messages.vPaymentGatewayError, Result = vResponse })));
                    }
                }
            } catch (Exception vEx) {
                string vMessage = vEx.Message;
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, new { Code = HttpStatusCode.InternalServerError, Message = Messages.vInternalServerError, Result = vResult })));
            }
            return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, new { Code = HttpStatusCode.BadRequest, Message = Messages.vNotInserted, Result = vResult })));
        }