SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2000
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone have any code to check the expiration date of a credit card?

  2. #2
    SitePoint Member
    Join Date
    Feb 2000
    Location
    NY, USA
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't you need a merchant account to do that? And once you have a merchant account, the merchant provider should supply you with code to handle all that stuff.

    Eugene.
    http://www.interprosolution.com

  3. #3
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You don't need a merchant account but you do need the card issuers account check digits. There are cgi scripts to validate credit cards available on the net. Look at cgi.resources.com.

    ------------------
    Wayne Luke
    Internet Media Provider

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2000
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to check to see if the credit card's
    EXPIRATION DATE has EXPIRED. I wouldn't
    need a merchant account for that and I already have functions for checking to see if
    the credit card NUMBER is valid.

  5. #5
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you would need a merchant account. Else you'd need to connect to Visa/MC/Discover/Amex's servers and check somehow.

    ------------------
    -Quinn Slack
    http:/www.fourthdev.com has webmaster resources!


  6. #6
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Laguna Hills, CA, USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this, this is ment to work with a pull down for the month call ed "cc_mexp" and a pull down for the year called "cc_yexp". It also makes a call to a sub routine "&print_error". In that sub routine it will replace the $error with the deffinisions below. If the exp date submitted is OK the bellow script will stop and your script will continue with its routine.

    sub checkexpire
    {
    $month = "$INPUT{'cc_mexp'}";
    $year = "$INPUT{'cc_yexp'}";
    (@thistime) = gmtime(time);
    $thistime[4]++;
    $thistime[5] += 1900;
    $date = "$thistime[5]/$thistime[4]/$thistime[3]";

    if (length($month) > 2 | | length($year) > 4)
    {
    $error = "Please check your credit card's experation date.";
    &print_error;
    exit;
    }
    elsif ($month < 1 or $month > 12)
    {
    $error = "Please check your credit card's experation date.";
    &print_error;
    exit;
    }
    elsif ($year < $thistime[5])
    {
    $error = "Please check your credit card's experation date.";
    &print_error;
    exit;
    }
    elsif ($year == $thistime[5] and $month < $thistime[4])
    {
    $error = "Please check your credit card's experation date.";
    &print_error;
    exit;
    }
    }

  7. #7
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Laguna Hills, CA, USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh ya,

    The month is a 2 digit input and the year is a 4 digit input.

  8. #8
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I used to write banking software. If you have the check digits you can validate not only the number but pull the expiration month out of the number. The year is really inconsequential. d3v was kind of right though.

    I can give you valid credit card numbers with valid expiration dates all day but until you verify with the issuer through your merchant account that the card is still valid you have nothing but a bunch of numbers. In fact I have a card that expires next year, it has a valid number but I closed the account and its a worthless piece of plastic.

    ------------------
    Wayne Luke
    Internet Media Provider

  9. #9
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Laguna Hills, CA, USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is the deal with everyone. Many people process cards offline but gather the info online. There is still a need to verify card numbers and exp date to cut down on bad submissions. Some of the comments above go to prove that "e-commerce" has been hyped so much that all the mindless sheep seem to belive that you must process online. Comon people, Get your heads out of the hype and back to earth.


    ------------------
    Bringing the Internet back to Earth
    Highland Media

  10. #10
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You don't have to process online. Having the issuer verify that the card is correct and valid is the only 100% sure-fire way you know it will be accepted though.

    ------------------
    Wayne Luke
    Internet Media Provider

  11. #11
    SitePoint Enthusiast
    Join Date
    Jan 2000
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I decided to write my own and it looks like this:


    function isvalidCCEXPDate(MonthInput, YearInput) {
    var now = new Date();
    /*
    No need to add 1 to the MonthInput because they are zero-based.

    We are going to check to see if now is greater than midnight on the
    first day of the month following the expire month.
    */
    var expires = new Date(YearInput, MonthInput, 01, 00, 00 );
    if (expires.getTime() < now.getTime()) {
    return false;
    }
    else
    return true;
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •