Beispiel #1
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 #2
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;
            }
        }