Skip to content

Commit 0547be6

Browse files
maebealeclaude
andcommitted
Hide "Other" payment method on registration forms
The "Other" option offered no clear meaning to registrants and added noise to the payment choice. Keep it in code and form data — the scholarship flow still relies on it as the stored payment method — but filter it out of the options surfaced on the public registration and bulk payment forms, preserving it only when it's already the selected value (e.g. the scholarship preset). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5691399 commit 0547be6

5 files changed

Lines changed: 42 additions & 3 deletions

File tree

app/services/form_builder_service.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ class FormBuilderService
33
# charge, so controllers match against PAYMENT_METHOD_PAY_NOW rather than
44
# repeating its label. Keep this the single source of truth for the label.
55
PAYMENT_METHOD_PAY_NOW = "Credit card (now)".freeze
6-
PAYMENT_METHOD_OPTIONS = [ PAYMENT_METHOD_PAY_NOW, "Credit card (later)", "Check", "Other" ].freeze
6+
# "Other" is retained as a payment method in code and form data — the scholarship
7+
# flow stores it as the payment method — but it is intentionally hidden from the
8+
# options surfaced on public forms for now (see the public registration and bulk
9+
# payment views, which filter it out).
10+
PAYMENT_METHOD_OTHER = "Other".freeze
11+
PAYMENT_METHOD_OPTIONS = [ PAYMENT_METHOD_PAY_NOW, "Credit card (later)", "Check", PAYMENT_METHOD_OTHER ].freeze
712

813
SECTIONS = {
914
person_identifier: { label: "Person identifier", method: :build_person_identifier_fields },

app/views/events/bulk_payments/new.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@
134134
<% if field.required %><span class="text-red-500">*</span><% end %>
135135
</label>
136136
<div class="flex flex-wrap gap-2 mt-1">
137-
<% field.form_field_answer_options.includes(:answer_option).each do |ffao| %>
137+
<%# "Other" is kept in code/data but hidden on the form for now. %>
138+
<% field.form_field_answer_options.includes(:answer_option).reject { |ffao| ffao.answer_option.name == FormBuilderService::PAYMENT_METHOD_OTHER }.each do |ffao| %>
138139
<label class="inline-flex items-center gap-2 rounded-lg border <%= error ? 'border-red-400' : 'border-gray-300' %> px-3 py-2.5 cursor-pointer hover:border-blue-400 has-[:checked]:border-blue-600 has-[:checked]:bg-blue-50 transition">
139140
<input type="radio"
140141
name="bulk_payment[form_fields][<%= field.id %>]"

app/views/events/public_registrations/_form_field.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
data and store none of their own, so fall back to those when present. %>
7373
<% radio_options = dynamic_form_field_options(field) ||
7474
field.form_field_answer_options.includes(:answer_option).map { |ffao| [ ffao.answer_option.name, ffao.answer_option.name ] } %>
75+
<%# "Other" is hidden on the payment method field for now (it stays in code/data
76+
for the scholarship flow). Keep it only when it's already the selected value
77+
so a preset/stored "Other" still renders checked. %>
78+
<% if field.field_identifier == "payment_method" %>
79+
<% radio_options = radio_options.reject { |_option_label, option_value| option_value == FormBuilderService::PAYMENT_METHOD_OTHER && value != FormBuilderService::PAYMENT_METHOD_OTHER } %>
80+
<% end %>
7581
<% has_specify = radio_options.any? { |option_label, _option_value| specify_placeholder(option_label).present? } %>
7682
<%= tag.div class: "flex flex-wrap gap-2.5 mt-1", data: (has_specify ? { controller: "specify-option", action: "change->specify-option#update" } : {}) do %>
7783
<% radio_options.each do |option_label, option_value, option_description| %>

app/views/events/public_registrations/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
<% else %>
123123
<% submitted_value = params.dig(:public_registration, :form_fields, field.id.to_s) %>
124124
<% if submitted_value.blank? && field.field_identifier == "payment_method" %>
125-
<% submitted_value = @scholarship ? "Other" : FormBuilderService::PAYMENT_METHOD_PAY_NOW %>
125+
<% submitted_value = @scholarship ? FormBuilderService::PAYMENT_METHOD_OTHER : FormBuilderService::PAYMENT_METHOD_PAY_NOW %>
126126
<% end %>
127127
<div class="<%= field.grid_span_class %>">
128128
<%= render "events/public_registrations/form_field", field: field, value: submitted_value, label: email_label_overrides[field.field_identifier] %>

spec/requests/events/public_registrations_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,33 @@ def post_with_scholarship(scholarship_answer)
442442
end
443443
end
444444

445+
describe "GET new payment method options" do
446+
# A paid event so the payment section is not stripped from the form.
447+
let(:event) { create(:event, cost_cents: 150_00) }
448+
let!(:payment_method_field) do
449+
field = create(:form_field, form: form, answer_type: :single_select_radio,
450+
field_identifier: "payment_method", name: "Payment method",
451+
required: false)
452+
FormBuilderService::PAYMENT_METHOD_OPTIONS.each do |option_name|
453+
field.form_field_answer_options.create!(answer_option: AnswerOption.find_or_create_by!(name: option_name))
454+
end
455+
field
456+
end
457+
458+
it "hides the 'Other' payment method from a normal registrant" do
459+
get new_event_public_registration_path(event)
460+
461+
expect(response.body).to include(%(value="Check"))
462+
expect(response.body).not_to include(%(value="Other"))
463+
end
464+
465+
it "keeps 'Other' as the preselected payment method for a scholarship registrant" do
466+
get new_event_public_registration_path(event, scholarship_requested: "true")
467+
468+
expect(response.body).to match(/value="Other"[^>]*\bchecked\b/)
469+
end
470+
end
471+
445472
describe "GET show" do
446473
let(:person) { create(:person) }
447474

0 commit comments

Comments
 (0)