Why first_name last_name, why not just name?

15 views
Skip to first unread message

Jonzo

unread,
Feb 6, 2008, 11:31:49 PM2/6/08
to Active Merchant
Hi,

I've been curious about this since I started looking into Active
Merchant: Why does ActiveMerchant::Billing::CreditCard require a
first_name and a last_name?

In the main example the following values are used:
.......
:first_name => 'Bob',
:last_name => 'Bobsen'
.......

This person could just as easily have decided that they wanted their
name on their credit card to be "B Bobsen" or they could have chosen
to include their middle name: "Bob Andy Bobsen", "Bob A Bobsen", or
even "B A Bobsen".

All of these combinations are going to be problems when restricting
the user to first_name and last_name. At the very least it's going to
be confusing to the user... Also, I think I noticed somewhere in the
code that the names are joined together when submitting them to a
gateway? Why not just use one field from the start: "name"?

Cody Fauser

unread,
Feb 7, 2008, 9:37:17 PM2/7/08
to activem...@googlegroups.com
Jonzo,

Most of the payment gateways require both the first name and last name
provided separately. It is pretty hard to guess with a 3 part name
whether to select 2 names as the first name or 2 names for the last
name. The customer is more likely to be able to put the 2 names into
the correct box.

We've processed many thousands of transactions in Shopify using both
the first and last name and we haven't had any problems that I've
heard of yet.

There are some payment gateways that do take the full name of customer
in one field. In such cases we use the CreditCard#name method that
concatenates the name into a single string.


--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://peepcode.com/products/activemerchant-pdf - ActiveMerchant PeepCode
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

Brendon

unread,
Apr 2, 2008, 4:24:30 PM4/2/08
to Active Merchant
Hi Jonzo, that's not overly helpful. For instance, by business credit
card has the name of my company on it. How does that fit into the
firstname lastname scenario? For users to un-naturally split up the
name would require that they understood that your system would be
concatenating the names back together in the background.

I use the PaymentExpress Gateway which only requires a name (single
field) for this it would be nice if I could just specify
CreditCard#name rather than the other two. Is this possible. It's been
a while since I wrote my creditcard stuff but I do recall when I tried
back then it didn't work.

Cheers,

Brendon

On Feb 8, 3:37 pm, "Cody Fauser" <codyfau...@gmail.com> wrote:
> Jonzo,
>
> Most of the payment gateways require both thefirstnameandlastname
> provided separately. It is pretty hard to guess with a 3 partname
> whether to select 2 names as thefirstnameor 2 names for thelastname. The customer is more likely to be able to put the 2 names into
> the correct box.
>
> We've processed many thousands of transactions in Shopify using both
> thefirstandlastnameand we haven't had any problems that I've
> heard of yet.
>
> There are some payment gateways that do take the fullnameof customer
> in one field. In such cases we use the CreditCard#namemethod that
> concatenates thenameinto a single string.
>
> On 2/6/08, Jonzo <j.fant...@gmail.com> wrote:
>
>
>
>
>
> > Hi,
>
> > I've been curious about this since I started looking into Active
> > Merchant: Why does ActiveMerchant::Billing::CreditCard require a
> > first_name and a last_name?
>
> > In the main example the following values are used:
> > .......
> > :first_name => 'Bob',
> > :last_name => 'Bobsen'
> > .......
>
> > This person could just as easily have decided that they wanted their
> >nameon their credit card to be "B Bobsen" or they could have chosen
> > to include their middlename: "Bob Andy Bobsen", "Bob A Bobsen", or

Thijs van der Vossen

unread,
Apr 3, 2008, 3:51:43 AM4/3/08
to activem...@googlegroups.com
On 2 Apr 2008, at 22:24, Brendon wrote:
> Hi Jonzo, that's not overly helpful. For instance, by business credit
> card has the name of my company on it. How does that fit into the
> firstname lastname scenario? For users to un-naturally split up the
> name would require that they understood that your system would be
> concatenating the names back together in the background.
>
> I use the PaymentExpress Gateway which only requires a name (single
> field) for this it would be nice if I could just specify
> CreditCard#name rather than the other two. Is this possible. It's been
> a while since I wrote my creditcard stuff but I do recall when I tried
> back then it didn't work.

Using your own CreditCard subclass is a nice way to do this. See http://pastie.caboo.se/174477
for an example of what we're currently using.

Even though the separate first and last name doesn't seem to make
sense it is required by a lot of gateways including Authorize.net

Kind regards,
Thijs

--
Fingertips - http://www.fngtps.com


David J

unread,
May 11, 2008, 8:06:21 PM5/11/08
to Active Merchant
Interesting debate.

