Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Hello expertise, I want to check is Credit Card and other provided cards numbers are valid before sending request to my payment gateway ?

Please share you best thoughts as a best suggestion. Many thanks in advance. :)

user-image
Question added by Muhammad Abid Saleem , Software Engineer , PVT Company LTD lahore
Date Posted: 2013/12/15
Muhammad Majid Saleem
by Muhammad Majid Saleem , Senior PHP Developer / Project Manager , SwaamTech

There is some confusion in your question and I can feel two different aspects of your question:

  1. You just want to check valid credit card numbers?
  2. You want to verify whether a credit card number is valid for charge?

First Part:

If you are concerned with for first part, you can look for Asif's answer.

 

Second Part:

If you are concerned for2nd part, then I don't think so that you can find any such service by which you check validity and availability of a credit card. This part is taken care by payment gateways when you put your credit card for payment.

You need to write a script that checks the entered card number against the Luhn algorithm.

Generally, though, this is frivolous check. Just because the pattern is correct does not mean the card number is valid.

Whilst not perfect, the following will help you get started: http://adrianotto.com/2011/10/better-luhn-formula-validator-for-php/

Ahmed Hisham
by Ahmed Hisham , Marketing Consultant - Web Developer , CPI Group

If you have the pattern of the text or number, the best solution is to use regular expressions. If you don't know how to write them, you will find tons of them over the web for many purposes and patterns.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.