Stripe Custom Checkout with dynamically amount

Solution:

Here is my solution. Use jQuery/Javascript. I advise adding the id=”donation” to the donation input field, and also a placeholder=”10.00″ as an example of donation input.

jQuery(document).ready(function($) {
    var first_price = 0;
    var second_price = 0;
    var total_price = 0;

  $('#registration_fee').on( "change", function() {
    first_price = $('#registration_fee').val(); 
    first_price = parseInt( first_price );
    //console.log( first_price );
  });

  $('#donation').on( "change", function() {
    second_price = $('#donation').val(); 
    second_price = parseInt( second_price );
    //console.log( second_price );
  });

  $('#payment-form').on( "change", function() {
    total_price = first_price + second_price;
    //console.log( "total: " + total_price );
    $('.stripe-button-el span').html( "Pay with Card $" + total_price );
  });


});