>> This person could just as easily have decided that they wanted their
>> name on their credit card to be "B Bobsen" or they could have chosen
>> to include their middle name: "Bob Andy Bobsen", "Bob A Bobsen", or
>> even "B A Bobsen".

I agree with Jonzo, it's seems a bit weird to make people break up the
name on their card. It's just another field someone has to fill out
and if your gateway doesn't need it, why do we have to force the user
to break it up?

The more I think about it, maybe none of us are wrong. It seems to be
down to the requirements of the gateway your using. Maybe there is
something we define in the gateaway which then changes the way the
credit card validates.

In the case of PaymentExpress, just having a name field is clearly
better, and in the case of other gateways having it broken up is
better.

Is there is solution we can come up with that doesn't require you to
extend the CreditCard class? Maybe just a simple option that is set on
the gateway that disables validation on the last name?


For a temporary solution, just comment out this line
"errors.add :last_name, "cannot be empty" if @last_name.blank?" in the
validate_essential_attributes() method in /lib/active_merchant/billing/
credit_card.rb file. That will shut up the last name errors.

On Apr 3, 7:51 pm, Thijs van der Vossen <t.vandervos...@gmail.com>
wrote:
> On 2 Apr 2008, at 22:24, Brendon wrote:
>
> > Hi Jonzo, that's not overly helpful. For instance, by business credit
> > card has the name of my company on it. How does that fit into the
> > firstname lastname scenario? For users to un-naturally split up the
> > name would require that they understood that your system would be
> > concatenating the names back together in the background.
>
> > I use the PaymentExpress Gateway which only requires a name (single
> > field) for this it would be nice if I could just specify
> > CreditCard#name rather than the other two. Is this possible. It's been
> > a while since I wrote my creditcard stuff but I do recall when I tried
> > back then it didn't work.
>
> Using your own CreditCard subclass is a nice way to do this. Seehttp://pastie.caboo.se/174477

Jonzo

unread,
May 12, 2008, 4:43:20 PM5/12/08
to Active Merchant
I remember having this thought on it when I posted this note:

Isn't the best practice to design for the situation that is correct?
and then adapt for incorrect situations such as Authorize.net?

Or better yet, put in a conditional switch. First check for :name,
then if that doesn't exist look for :first_name, and :last_name.

My solution was to edit the plugin myself like David J suggests, so
that it worked correctly with my gateway. That works fine so far :-)

Cody Fauser

unread,
May 13, 2008, 9:22:31 AM5/13/08
to activem...@googlegroups.com
I agree that only asking for the entire name definitely makes the most
sense and is the nicest solution, but many of the gateways require the
name in its individual components.

We could also add a name= method to the CreditCard class that splits
the single name into the first_name and last_name components, but also
stores the full name in case the gateway can use it.

def name=(value)
return if value.blank?

@name = value
segments = value.split(' ')
@last_name = segments.pop
@first_name = segments.join(' ')
end

def name
@name ||= "#{first_name} #{last_name}"
end

This way if the gateway supports a single name field and you've set
the name using name= then the entire name would be passed to the
gateway unaltered.

Comments?

--

Benjamin Curtis

unread,
May 13, 2008, 9:26:34 AM5/13/08
to activem...@googlegroups.com
+1

I've done this very thing in a few projects.

----
Benjamin Curtis
http://railskits.com/ - Ready-made Rails code
http://catchthebest.com/ - Team-powered recruiting
http://www.bencurtis.com/ - Personal blog

patrick...@gmail.com

unread,
May 13, 2008, 2:01:10 PM5/13/08
to Active Merchant
Sounds like a good compromise to me.

On May 13, 9:26 am, Benjamin Curtis <benjamin.cur...@gmail.com> wrote:
> +1
>
> I've done this very thing in a few projects.
>
> ----
> Benjamin Curtishttp://railskits.com/- Ready-made Rails codehttp://catchthebest.com/- Team-powered recruitinghttp://www.bencurtis.com/- Personal blog
>
> On May 13, 2008, at 6:22 AM, Cody Fauser wrote:
>
>
>
> > I agree that only asking for the entire name definitely makes the most
> > sense and is the nicest solution, but many of the gateways require the
> > name in its individual components.
>
> > We could also add a name= method to the CreditCard class that splits
> > the single name into the first_name and last_name components, but also
> > stores the full name in case the gateway can use it.
>
> > def name=(value)
> > return if value.blank?
>
> > @name = value
> > segments = value.split(' ')
> > @last_name = segments.pop
> > @first_name = segments.join(' ')
> > end
>
> > def name
> > @name ||= "#{first_name} #{last_name}"
> > end
>
> > This way if the gateway supports a single name field and you've set
> > the name using name= then the entire name would be passed to the
> > gateway unaltered.
>
> > Comments?
>

