kenkeiter / skeuocard

Skeuocard progressively enhances credit card inputs to provide a skeuomorphic interface.
http://kenkeiter.com/skeuocard/
MIT License
3.23k stars 231 forks source link

Splitting Name Field dynamically #69

Closed zschmid closed 11 years ago

zschmid commented 11 years ago

Is there a recommended approach for submitting name data for payment processors that don't allow a single name field?

For example, according to PayPal payments pro documentation their rest API accepts data in this format:

    "funding_instruments": [
      {
        "credit_card": {
          "number": "5500005555555559",
          "type": "mastercard",
          "expire_month": 12,
          "expire_year": 2018,
          "cvv2": 111,
          "first_name": "Joe",
          "last_name": "Shopper"
        }

Browsing the documentation it appears that in the current state we're only able to submit the 'name' field without doing any additional JS magic. I suppose we could split based on spaces in the name. 1 space would mean only first and last name was entered, 2 spaces means first middle and last - though i'm not sure if there would be any edge cases where 2 or more spaces would be entered for a name.

Anyone else think this type of functionality should be rolled into the library - rather than depending on additional logic to parse the name? Not sure about other payment processors , but i'm assuming this may potentially be very common.

kenkeiter commented 11 years ago

Hi @zschmid --

Splitting the name field using JS for your own requirements isn't a bad idea at all -- and it'll probably work with at least 80% of names. An even better solution might be to pre-fill the name on the card using first and last name fields elsewhere on the page and, if the user doesn't modify the card's name, treating those first and last name fields as canonical.

All that said, adding this feature to support a small handful of payment processors probably isn't in the cards (pun) for this project at the moment. My tests indicate that users think of their name on the card as one field; splitting it into two would add confusion. We'd have to a) make a bunch of assumptions about the formatting of users' names, and b) support any edge-cases.