Credit Card Validation using PHP

Possible Duplicate:
What is the best way to validate a credit card in PHP?

I am thinking of making an online shopping cart, using credit card validation. My question is, how is the entered credit card going to be validated? I am new to credit card validation, and I was wondering if there is a database with valid credit card numbers? (I know you can do this through PayPal). I also know there is an algorithm to check if the credit card is valid. And after checking the validation how is the charge gonna be made to that credit card and where do you get the money from? Excuse me if my question(s) are naive


You want to look at the Luhn algorithm: http://en.wikipedia.org/wiki/Luhn_algorithm

This is the algorithm that basically looks at a credit card number and decides if it's a valid number. This doesn't mean that it's an actual, real credit card. You would need a credit card processor/gateway for that (see: Authorize.NET, Paypal, etc).

This algorithm has been implemented in PHP many times, and I'm sure with a simple Google search you can find some code in PHP that representes the Luhn algorithm.

Good luck.


and I was wondering if there is a database with valid credit card numbers

I wish , I'd have so much new stuff!

My question is, how is the entered credit card going to be validated?

You will need to use a payment gateway to validate the credit card number.

I also know there is an algorithm to check if the credit card is valid.

You can implement such an algorithm, but just because it passes the check doesn't mean you can charge money to the card.

And after checking the validation how is the charge gonna be made to that credit card and where do you get the money from?

Again, you'll need a payment gateway, such as PayPal or authorize.net


There is no freely available credit card database to my knowledge. You will need to use a PCI compliant company which provides credit card processing and you can use the same or similar company for authorizing the transactions. Please check out the following:

http://www.authorize.net/

链接地址: http://www.djcxy.com/p/70720.html

上一篇: 使用Luhn's进行信用卡验证

下一篇: 使用PHP进行信用卡验证