mongoosepepper Posted September 23, 2005 Share Posted September 23, 2005 hi guys, I need some help, i am using protx_direct on my site and I am unable to accept Visa Electron cards, They pass through my validation however when the order is confirmed and payment is sent to protx it just fails. Can anyone shed any light please ? Also can someone explain to me in plain and simple english what the code below means as I am a bit miffed: elseif (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number) and CC_ENABLED_VISA=='1') { $this->cc_type = 'Visa'; Thanks for your help, Mongoose Quote Link to comment Share on other sites More sharing options...
aragorn231 Posted October 14, 2005 Share Posted October 14, 2005 elseif (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number) and CC_ENABLED_VISA=='1') { $this->cc_type = 'Visa'; I can't help you out with your protx_direct question, but I'll help you understand the code. The part you're having trouble understanding would be the ereg() function, right? It uses a "regular expression" (first parameter - the tough part) to verify the format of the credit card number (the second parameter). The regular expression that you posted verifies if the CC number starts with a 4, followed by exactly 12 digits, ending in 3 optional digits (that would be the check number printed on the back - at least if it is VISA). The weird thing is, as far as I know anyway, a VISA card number is 16 digits + 3 optional, not 13 + 3. Maybe that's what you're having trouble with? Try changing the regular expression to the following: '^4[0-9]{15}([0-9]{3})?$' The comment above would be applicable for regular VISA, I don't know the VISA Electron cards, so you'll need to verify for yourself what the number length of such a card is... BTW: if you're up for it, try a Google on "regex tutorial" for more info about this powerful subject - get a strong coffee first ;) . Quote How to make a horrible shop (great sarcasm!) Link to comment Share on other sites More sharing options...
aragorn231 Posted October 21, 2005 Share Posted October 21, 2005 Apparently VISA card numbers can be 13 or 16 digits, which means that the code modification in my earlier mail is not valid and should be disregarded. More discussion about this in this thread. Quote How to make a horrible shop (great sarcasm!) Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.