Jonathan Fantham

unread,
May 13, 2008, 4:08:39 PM5/13/08
to activem...@googlegroups.com
sounds good :-)

--
Jonathan

Cody Fauser

unread,
May 14, 2008, 6:30:39 AM5/14/08
to activem...@googlegroups.com
Anyone want to whip up a patch?

--

Benjamin Curtis

unread,
May 15, 2008, 12:41:06 PM5/15/08
to activem...@googlegroups.com
Is this too naïve? It will fail if someone has no space in the name
on their card, but I don't know whether that happens.

cc_name.diff

Cody Fauser

unread,
May 15, 2008, 3:13:47 PM5/15/08
to activem...@googlegroups.com
Madonna ;)

> ----
> Benjamin Curtis
> http://railskits.com/ - Ready-made Rails code
> http://catchthebest.com/ - Team-powered recruiting
> http://www.bencurtis.com/ - Personal blog
>
>
>

> On May 14, 2008, at 3:30 AM, Cody Fauser wrote:
>>
>> Anyone want to whip up a patch?
>>
>>
>
>
>
>

--

Benjamin Curtis

unread,
May 15, 2008, 3:37:29 PM5/15/08
to activem...@googlegroups.com
Heh, we should definitely call her agent and ask how she orders stuff
online. :)

----
Benjamin Curtis
http://railskits.com/ - Ready-made Rails code
http://catchthebest.com/ - Team-powered recruiting
http://www.bencurtis.com/ - Personal blog

Cody Fauser

unread,
May 15, 2008, 3:59:37 PM5/15/08
to activem...@googlegroups.com
lol

On Thu, May 15, 2008 at 3:37 PM, Benjamin Curtis


<benjami...@gmail.com> wrote:
>
> Heh, we should definitely call her agent and ask how she orders stuff
> online. :)
>
> ----
> Benjamin Curtis
> http://railskits.com/ - Ready-made Rails code
> http://catchthebest.com/ - Team-powered recruiting
> http://www.bencurtis.com/ - Personal blog
>
>
>
> On May 15, 2008, at 12:13 PM, Cody Fauser wrote:
>>
>> Madonna ;)
>>
>> On Thu, May 15, 2008 at 12:41 PM, Benjamin Curtis
>> <benjami...@gmail.com> wrote:
>>> Is this too naïve? It will fail if someone has no space in the name
>>> on their card, but I don't know whether that happens.
>>>
>>>>
>
> >
>

--

Damien McKenna

unread,
May 15, 2008, 5:24:45 PM5/15/08
to activem...@googlegroups.com
On May 15, 2008, at 3:37 PM, Benjamin Curtis wrote:
> Heh, we should definitely call her agent and ask how she orders stuff
> online. :)


first_name: "Mrs"
last_name: "Ritchie"

--
Damien McKenna - Husband, father, geek.
dam...@mc-kenna.com - http://www.mc-kenna.com/

Brendon

unread,
May 21, 2008, 11:34:45 PM5/21/08
to Active Merchant
Great to see progress on this! I almost forgot completely about it.

Cheers,

Brendon

On May 14, 10:30 pm, "Cody Fauser" <codyfau...@gmail.com> wrote:
> Anyone want to whip up a patch?
>
>
>
> On Tue, May 13, 2008 at 4:08 PM, Jonathan Fantham <j.fant...@gmail.com> wrote:
>
> > sounds good :-)
>
> > On Wed, May 14, 2008 at 6:01 AM, patrick.t.jo...@gmail.com
> > <patrick.t.jo...@gmail.com> wrote:
>
> > > Sounds like a good compromise to me.
>
> > > On May 13, 9:26 am, Benjamin Curtis <benjamin.cur...@gmail.com> wrote:
> > > > +1
>
> > > > I've done this very thing in a few projects.
>
> > > > ----
> > > > Benjamin Curtishttp://railskits.com/-Ready-made Rails codehttp://catchthebest.com/-Team-powered recruitinghttp://www.bencurtis.com/-Personal blog
> > > > >http://shopify.com-e-commerce done right
> > > > >http://www.codyfauser.com-blog
> > > > >http://peepcode.com/products/activemerchant-pdf-ActiveMerchant
> > > > > PeepCode
> > > > >http://www.oreilly.com/catalog/rjsrails-RJS Templates for Rails
>
> > --
> > Jonathan
>
> --
> Cody Fauserhttp://shopify.com- e-commerce done righthttp://www.codyfauser.com- bloghttp://peepcode.com/products/activemerchant-pdf- ActiveMerchant PeepCodehttp://www.oreilly.com/catalog/rjsrails- RJS Templates for Rails
Reply all
Reply to author
Forward
0 new messages