×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

credit card parsing - Can anyone share a method/routine?

credit card parsing - Can anyone share a method/routine?

credit card parsing - Can anyone share a method/routine?

(OP)
I am struggling with this - I thought it would be very simple.

I guess that my not knowing preg_match does not help

I found this: http://thunderdata.com/blog/category/using-phps-pr...

but it does not work; my guess is that this is due to credit cards having changed their encoding !?!

jquery.payment.js is not working either ... besides, I am not sure I want to use jquery for this task!

Thanks you all in advance.

--
SouthBeach
http://www.fpgroups.com
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

RE: credit card parsing - Can anyone share a method/routine?

(OP)
Too often I post a question here looking for help just to find a solution or plug shortly there after.

Mind you, I spend a great deal of time working on my problem before I come here seeking for help, it is how one learns, by struggling. Since I ask the question and then find what may be an answer, I also like to post what I came up with so, here it is:

CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
var	setCreditCardAttributes = function(string){
        try {
		    string = string.replace('%B', '');
            string = string.replace('%b', '');
            
            var arr = string.split('^');
            var nameArr = arr[1].split(' ');
            var len = nameArr.length;
            
            this.creditcardnumber = arr[0];
			document.getElementById('number').value=this.creditcardnumber;

            this.month = arr[2].substring(2, 4);
            this.year = arr[2].substring(0, 2);
			document.getElementById('expires').value=arr[2].substring(2, 4)+"/"+arr[2].substring(0, 2);

            this.first_name = '';
            this.last_name = '';
			
			nameArr = arr[1].split('/');
            this.first_name = nameArr[1];
			document.getElementById('fname').value=nameArr[1];
            this.last_name = nameArr[0];
			document.getElementById('lname').value=nameArr[0];
			this.payment_method_id=1;
			this.type='credit';

	    } 
        catch (err) {
            pushToErrorLog('class Payment::setCreditCardAttributes() ' + err);
            displayMessageWindow('Error With Card', 'There was an error reading the data from this card', 'error');
        }
	}

function returnKey(evt)
{
	var evt  = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
 
	if ((evt.keyCode == 13) && (node.type == "text")) 
	{
		switch(node.id)
		{
			case 'p1cc':
				setCreditCardAttributes(document.getElementById('p1cc').value); break;
 
		}
	}
}

 	
document.onkeypress = returnKey;

</script>
</head>

<body>
<input name="p1cc" id="p1cc" type="text" size="55" maxlength="256" />

<input id="fname" type="text" />
<input id="lname" type="text" />
<input id="expires" type="text" />
<input id="number" type="text" />

</body>
</html> 

--
SouthBeach
http://www.fpgroups.com
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close