<%# RAILS3 CHECK ENDS -%>

<h2><%= h site_account.org_name %> Service Payment Details</h2>

<div class="wide_dashboard_box round">
  <h3>Payment Details</h3>

  <p>Update your credit card details here to set up monthly billing
    for your <%= h current_account.provider_account.org_name %>
    service. You'll be charged monthly on the 7th of the following month
    and receive email notification about a successful payment along
    with the invoice.</p>

  <%= render :partial => 'error_list', :locals => { :error_list => @errors } %>

  <%= semantic_form_for current_account.customer, as: :customer, :url => @form_url do |form| %>

    <%= hidden_field_tag 'tr_data', ERB::Util.html_escape(@tr_data) %>
    <%= hidden_field_tag 'customer[credit_card][billing_address][options][update_existing]', true %>

    <%= form.inputs :name => "Credit Card and Billing Address" do %>
      <%= form.input :first_name, :required => true %>
      <%= form.input :last_name, :required => true %>

    <%= form.semantic_fields_for :credit_card do |cc|%>
      <%= cc.input :number , :required => true %>
      <%= cc.input :cvv , :required => true, :label => 'Cvv' %>
      <%= cc.input :expiration_date , :required => true, :label => 'Expiration Date (MM/YY)' %>

      <%= cc.semantic_fields_for :billing_address, current_account.billing_address_data do |billing_address| %>
        <%= billing_address.input :company , :required => true %>
        <%= billing_address.input :street_address , :required => true %>
        <%= billing_address.input :locality , :label => "City", :required => true %>
        <%= billing_address.input :country_name, :label =>  "Country", :as => :select,
                  :collection =>  merchant_countries, :required => true,
            :allow_blank => false %>
        <%= billing_address.input :region , :label => "State/Region" , :required => true%>
        <%= billing_address.input :postal_code , :label =>  "ZIP / Postal Code" , :required => true %>
      <% end %>
      <%= form.input :phone , :label =>  "Phone", :required => true %>
    <% end %>
  <% end %>

  <div class="operations">
      <%= form.submit 'Save credit card' %>
  </div>
<% end %>
<%=render :partial => '/shared/legal_terms_for_cc_details' %>
</div>
