protected void Page_Load(object sender, EventArgs e)
        {
            //Recivimos el json, verificar si mandamos mas datos.
            string json = Request.QueryString["details"];
            //Instancia al using para deserealizar json
            JavaScriptSerializer js = new JavaScriptSerializer();
            //Instancia de la clase paypal
            paypal oUser = js.Deserialize <paypal>(json);

            //Logica para convertir a Byte lo que recivimos de la base 64
            byte[] data = System.Convert.FromBase64String(oUser.status);
            //Lo volvemos al lenguaje español
            oUser.status = System.Text.ASCIIEncoding.ASCII.GetString(data);
            //Se aplica lo mismo
            data     = System.Convert.FromBase64String(oUser.id);
            oUser.id = System.Text.ASCIIEncoding.ASCII.GetString(data);
            //Listo ya funciona
            pe = (Paypal)Session["myOrderingEntity"];
            string idVenta     = pe.idVenta;
            string orderStatus = oUser.status;
            string orderID     = oUser.id;

            if (orderStatus == "COMPLETED")
            {
                //Rutina para actualizar tabla
                try
                {
                    books.UpdEstatusVentaPaypal(idVenta, orderID);
                    //Label1.Text = "Tu compra ha sido autorizada con el siguiente número de orden: " + orderID +", ya puedes descargar el libro";
                    Response.Redirect("~/Forms/MisCompras.aspx");
                }
                catch (Exception ex)
                {
                    Label1.Text = "Algo salió mal " + ex.Message;
                    throw;
                }
            }
            else
            {
                Label1.Text         = orderStatus;
                btnRegresar.Visible = true;
                ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "NoProcess();", true);
            }
        }
Esempio n. 2
0
        public void UpdatePagoPaypal(string IDVenta, string OrderID)
        {
            LibrosDAO DAOLibros = new LibrosDAO();
            DataTable dt        = new DataTable();
            string    outputJSON;
            int       value = 0;

            try
            {
                DAOLibros.UpdEstatusVentaPaypal(IDVenta, OrderID);
                value = 1;
            }
            catch (Exception)
            {
                value = 0;
            }
            JsonResult OBJson = new JsonResult
            {
                Result = value
            };

            outputJSON = ser.Serialize(OBJson);
            Context.Response.Write(ser.Serialize(OBJson));
        }