diff --git a/app/assets/javascripts/admin/payments/new.js b/app/assets/javascripts/admin/payments/new.js new file mode 100644 index 0000000000..e50c348daa --- /dev/null +++ b/app/assets/javascripts/admin/payments/new.js @@ -0,0 +1,33 @@ +// Override of Spree's logic in the file of the same name +// Changes made as per https://github.com/spree/spree/commit/8a3a80b08abf80fbed2fcee4b429ba1caf68baf1 +// which allows the form partial in admin/payments/new to be switched using radio buttons +// We can remove this file when we reach 2.3.0 + +$(document).ready(function() { + if ($("#new_payment").is("*")) { + $('.payment_methods_radios').click( + function() { + $('.payment-methods').hide(); + if (this.checked) { + $('#payment_method_' + this.value).show(); + } + } + ); + + $('.payment_methods_radios').each( + function() { + if (this.checked) { + $('#payment_method_' + this.value).show(); + } else { + $('#payment_method_' + this.value).hide(); + } + } + ); + + $(".card_new").radioControlsVisibilityOfElement('.card_form'); + + $('select.jump_menu').change(function(){ + window.location = this.options[this.selectedIndex].value; + }); + } +}); diff --git a/app/views/spree/admin/payments/_form.html.erb b/app/views/spree/admin/payments/_form.html.erb new file mode 100644 index 0000000000..fe019007b1 --- /dev/null +++ b/app/views/spree/admin/payments/_form.html.erb @@ -0,0 +1,34 @@ +
+
+
+ <%= f.label :amount, t(:amount) %> + <%= f.text_field :amount, :value => @order.outstanding_balance, :class => 'fullwidth' %> +
+
+
+
+ +
    + <% @payment_methods.each do |method| %> +
  • + +
  • + <% end %> +
+ +
+ <% @payment_methods.each do |method| %> +
+ <% if method.source_required? %> +
+ <%= render :partial => "spree/admin/payments/source_forms/#{method.method_type}", :locals => { :payment_method => method } %> + <% end %> +
+ <% end %> +
+
+
+
diff --git a/app/views/spree/admin/payments/source_forms/_gateway.html.erb b/app/views/spree/admin/payments/source_forms/_gateway.html.erb new file mode 100644 index 0000000000..8cf4b914cc --- /dev/null +++ b/app/views/spree/admin/payments/source_forms/_gateway.html.erb @@ -0,0 +1,58 @@ +
+
+ <% @previous_cards.each do |card| %> + + <% end %> + +
+ +
+ <% param_prefix = "payment_source[#{payment_method.id}]" %> + +
+ +
+
+
+ <%= hidden_field_tag "#{param_prefix}[cc_type]", '', {class: 'ccType'} %> + <%= label_tag "card_number#{payment_method.id}", raw(t(:card_number) + content_tag(:span, ' *', :class => 'required')) %> + <%= text_field_tag "#{param_prefix}[number]", '', :class => 'required fullwidth cardNumber', :id => "card_number#{payment_method.id}", :maxlength => 19 %> + +
+
+
+
+
+
+ <%= label_tag "card_name#{payment_method.id}", raw(t(:name) + content_tag(:span, ' *', :class => 'required')) %> + <%= text_field_tag "#{param_prefix}[name]", '', id: "card_name#{payment_method.id}", class: 'required fullwidth', maxlength: 19 %> +
+
+
+
+
+ <%= label_tag "card_expiry#{payment_method.id}", raw(t(:expiration) + content_tag(:span, ' *', :class => 'required')) %>
+ <%= text_field_tag "#{param_prefix}[expiry]", '', id: "card_expiry#{payment_method.id}", class: "required cardExpiry", placeholder: "MM / YY" %> +
+
+
+
+ <%= label_tag "card_code#{payment_method.id}", raw(t(:card_code) + content_tag(:span, ' *', :class => "required")) %> + <%= text_field_tag "#{param_prefix}[verification_value]", '', id: "card_code#{payment_method.id}", class: 'required fullwidth cardCode', size: 5 %> + + (<%= t(:what_is_this) %>) + +
+
+ +
+ <%= image_tag 'credit_cards/credit_card.gif', :class => 'credit-card-image' %> +
+ +
+
+