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

Use pay_customer_name if available #428

Merged
merged 1 commit into from
Sep 9, 2021
Merged
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
1 change: 1 addition & 0 deletions app/models/pay/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def has_incomplete_payment?
end

def customer_name
return owner.pay_customer_name if owner.respond_to?(:pay_customer_name) && owner.pay_customer_name.present?
owner.respond_to?(:name) ? owner.name : [owner.try(:first_name), owner.try(:last_name)].compact.join(" ")
end

Expand Down
5 changes: 5 additions & 0 deletions test/pay/billable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class Pay::Billable::Test < ActiveSupport::TestCase
assert_equal "Fake User", @user.payment_processor.customer_name
end

test "customer with a pay_customer_name" do
@user.define_singleton_method(:pay_customer_name) { "Pay Customer Name" }
assert_equal "Pay Customer Name", @user.payment_processor.customer_name
end

test "has charges" do
assert_equal Pay::Charge.none, users(:none).charges
end
Expand Down