Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for use of settings on payment methods. #213

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/helpers/spree/admin/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ def spree_humanize_dropdown_values(model_name, options = {})
formatted_option_values
end

def path_for(obj)
obj.class.name.demodulize.underscore
end

def spree_humanize_type(obj)
last_word = obj.split('::', 10).last
if last_word.starts_with?('Cms')
Expand Down
17 changes: 11 additions & 6 deletions app/views/spree/admin/payment_methods/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@
<div class="card-body">
<div id="preference-settings" data-hook class="form-group">
<% unless @object.new_record? %>
<% if preference_fields(@object, f).empty? %>
<%= Spree.t('no_payment_provider_settings_message') %>
<% end %>
<%= preference_fields(@object, f) %>
<% if @object.respond_to?(:use_settings?) && @object.use_settings? %>
<%= render partial: "spree/admin/shared/payment_methods/settings/#{path_for(@object)}", locals: { object: @object, form: f } %>
<% else %>
<% if preference_fields(@object, f).empty? %>
<%= Spree.t('no_payment_provider_settings_message') %>
<% end %>

<%= preference_fields(@object, f) %>

<% if @object.respond_to?(:preferences) %>
<div id="gateway-settings-warning" class="info warning"><%= Spree.t(:provider_settings_warning) %></div>
<% if @object.respond_to?(:preferences) %>
<div id="gateway-settings-warning" class="info warning"><%= Spree.t(:provider_settings_warning) %></div>
<% end %>
<% end %>
<% end %>
</div>
Expand Down