<commit_before>%h2 Make a Payment

%form{ :action => @formAction, :method => "POST", :onSubmit => "return confirmAmount();" }
  
  %table.lightweight
    %tbody
      %tr
        %th Total cost
        %td.numeric= number_to_currency @user.get_invoice_total
        %td.smalltext= link_to "Cost Summary", invoice_user_path(@user)
      %tr
        %th Amount paid
        %td.numeric= number_to_currency @user.amount_paid
        %td.smalltext Updated every few days, please be patient
      %tr
        %th Balance
        %td.numeric= number_to_currency @user.balance
      %tr
        %td{ :colspan => "3", :style => "padding-left: 0px;" }
          %br
          %h2 Payment Information
      %tr
        %th Account Email Address
        %td= @user.email
        %td.smalltext Please use this email address on the following forms
      %tr
        %th Enter payment amount
        %td.align-right
          $
          %input.align-right{ :type => "text", :size => "6", :name => "amount", :id => "amount" }
          %input{ :type => "hidden", :name => "action", :value => "process_variable" }
          %input{ :type => "hidden", :name => "order_description", :value => "USGC Payment for #{@user.email}" }
          %input{ :type => "hidden", :name => "language", :value => "en" }
          %input{ :type => "hidden", :name => "url_finish", :value => "http://www.gocongress.org/#{@year}" }
          %input{ :type => "hidden", :name => "customer_receipt", :value => "true" }
          %input{ :type => "hidden", :name => "username", :value => @merchantone_username }
        %td.smalltext Your payment will be processed by secure.merchantonegateway.com
      %tr
        %th
        %td.align-right
          %br
          %input{ :type => "submit", :name => "submit", :value => "Submit" }

-# The following line is called a HAML "Filter"
:javascript

  // Check the payment amount, and warn people who overpay
  function confirmAmount() {

    // Get amount field via jquery
    var a = $('#amount');
    if (a.length !== 1) { return true; }

    // Validate numeric
    if (isNaN(a.val())) {
      alert("Please enter a numeric payment amount");
      return false;
      }

    // Get user balance via interpolation
    var b = parseFloat('#{@user.balance}');

    // Warn people who overpay
    /*
    if (!isNaN(b) && a.val() > b) {
      var msg = "It looks like the amount that you entered is greater";
      msg += " than your account balance.  Are you sure you want to";
      msg += " make a donation?";
      return confirm(msg);
      }
    */

    // Otherwise, everything looks OK.  Submit the form.
    return true;
  }
<commit_msg>url helper<commit_after>%h2 Make a Payment

%form{ :action => @formAction, :method => "POST", :onSubmit => "return confirmAmount();" }
  
  %table.lightweight
    %tbody
      %tr
        %th Total cost
        %td.numeric= number_to_currency @user.get_invoice_total
        %td.smalltext= link_to "Cost Summary", invoice_user_path(@user)
      %tr
        %th Amount paid
        %td.numeric= number_to_currency @user.amount_paid
        %td.smalltext Updated every few days, please be patient
      %tr
        %th Balance
        %td.numeric= number_to_currency @user.balance
      %tr
        %td{ :colspan => "3", :style => "padding-left: 0px;" }
          %br
          %h2 Payment Information
      %tr
        %th Account Email Address
        %td= @user.email
        %td.smalltext Please use this email address on the following forms
      %tr
        %th Enter payment amount
        %td.align-right
          $
          %input.align-right{ :type => "text", :size => "6", :name => "amount", :id => "amount" }
          %input{ :type => "hidden", :name => "action", :value => "process_variable" }
          %input{ :type => "hidden", :name => "order_description", :value => "USGC Payment for #{@user.email}" }
          %input{ :type => "hidden", :name => "language", :value => "en" }
          %input{ :type => "hidden", :name => "url_finish", :value => year_url }
          %input{ :type => "hidden", :name => "customer_receipt", :value => "true" }
          %input{ :type => "hidden", :name => "username", :value => @merchantone_username }
        %td.smalltext Your payment will be processed by secure.merchantonegateway.com
      %tr
        %th
        %td.align-right
          %br
          %input{ :type => "submit", :name => "submit", :value => "Submit" }

-# The following line is called a HAML "Filter"
:javascript

  // Check the payment amount, and warn people who overpay
  function confirmAmount() {

    // Get amount field via jquery
    var a = $('#amount');
    if (a.length !== 1) { return true; }

    // Validate numeric
    if (isNaN(a.val())) {
      alert("Please enter a numeric payment amount");
      return false;
      }

    // Get user balance via interpolation
    var b = parseFloat('#{@user.balance}');

    // Warn people who overpay
    /*
    if (!isNaN(b) && a.val() > b) {
      var msg = "It looks like the amount that you entered is greater";
      msg += " than your account balance.  Are you sure you want to";
      msg += " make a donation?";
      return confirm(msg);
      }
    */

    // Otherwise, everything looks OK.  Submit the form.
    return true;
  }

{'fraction_non_alphanumeric': 0.14672985781990522, 'fraction_numerical': 0.002274881516587678, 'mean_word_length': 2.3329121920404297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1657790', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1576, 'n_words': 507}