In so far as checking whether or not a credit card number is valid, you can check the number against a Luhn alogorithm, of course, that will just return you a bool value telling you that numbers are or arent correct; it will provide you with no details of the card holder, if the card is valid, or if there is even money on the card.
Simply put, you are going to buy something: your payment gateway. Each companys gateway works differently (in my experience anyway) and that will dictate how you code. Paypal, for example, allows you to process payments through them using an API that they expose and it is relatively simple.
(Payment gateway == a credit card processing company that can provide the functionality necessary to validate credit cards.)
================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========