Sunday, 30 December 2012 13:56

How to verify credit Card number and card security code are valid

Written by 
Rate this item
(0 votes)

when you process credit card payment the two
most sensitive inputs are taken from customer
are card number and card security code.you
will want to verify that the data entered
is valid before processing credit card payment.

//verifying that card number entered is valid

string cardNum = CardNumber.Text.Trim();
long res;
if (long.TryParse(cardNum, out res))
{cardNum = res.ToString();}
else
{strError+="Card Number may only contain numbers";}

//verifying card security code entered is valid

int res3;
string securitycode = CardCode.Text.Trim();
if (int.TryParse(securitycode, out res3))
{
if (res3 > 999)
{strError+="Security Code Value invalid<br/>";}
else
{
securitycode = res3.ToString().PadLeft(3, '0');
}}

Read 3493 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.