Jump to content
Larry Ullman's Book Forums

Recommended Posts

I'm working on an online store application.

I'm working on the part that will get Customer's shipping address.

I also want to get name, email, and phone number.

My question is, what is the best way to validate all of these, especially the address.

I know this is a general way of stating the question, so to clarify, this is what I am thinking.

I have two goals: 1) all the data is valid in the sense I can store it in the database.

2) I want to try to make sure it is a real customer, not a scammer, so I would like to make sure everything is in a valid form. Such as a zip code is only 5 digits plus 4. A phone number is only 10 digits, etc.

Is it reasonable to check if the zip code is valid for that state?

I don't think it needs to be perfect. It is just for doing some basic checking before passing it through to the credit card section.

Link to comment
Share on other sites

This is a good question! You need to differentiate between syntactically valid and actually valid. For example, a regex can confirm an email address is syntactically valid, but only requiring the user to click a link in that email confirms it's actually valid: exists and in the user's control. 

 

For street addresses, there are very few limits on syntactic validity and it's impractical to test actual validity. Your best bet is to use a third-party service that can validate addresses. You should also accept the billing address and confirm it as part of the credit card charge attempt. If the shipping address differs from the billing address, you would want to take additional steps to prevent fraud. Make sure you're using every tool at your disposable from your payment gateway. 

Link to comment
Share on other sites

Yes, this is pretty close to what I was thinking but I thought maybe you knew something that I don't already know.

 

Here's another thing (unless you think I should post this separately)

Do you think it is necessary that I make my customer register and login?

I will have to keep the address information in the database but do I really need to identify them as a customer?

Many people will probably only every buy just one time.

I would really like to simply it.

I'll be using Stripe.

Link to comment
Share on other sites

Do you think it is necessary that I make my customer register and login?

 

Abigail,

 

I am building a checkout system and have been doing a lot of research on this very subject. As a general rule do not force your users to register and login to make a purchase. It is a distraction that can cause them to stop finishing the checkout process. Statistics show that this is one of the biggest reasons why users do not complete an online purchase. Instead, give them a link somewhere at the top where they can chose to login if they already have an account and they want to save time and use the billing information they have already entered previously. If not, then they will have to enter that information again.

 

There are also sites that auto detect if a user is already in the system by checking if the email address they have entered is already in the database. If it is, then it prompts them to login, but they can choose to ignore it and continue the checkout as a guest.

 

Matt

Link to comment
Share on other sites

Hey Matt,

  Thanks for replying.

   I kind of decided to not have login. Largely because to save my programming. And also, like you mention, the users don't like it.

However, I'm doing it a little different than you describe. I am not going to have a User. I am going to have an Order.

I suppose my tables won't be normalized, because the name, address, and email will be repeated.

But I'm thinking that is small price to pay for the convenience.

The one thing that is different for my site, than for others (I think), is that I am only going let someone purchase one item at a time.

So everything really is focused around getting that Stripe charge card handled properly.

Sure, it takes them a little time to re-enter when they return but many people will only ever buy one item probably.

My browser remembers those fields and fills them with mouse clicks.

  Anyway, that is how I am going to start out and hopefully it will work well.

Abigail

Link to comment
Share on other sites

 Share

×
×
  • Create New...