protected void Boton_Mercado_Pago_Click(object sender, EventArgs e) { decimal Valor_Carga = LBCDC.Mercado_Pago(TextBox_Mercado_Pago.Text, TextBox_Mercado_Pago_Movil.Text, TextBox_PagoFacil.Text, TextBox_PagoFacil_Movil.Text); // analisis de donde pidio la carga pc o movil if (Valor_Carga == -9) // fallo los botones en javascript { return; } MP mp = new MP("7071654091217780", "F4SUQfv2CA4YUvPj0VsFROGywMkcYvyC"); Hashtable preference = mp.createPreference("{\"items\":[{\"title\":\"clases\",\"quantity\":1,\"currency_id\":\"ARS\",\"unit_price\":" + Valor_Carga + "}],\"external_reference\":\"" + (string)Session["Usuario"] + "\"}"); String accessToken = mp.getAccessToken(); Response.Redirect((((Hashtable)preference["response"])["init_point"]).ToString()); }
private void guardardatos() { String[] Producto; String[] Proveedor; String[] PrecioPesos; String[] PrecioDolar; String[] Cantidad; Decimal totalpreciopesosadicionales = 0; Decimal totalpreciodolaradicionales = 0; Decimal totalpreciopesos= 0; Decimal totalpreciodolar= 0; DataTable dtProductos = new DataTable(); DataTable dtProveedor = new DataTable(); DataTable dtPrecioPesos = new DataTable(); DataTable dtPrecioDolar = new DataTable(); DataTable dtCantidad = new DataTable(); DataSet dsProductos = new DataSet(); DataSet dsProveedor = new DataSet(); DataSet dsPrecioPesos = new DataSet(); DataSet dsPrecioDolar = new DataSet(); DataSet dsCantidad = new DataSet(); DataSet ds = new DataSet(); SqlDataAdapter adapter; String tabla = ""; String preciosindto = ""; Decimal cambio = 0; Decimal valorcambio = 0; DataTable dtFormaPago = new DataTable(); DataSet dsFormaPago = new DataSet(); DataTable dtFactura = new DataTable(); DataSet dsFactura = new DataSet(); try{ dtFormaPago.Columns.Add("TipoPago"); dtFormaPago.Columns.Add("TipoTelefono"); dtFormaPago.Columns.Add("PaisTelefono"); dtFormaPago.Columns.Add("CodAreaTelefono"); dtFormaPago.Columns.Add("NroTelefono"); //FormaPago DataRow row = dtFormaPago.NewRow(); row["TipoPago"] = hdfFormaPago.Value; row["TipoTelefono"] = ddlTipoTelefono.SelectedIndex; row["PaisTelefono"] = ddlPaisTelefono.SelectedIndex; row["CodAreaTelefono"] = txtCodigoAreaCiudad.Text; row["NroTelefono"] = txtNroLocal.Text; dtFormaPago.Rows.Add(row); dsFormaPago.Tables.Add(dtFormaPago); dtFactura.Columns.Add("SituacionFiscal"); dtFactura.Columns.Add("RazonSocial"); dtFactura.Columns.Add("CUILCUIT"); dtFactura.Columns.Add("CodigoPostal"); dtFactura.Columns.Add("Domicilio"); dtFactura.Columns.Add("CiudadDomicilio"); dtFactura.Columns.Add("PaisDomicilio"); dtFactura.Columns.Add("TipoTelefono"); dtFactura.Columns.Add("PaisTelefono"); dtFactura.Columns.Add("CodAreaCiudad"); dtFactura.Columns.Add("NroLocal"); //FormaPago DataRow row1 = dtFactura.NewRow(); row1["SituacionFiscal"] = ddlSituacionFiscal.SelectedIndex; row1["RazonSocial"] = txtNombreoRazonSocial.Text; row1["CUILCUIT"] = txtCuit.Text; row1["CodigoPostal"] = txtCodigoPostal.Text; row1["Domicilio"] = txtDomicilio.Text; row1["CiudadDomicilio"] = txtCiudad.Text; row1["PaisDomicilio"] = ddlPaisTelefono.SelectedIndex; row1["TipoTelefono"] = ddlTipoTelefonoFactura.SelectedIndex; row1["PaisTelefono"] = ddlPaisTelefonoFactura.SelectedIndex; row1["CodAreaCiudad"] = txtCodigoAreaCiudad.Text; row1["NroLocal"] = txtNroLocalFactura.Text; dtFactura.Rows.Add(row1); dsFactura.Tables.Add(dtFactura); Session["InfoFormasdePago"] = dsFormaPago; Session["InfoFactura"] = dsFactura; dtProductos.Columns.Add("IdProductos"); dtProveedor.Columns.Add("IdProveedor"); dtPrecioPesos.Columns.Add("PrecioPesos"); dtPrecioDolar.Columns.Add("PrecioDolar"); dtCantidad.Columns.Add("Cantidad"); Producto = hdfIdProducto.Value.Split('*'); Proveedor = hdfIdProveedor.Value.Split('*'); Cantidad = hdfCantidad.Value.Split('*'); System.Data.SqlClient.SqlConnection conn; conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; conn.Open(); SqlCommand command = new SqlCommand("spselProductosIntangibles", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("IdProveedor", hdfIdProveedor.Value); command.ExecuteNonQuery(); adapter = new SqlDataAdapter(command); adapter.Fill(ds); conn.Close(); conversiondemonedas moneda = new conversiondemonedas(); if ((ds != null) && (ds.Tables[0].Rows.Count > 0)) { for (int j = 0; j < Producto.Count(); j++) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["IdProducto"].ToString() == Producto[j].ToString()) { preciosindto = ds.Tables[0].Rows[i]["Tarifa"].ToString(); cambio = moneda.GetConvertion("ARS", "USD"); valorcambio = Decimal.Round(Convert.ToDecimal(ds.Tables[0].Rows[i]["Tarifa"].ToString()) * cambio, 2); hdfPrecioPesos.Value = hdfPrecioPesos.Value + preciosindto + "*"; hdfPrecioDolar.Value = hdfPrecioDolar.Value + valorcambio + "*"; } } } } PrecioPesos = hdfPrecioPesos.Value.Split('*'); PrecioDolar = hdfPrecioDolar.Value.Split('*'); ds.Dispose(); conn.Close(); if (hdfOpcionAdicionales.Value == "1") { if (Producto.Count() - 1 > 0) { for (int x = 0; x < Producto.Count() - 1; x++) { DataRow row3 = dtProductos.NewRow(); row3["IdProductos"] = Producto[x].ToString(); dtProductos.Rows.Add(row3); DataRow row4 = dtProveedor.NewRow(); row4["IdProveedor"] = Proveedor[x].ToString(); dtProveedor.Rows.Add(row4); DataRow row5 = dtPrecioPesos.NewRow(); row5["PrecioPesos"] = PrecioPesos[x].ToString(); dtPrecioPesos.Rows.Add(row5); DataRow row6 = dtPrecioDolar.NewRow(); row6["PrecioDolar"] = PrecioDolar[x].ToString(); dtPrecioDolar.Rows.Add(row6); DataRow row7 = dtCantidad.NewRow(); row7["Cantidad"] = Cantidad[x].ToString(); dtCantidad.Rows.Add(row7); } } } dsProductos.Tables.Add(dtProductos); dsProveedor.Tables.Add(dtProveedor); dsPrecioPesos.Tables.Add(dtPrecioPesos); dsPrecioDolar.Tables.Add(dtPrecioDolar); dsCantidad.Tables.Add(dtCantidad); Session["Productos"] = dsProductos; Session["Proveedor"] = dsProveedor; Session["PrecioPesos"] = dsPrecioPesos; Session["PrecioDolar"] = dsPrecioDolar; Session["Cantidad"] = dsCantidad; if (PrecioPesos.Count() > 0){ for (int z = 0; z < PrecioPesos.Count()-1 ; z++){ totalpreciopesosadicionales += Convert.ToDecimal(PrecioPesos[z].ToString()); totalpreciodolaradicionales += Convert.ToDecimal(PrecioDolar[z].ToString()); } } totalpreciopesos += totalpreciopesosadicionales + Convert.ToDecimal(lblPrecioPesos.Text); totalpreciodolar += totalpreciodolaradicionales + Convert.ToDecimal(lblPrecioDolar.Text); MP mp = new MP("3592982235689583", "iwzO6CMeOH6gA0dMYnCtvZZo7L6aUYO3"); String url1 = ""; String url2 = ""; String url3 = ""; //url1 = "http://testing.portsoft.com.ar/tusegurodeviaje/pago-confirmado.aspx?op=" + lblFechaSalida.Text + "_" + lblFechaLlegada.Text + "_" + Convert.ToString(totalpreciopesos) + "_" + Convert.ToString(totalpreciodolar) + ""; //url2 = "http://testing.portsoft.com.ar/tusegurodeviaje/pago-pendiente.aspx?op=" + lblFechaSalida.Text + "_" + lblFechaLlegada.Text + "_" + Convert.ToString(totalpreciopesos) + "_" + Convert.ToString(totalpreciodolar) + ""; //url3 = "http://testing.portsoft.com.ar/tusegurodeviaje/pago-fallo.aspx?op=" + lblFechaSalida.Text + "_" + lblFechaLlegada.Text + "_" + Convert.ToString(totalpreciopesos) + "_" + Convert.ToString(totalpreciodolar) + ""; url1 = "http://localhost:50814/pago-confirmado.aspx?op=" + lblFechaSalida.Text + "_" + lblFechaLlegada.Text + "_" + Convert.ToString(totalpreciopesos) + "_" + Convert.ToString(totalpreciodolar) + ""; url2 = "http://localhost:50814/pago-pendiente.aspx?op=" + lblFechaSalida.Text + "_" + lblFechaLlegada.Text + "_" + Convert.ToString(totalpreciopesos) + "_" + Convert.ToString(totalpreciodolar) + ""; url3 = "http://localhost:50814/pago-fallo.aspx?op=" + lblFechaSalida.Text + "_" + lblFechaLlegada.Text + "_" + Convert.ToString(totalpreciopesos) + "_" + Convert.ToString(totalpreciodolar) + ""; String datos = "{\"items\":[{\"title\":\"sdk-dotnet\",\"quantity\":1,\"currency_id\":\"ARS\",\"unit_price\":" + Convert.ToString(totalpreciopesos) + "}] , \"back_urls\":{\"success\": \"" + url1 + "\", \"pending\": \"" + url2 + "\",\"failure\":\"" + url3 + "\"} }"; Hashtable preference = mp.createPreference(datos); Hashtable url = ((Hashtable)preference["response"]); hdfUrl.Value = url["sandbox_init_point"].ToString(); Response.Redirect(url["sandbox_init_point"].ToString()); } catch (Exception ex){ Response.Write(ex.Message); } finally{ } }
/* Create a new preference and verify that data result are ok */ public void createPreference() { JObject preference = mp.createPreference("{'items':[{'title':'create-dotnet','quantity':1,'currency_id':'ARS','unit_price':10.5}]}"); Assert.AreEqual((Int16)preference["status"], 201); Assert.AreEqual((String)preference["response"]["items"][0]["title"], "create-dotnet"); }
/* Create a new preference and verify that data result are ok */ public void createPreference() { // String pref = "{'items':[{'title':'create-dotnet','quantity':1,'currency_id':'ARS','unit_price':10.5}]}"; String pref = "{\"items\":[{\"title\":\"create-dotnet\",\"quantity\":1,\"currency_id\":\"ARS\",\"unit_price\":10.5}]}"; Hashtable preference = mp.createPreference(pref); Assert.AreEqual(preference["status"], 201); Assert.AreEqual(((Hashtable)((ArrayList)((Hashtable)preference["response"])["items"])[0])["title"], "create-dotnet"); }
public Hashtable CrearCobro(CobroEntity[] items) { Hashtable cobro = mp.createPreference(JsonConvert.SerializeObject(items)); //Hashtable cobro = mp.createPreference("{\"items\":[{\"title\":\"sdk-dotnet\",\"quantity\":1,\"currency_id\":\"ARS\",\"unit_price\":10.5}]}"); return(cobro); }
protected void Button2_Click(object sender, EventArgs e) { MP mp = new MP("4736332457228950", "0LWuHjraDil2tQrQN5uwMFaS1vuZMlWt"); Hashtable preference = mp.createPreference("{\"items\":[{\"title\":\"sdk-dotnet\",\"quantity\":1,\"currency_id\":\"ARS\",\"unit_price\":10.5}]}"); Response.Write(preference["response"]); }
public ActionResult PayMercadoPago() { try { Venta oVenta = (Venta)Session["Cart"]; if (oVenta == null || oVenta.DetalleVenta.Count == 0) { return(RedirectToAction("Cart", "Sell")); } string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/"; MP mp = new MP(srvConfig.MP_client_id(), srvConfig.MP_client_secret()); String preferenceData = "{\"items\":["; foreach (DetalleVenta oDetalleVenta in oVenta.DetalleVenta) { // Item preferenceData += "{" + "\"title\":\"" + oDetalleVenta.Producto.nombre + "\"," + "\"quantity\":" + oDetalleVenta.cantidad + "," + "\"currency_id\":\"ARS\"," + "\"category_id\":" + oDetalleVenta.descuento + "," + "\"unit_price\":" + Convert.ToUInt32((oDetalleVenta.precioUnitario) - ((oDetalleVenta.precioUnitario * oDetalleVenta.Producto.descuento) / 100)) + "," + "\"id\":" + oDetalleVenta.idProducto + "," + "\"picture_url\":\"" + baseUrl + "Images/Product/" + oDetalleVenta.Producto.Imagen.Where(x => x.principal == true).FirstOrDefault().archivo + "\"," + "},"; } string stDimensions = srvMetodosGenericos.GetDimensionsProducts(oVenta.DetalleVenta.ToList()); preferenceData += "]," + "\"shipments\":{" + "\"mode\":\"me2\"," + "\"dimensions\":\"" + stDimensions + "\"," + "\"local_pickup\":true," + //"\"free_methods\":[" + // "{\"id\":73328}" + //"]," + "\"default_shipping_method\":73328," + "\"zip_code\":\"5900\"" + "}," + "\"back_urls\":{" + "\"success\": \"" + baseUrl + "Sell/EndPurchase" + "\"" + "}," + "\"auto_return\":\"approved\"," + "}"; Hashtable preference = mp.createPreference(preferenceData); string linkMP = ((Hashtable)preference["response"])["init_point"].ToString(); return(Redirect(linkMP)); } catch (Exception) { Session["Cart"] = null; return(RedirectToAction("Index", "Home")); } }
protected void Page_Load(object sender, EventArgs e) { // https://github.com/mercadopago/sdk-dotnet // tests - sandbox // https://www.mercadopago.com.co/developers/en/solutions/payments/basic-checkout/test/basic-sandbox/ // <a href="<% Response.Write(preference["response"]["sandbox_init_point"]); %>">Pay</a> // production // href="<%= mercadoPreference["response"]["init_point"] %>" if (Session["Payment_ID"] == null || Session["Payment_Total"] == null) { alert.InnerText = "Información de pago no encontrada."; } else { MP mp = new MP(Global.Configuration.Payments.Mercadopago.Basic.GetClientID() , Global.Configuration.Payments.Mercadopago.Basic.GetClientSecret()); if (Global.Configuration.Development.GetIsEnabledDeveloperMode()) { mp.sandboxMode(true); } string accessToken = mp.getAccessToken(); // https://www.mercadopago.com.co/developers/es/solutions/payments/basic-checkout/receive-payments/additional-info/ // Available currencies at: https://api.mercadopago.com/currencies string preferenceData = "{\"items\":" + "[{" + "\"title\":\"Factura\"," + "\"quantity\":1," + "\"currency_id\":\"COP\"," + "\"unit_price\":100.0" + "}]" + "}"; Hashtable preference = mp.createPreference(preferenceData); //paylinkURL = preference["response"]["sandbox_init_point"]; alert.InnerText = Server.HtmlEncode(preference["response"].ToString()); if (Global.Configuration.Development.GetIsEnabledDeveloperMode()) { } else { } } }
public ActionResult DoCheckout() { decimal _saldo = 0; var saldo = Request["saldo"]; Decimal.TryParse(saldo, out _saldo); var pf = new PreferencesMP { items = new List <Items>() { new Items() { currency_id = "ARS", unit_price = _saldo, quantity = 1, title = "Pago de comisión por servicios de ServiEnCasa" } } }; MP mp = new MP(ConfigurationManager.AppSettings["MPClientID"], ConfigurationManager.AppSettings["MPSecret"]); mp.sandboxMode(bool.Parse(ConfigurationManager.AppSettings["MPSandbox"])); var data = new { items = pf.items.Select(i => new { title = i.title, quantity = i.quantity, currency_id = i.currency_id, unit_price = i.unit_price }).ToArray(), back_urls = new { success = Request.Url.DnsSafeHost + ":1230" + Url.RouteUrl("CheckoutStatus"), failure = Request.Url.DnsSafeHost + ":1230" + Url.RouteUrl("CheckoutStatus"), pending = Request.Url.DnsSafeHost + ":1230" + Url.RouteUrl("CheckoutStatus") } }; Hashtable preference = mp.createPreference(JsonConvert.SerializeObject(data)); string MPRefID = (string)((Hashtable)preference["response"])["id"]; var _pago = new Pagos(); _pago.Estado = "Pemdiente"; _pago.Importe = _saldo; _pago.MPRefID = MPRefID; db.Pagos.Add(_pago); db.SaveChanges(); return(Json(new { url = (string)((Hashtable)preference["response"])[ConfigurationManager.AppSettings["MPUrl"]] })); }
public Hashtable CrearCobro() { Hashtable cobro = mp.createPreference("{\"items\":[{\"title\":\"sdk-dotnet\",\"quantity\":1,\"currency_id\":\"ARS\",\"unit_price\":10.5}]}"); return(cobro); }
public ActionResult GenerarReserva(String boxID, String estacionamientoID, String desde, String hasta, String vehiculoSel, ControllerContext context) { // traigo las reservas que tengo de la base de Datos para luego comparar //var reservasDb = _context.Reservas.Include(x => x.Box).ToList(); var tempReserva = new Reserva(); EstadoBox estadoBoxReservado = _context.EstadosBox.SingleOrDefault(y => y.EstadoBoxId == 3); int boxIdInt = Int32.Parse(boxID); Box boxSeleccionado = _context.Boxes.Include(x => x.CategoriaBox).Include(x => x.EstadoBox).SingleOrDefault(x => x.BoxId == boxIdInt); boxSeleccionado.EstadoBox = estadoBoxReservado; DateTime dtDesde = Convert.ToDateTime(desde); DateTime dtHasta = Convert.ToDateTime(hasta); Cliente cliente = (Cliente)Session["user"]; cliente = _context.Cientes.Include(x => x.Vehiculos).SingleOrDefault(p => p.ClienteId == cliente.ClienteId); int vehiculoSelId = Int32.Parse(vehiculoSel); Vehiculo vehiculoSeleccionado = _context.Vehiculos.SingleOrDefault(x => x.VehiculoId == vehiculoSelId); //tempReserva.BoxId = reservaModel.Box.BoxId; var estadoReserva = _context.EstadoReservas.SingleOrDefault(x => x.EstadoReservaId == 1); tempReserva.FechaDesde = dtDesde; tempReserva.FechaHasta = dtHasta; tempReserva.Vehiculo = vehiculoSeleccionado; tempReserva.Box = boxSeleccionado; tempReserva.EstadoReserva = estadoReserva; tempReserva.BoxId = boxSeleccionado.BoxId; _context.Reservas.Add(tempReserva); _context.SaveChanges(); int estacionamientoIdInt = Int32.Parse(estacionamientoID); var estacionamiento = _context.Estacionamientos.SingleOrDefault(x => x.EstacionamientoId == estacionamientoIdInt); var model = new ConfirmacionReservaViewModel() { Box = boxSeleccionado, Cliente = cliente, TipoVehiculoSeleccionado = vehiculoSeleccionado.TipoVehiculo, EstacionamientoSeleccionado = estacionamiento, Vehiculo = vehiculoSeleccionado, Desde = dtDesde, Hasta = dtHasta, MPCheckoutLink = "" }; MP mp = new MP("1289778604132689", "zmbZeSQHeC8Zmb4rFbIBWHAHwm4thyig"); //mp.sandboxMode(true); String preferenceData = "{\"items\":" + "[{" + "\"title\":\"Parkin: " + estacionamiento.Nombre + "\"," + "\"quantity\":1," + "\"currency_id\":\"ARS\"," + "\"unit_price\":10.0" + "}]," + "\"back_urls\": {" + "\"success\": \"http://localhost:49557/Estacionamiento\"," + "\"failure\": \"http://localhost:49557/Estacionamiento\"," + "\"pending\": \"http://localhost:49557/Estacionamiento\"" + "}" + "}"; Hashtable preference = mp.createPreference(preferenceData); Hashtable data = (Hashtable)preference["response"]; String sandboxInitPoint = (String)data["sandbox_init_point"]; model.MPCheckoutLink = sandboxInitPoint; return(View("ConfirmacionReserva", model)); }
public ActionResult Index() { //Nico //MercadoPago.SDK.ClientId = "8668524491166741"; //MercadoPago.SDK.ClientSecret = "4PaR49TQj2gBLMygCWZ5hhK3ITcUGASb"; //dev //mercadopago.SDK.ClientId = "3825884689807039"; //mercadopago.SDK.ClientSecret = "2aLAWWtUxSs4ZbXjSXQRVilQCG1RdSlz"; //MercadoPago.SDK.AccessToken = "TEST-3825884689807039-100215-16400b9b5d9943961c4c3c1242690a8f-357350759"; MP mp = new MP("3825884689807039", "2aLAWWtUxSs4ZbXjSXQRVilQCG1RdSlz"); String preferenceData = "{\"items\":" + "[{" + "\"title\":\"Multicolor kite\"," + "\"quantity\":1," + "\"currency_id\":\"ARS\"," + "\"unit_price\":11" + "}" + "]," + "\"shipments\":{" + "\"mode\":\"me2\"," + "\"dimensions\":\"30x30x30,500\"," + "\"local_pickup\":true," + "\"free_methods\":[" + "{\"id\":73328}" + "]," + "\"default_shipping_method\":73328," + "\"zip_code\":\"5700\"" + "}," + "\"back_urls\":{" + "\"success\": \"https://www.dev-imagine.com\"" + "}," + "\"auto_return\":\"approved\"," + "}"; Hashtable preference = mp.createPreference(preferenceData); // envio // https://api.mercadolibre.com/sites/MLA/shipping_options?zip_code_from=5900&zip_code_to=2550&dimensions=10x10x20,500 // link de pago ViewBag.btnPagar = ((Hashtable)preference["response"])["init_point"].ToString(); // collection id // ViewBag.Collection_id = ((Hashtable)preference["response"])["collection_id"].ToString(); // collection_id // https://api.mercadopago.com/v1/payments/4205733345?access_token=APP_USR-3825884689807039-100215-028a54b7ff4b3017ab7830f35784a693-357350759 //con envio // https://www.dev-imagine.com/?collection_id=4205580523&collection_status=approved&preference_id=357350759-b26bbfb3-7857-496c-a2f9-814a2e4aa084&external_reference=null&payment_type=account_money&merchant_order_id=857112399 //con envio gratis // https://www.dev-imagine.com/?collection_id=4207772795&collection_status=approved&preference_id=357350759-8aa31d01-1c36-481f-9ae2-f521327671f1&external_reference=null&payment_type=account_money&merchant_order_id=858026235 // https://www.dev-imagine.com/?collection_id=4234545208&collection_status=approved&preference_id=357350759-ab6ae775-9a8f-49ee-86ad-0a523c8533c0&external_reference=null&payment_type=account_money&merchant_order_id=870753252 // https://www.dev-imagine.com/?collection_id=4234281281&collection_status=approved&preference_id=357350759-9ead90b3-1c9a-4709-adf7-a2544638cdec&external_reference=null&payment_type=account_money&merchant_order_id=870755027 // costso de envio // https://api.mercadolibre.com/sites/MLA/shipping_options?zip_code_from=5000&zip_code_to=5152&dimensions=10x10x20,500 // Al recibir la notificacion // Obtener topic=payment&id=123456789 // filtrar por topic=payment // Obtener informacion de pago con el id collection_id // https://api.mercadopago.com/v1/payments/4205580523?access_token=APP_USR-3825884689807039-100215-028a54b7ff4b3017ab7830f35784a693-357350759 // del resultado de lo anterior // order.id // https://api.mercadopago.com/merchant_orders/857112399?access_token=APP_USR-3825884689807039-100215-028a54b7ff4b3017ab7830f35784a693-357350759 // y obtenemos todos los datos // Obtener etiqueta de envio // https://api.mercadolibre.com/shipment_labels?shipment_ids=27709894001&response_type=zpl2&access_token=APP_USR-3825884689807039-100215-028a54b7ff4b3017ab7830f35784a693-357350759 return(View()); }
public ActionResult DoCheckout(string data) { var turno = db.HorariosDisponibles.Where(x => x.Id == data).FirstOrDefault(); var pf = new PreferencesMP() { items = new List <Items>() { new Items() { currency_id = "ARS", unit_price = turno.Precio, quantity = 1, title = "Turno Consultorio Virtual " + turno.Dia.ToString() }, }, }; MP mp = new MP(ConfigurationManager.AppSettings["MPClientID"], ConfigurationManager.AppSettings["MPSecret"]); mp.sandboxMode(bool.Parse(ConfigurationManager.AppSettings["MPSandbox"])); var datos = new { items = pf.items.Select(i => new { title = i.title, quantity = i.quantity, currency_id = i.currency_id, unit_price = i.unit_price }).ToArray(), back_urls = new { success = "http://" + Request.Url.Authority + Url.RouteUrl("CheckoutStatus"), failure = "http://" + Request.Url.Authority + Url.RouteUrl("CheckoutStatus"), pending = "http://" + Request.Url.Authority + Url.RouteUrl("CheckoutStatus") } }; Hashtable preference = mp.createPreference(JsonConvert.SerializeObject(datos)); string mprefid = (string)((Hashtable)preference["response"])["id"]; var usuario = User.Identity.GetUserId(); db.Configuration.LazyLoadingEnabled = false; db.Configuration.ProxyCreationEnabled = false; OrdenTurno orden = new OrdenTurno() { ordenitems = new List <OrdenItem>() { new OrdenItem() { currency_id = "ARS", unit_price = turno.Precio, quantity = 1, title = "Turno Consultorio Virtual " + turno.Dia.ToString(), EsValido = false, IdHorarioDisponible = turno.Id }, }, FechaCreacion = DateTime.Now, MPCollectionID = "", Status = "", SessionId = usuario, MPRefID = mprefid }; db.OrdenTurnos.Add(orden); db.SaveChanges(); //string MPRefID = (string)((Hashtable)preference["response"])["id"]; return(Json(new { url = (string)((Hashtable)preference["response"])[ConfigurationManager.AppSettings["MPUrl"]] })); }