public tbPayment ActualizarPayment()
        {
            //Inserto en payment detail el post del proveedor
            tbPaymentDetail paymentDetailPost = this.InsertPaymentDetail("POST_VENDOR");

            //Inserto en payment detail el request que voy a realizar a SimpleQueryTx
            tbPaymentDetail paymentDetailSimpleQuery = this.InsertPaymentDetail("SIMPLE_QUERY_TX");

            //Consulto el estado del pago
            NpsBusiness npsBusiness      = new NpsBusiness();
            tbPayment   paymentNpsResult = npsBusiness.ConsultarEstadoDelPago(_transactionId, _idPayment, paymentDetailSimpleQuery);

            //Actualizo tbPaymentDetails
            paymentDetailSimpleQuery = this.UpdatePaymentDetail(paymentDetailSimpleQuery);

            //Obtengo el registro del pago
            tbPayment payment = this.ObtengoPaymentPorId();

            //Actualizo registro del pago, con estado del pago y la informacion adicional
            payment.pst_id = paymentNpsResult.pst_id;
            payment.pay_informacion_adicional = paymentNpsResult.pay_informacion_adicional;
            payment = this.UpdatePayment(payment);

            return(payment);
        }
Beispiel #2
0
        public tbPayment GenerarFormularioDePago()
        {
            try
            {
                //Creo el registro en la tabla payment
                tbPayment payment = this.CreatePayment();

                //Creo el detalle del pago
                tbPaymentDetail paymentDetail = this.CreatePaymentDetail(payment);

                //Creo el formulario de pago
                NpsBusiness npsBusiness    = new NpsBusiness();
                string      urlPaymentForm = npsBusiness.CreateForm(payment.pay_id, _monto, _producto, _cuotas, paymentDetail);

                //Actualizo payment detail
                paymentDetail = this.UpdatePaymentDetail(paymentDetail);

                //Actualizo el payment con el formulario de pagos si no retorno nulo
                if (!string.IsNullOrEmpty(urlPaymentForm))
                {
                    //Valido que NPS retorne una url, sino es porque arrojo error y lo dejo registrado en tbPayment
                    //y no envío el mail
                    if (urlPaymentForm.Contains("http"))
                    {
                        //Asigno la url del formulario de pago de la app cliente
                        string vueAppUrl = ConfigurationManager.AppSettings["VUE_APP_URL_FORM"] + "/" + payment.pay_id.ToString();

                        //Actualizo payment con el formulario de pago
                        payment.pay_url_formulario        = urlPaymentForm;
                        payment.pay_url_formulario_custom = vueAppUrl;
                        payment.pst_id = (int)EnumPaymentStatus.PENDIENTE;
                        payment        = this.UpdatePayment(payment);

                        //envio e-mail
                        this.SendEmamil(vueAppUrl);

                        //Actualizo payment con el contador de envio de mails
                        payment.pay_cantidad_mails_enviados++;
                        payment = this.UpdatePayment(payment);
                    }
                    else
                    {
                        //Actualizo payment con el error que arrojo NPS
                        payment.pay_informacion_adicional = urlPaymentForm;
                        payment.pst_id = (int)EnumPaymentStatus.ERROR;
                        payment        = this.UpdatePayment(payment);
                    }
                }

                return(payment);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public object Post(VendorPaymentFormModel model)
        {
            try
            {
                NpsBusiness npsBusiness = new NpsBusiness();
                string      result      = npsBusiness.CreateForm(0, 1000, 14, 6, new Entities.tbPaymentDetail());

                if (result != null)
                {
                    model.urlPaymentForm = result;
                    return(Request.CreateResponse(HttpStatusCode.Created, model));
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            catch (Exception ex)
            {
                log.Error("Mensaje de error: " + ex.Message);
                if (ex.InnerException != null)
                {
                    log.Error("Inner exception" + ex.InnerException.Message);
                }
                throw ex;
            }
        }