Skip to content

Commit

Permalink
Use Spree::Address::Name to handle credit card names
Browse files Browse the repository at this point in the history
The logic for splitting a name and concatenating name components should
be centralized in a single class.
  • Loading branch information
filippoliverani committed Jan 15, 2020
1 parent f82013c commit 38e53d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/app/models/spree/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def has_payment_profile?
# the object to ActiveMerchant.
# @return [String] the first name on this credit card
def first_name
name.to_s.split(/[[:space:]]/, 2)[0]
Spree::Address::Name.new(name).first_name
end

# @note ActiveMerchant needs first_name/last_name because we pass it a
Expand All @@ -172,7 +172,7 @@ def first_name
# the object to ActiveMerchant.
# @return [String] the last name on this credit card
def last_name
name.to_s.split(/[[:space:]]/, 2)[1]
Spree::Address::Name.new(name).last_name
end

# @return [ActiveMerchant::Billing::CreditCard] an ActiveMerchant credit
Expand Down

0 comments on commit 38e53d5

Please sign in to comment.