Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
Avoid user touching HTML or JS in payment page

I'm testing stripe API and I'm wondering how to avoid that user changes prices by HTML and/or javascript code?

As you can see in my code, anybody with a bit of coding knowledge could change price value in the input #price, input checkboxes, or even directly change it in console with $("#price").val(some_value);

HTML SAMPLE CODE

<form id="articles_form">
    <div>
        <div>
            <label for="one_article">One Article</label>
            <input class="articles" type="checkbox" name="one_article" id="one_article" value="90">
        </div>
        <div>
            <label for="another_article">Another Article</label>
            <input class="articles" type="checkbox" name="another_article" id="another_article" value="75">
        </div>
</form>

<form action="payment_form.php" method="post" id="payment-form">
    <div class="form-row">
        <input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
        <input type="hidden" name="price" id="price" value="">
        <input type="hidden" name="products" id="products">
        <input type="text" name="first_name" class="form-control StripeElement StripeElemet--empty" placeholder="Name">
        <input type="text" name="last_name" class="form-control StripeElement StripeElemet--empty" placeholder="Surname">
        <input type="email" name="email" class="form-control StripeElement StripeElemet--empty" placeholder="Email">
    </div>
</form>

JS SAMPLE CODE

<script>
$(".articles").each(function(){
    $(this).on("change", function(){
        let value = 0;
        let products = '';
        $(".articulos").each(function(){
            if(this.checked == true){
                value = parseInt($(this).val()) + value;
                products = $(this).attr("id") + '|' + products;
            }
        })
                
        $("#price").val(value);
        $("#btn-pagar").text('payment ' + value + '€');
        $("#products").val(products);
        })
    })
</script>

How could avoid that?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda