Esempio n. 1
0
        // GET: Vendedores/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Vendedor vendedor = await _vendedoresService.GetVendedorById(id);

            if (vendedor == null)
            {
                return(NotFound());
            }
            return(View(vendedor));
        }
Esempio n. 2
0
        public async Task <IActionResult> Confirmar(int?id, int opcionElegida)
        {
            Usuario usuario = await _usuariosService.GetUsuarioByActiveIdentityUser(_userManager.GetUserId(User));

            Producto producto = await _productosService.GetProductoById(id);

            List <OpcionProducto> opciones = await _opcionesProductosService.GetOpcionProductoById(id);

            OpcionProducto   opcion           = opciones[opcionElegida - 1];
            ProductoVendedor productoVendedor = producto.ProductoVendedor[0];
            Vendedor         vendedor         = await _vendedoresService.GetVendedorById(productoVendedor.VendedorId);

            UsuarioProductoVM modelo = new UsuarioProductoVM
            {
                producto = producto,
                usuario  = usuario,
                opcion   = opcion
            };
            int   precioFinal = Convert.ToInt32(opcion.PrecioFinal * 100);
            float fee         = vendedor.Fee;
            int   helduFee    = Convert.ToInt32(precioFinal * (fee / 100));

            StripeConfiguration.ApiKey = "sk_test_51GvJEQL9UURBAADxXJtmn6ZmPepnp0Bkt4Hwl3y53I7rjWCQKa4wj3FSfkm2V4ZOIV67I6LQDmfvPmZ16eMh9LcE0057FViwnl";

            var service       = new PaymentIntentService();
            var createOptions = new PaymentIntentCreateOptions
            {
                PaymentMethodTypes = new List <string>
                {
                    "card",
                },
                Amount               = precioFinal,
                Currency             = "eur",
                ApplicationFeeAmount = helduFee,
                ReceiptEmail         = "*****@*****.**",

                Metadata = new Dictionary <string, string>
                {
                    { "ProductoId", Convert.ToString(producto.Id) },
                    { "Producto", producto.Titulo },
                    { "OpcionId", opcion.Id.ToString() },
                    { "Opcion", opcion.Descripcion },
                    { "PrecioOriginal", opcion.PrecioInicial.ToString() },
                    { "UsuarioId", Convert.ToString(usuario.Id) },
                    { "Usuario", usuario.NombreUsuario },
                    { "VendedorId", vendedor.Id.ToString() },
                    { "Vendedor", vendedor.NombreDeEmpresa }
                },
                TransferData = new PaymentIntentTransferDataOptions()
                {
                    Destination = "acct_1H08zjLhTBm3kv5q"
                },
                //TransferData = new PaymentIntentTransferDataOptions
                //{
                //     Destination = "acct_1H08zjLhTBm3kv5q",
                //},
            };
            var intent = service.Create(createOptions);

            ViewData["ClientSecret"] = intent.ClientSecret;

            return(View(modelo));
        }