home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / BBS / SHOP230.ZIP / EXAMPLE1.ARJ / CHKCARD.PAS < prev    next >
Pascal/Delphi Source File  |  1995-05-03  |  7KB  |  159 lines

  1. { ************************************************************************** }
  2. { Program-name: ChkCard.exe                                                  }
  3. {                                                                            }
  4. { ************************************************************************** }
  5. { This is a little Sample of a 'ShopDoor' to 'CreditCard Authorize system'   }
  6. { Interface.  An explanation:                                                }
  7. {                                                                            }
  8. { 1) A CreditCard Authorize system would scan for files with                 }
  9. {    the filename-format 'SHOP###.CC'. The '###' is the nodenumber.          }
  10. {    If it found such a file, it will contact the Authorize-link and         }
  11. {    write an answer back. This answer will be a file with                   }
  12. {    the filename-format 'NODE###.OK' or 'NODE###.DEC'.                      }
  13. {    The '.OK'-file will be written if the transaction has been authorized,  }
  14. {    and the '.DEC'-file will be written if the transaction has NOT          }
  15. {    been authorized...                                                      }
  16. {                                                                            }
  17. { 2) The 'SHOP###.CC'-file is a simple 3-line text-file like this:           }
  18. {                                                                            }
  19. {    4929 1234 5678 1234                                                     }
  20. {    0595                                                                    }
  21. {    120                                                                     }
  22. {                                                                            }
  23. {    The first line is the CreditCard number,                                }
  24. {    ShopDoor's format: 4929123456781234.                                    }
  25. {    (conversion needed)                                                     }
  26. {                                                                            }
  27. {    The second line is the Expire Date,                                     }
  28. {    ShopDoor's format: 05/95.                                               }
  29. {    (conversion needed)                                                     }
  30. {                                                                            }
  31. {    The third line is the amount of money,                                  }
  32. {    ShopDoor's format: 120,24.                                              }
  33. {    (a round Up and a conversion needed)                                    }
  34. {                                                                            }
  35. { Just take a good look at the little program and design your own            }
  36. { interface if needed. Contact us if you need help !                         }
  37. {                                                                            }
  38. { ************************************************************************** }
  39. {                                                                            }
  40. { (C) 1995 by: A.S. Kerkmeester, Simplesoft Developments                     }
  41. {                                                                            }
  42. { Written with Turbo Pascal v7.0                                             }
  43. {                                                                            }
  44. { Possible parameters:                                                       }
  45. { -----------------------------------------                                  }
  46. { Rem Parameter %1 = CreditCard Number                                       }
  47. { Rem Parameter %2 = CreditCard Expire Date                                  }
  48. { Rem Parameter %3 = Valuta symbol                                           }
  49. { Rem Parameter %4 = Amount of Money                                         }
  50. { Rem Parameter %5 = Node                                                    }
  51. {                                                                            }
  52. { ************************************************************************** }
  53. program CardDriver;
  54.  
  55. uses crt;
  56.  
  57. const Errorcode = 0;
  58.       Approved  = 1;
  59.       Declined  = 2;
  60.  
  61. var
  62.    f_chk                 : text;
  63.    retcode               : Byte;
  64.    n,code                : integer;
  65.    amount_int            : longint;
  66.    amount_real           : real;
  67.    hulpstr,number,nodenr : string;
  68.    expire,valuta,amount  : string;
  69.    ccfile,okfile,decfile : string;
  70.  
  71. { ************************************************************************** }
  72. Function FileExist(filename: String): Boolean; { File exist: TRUE , else: FALSE }
  73. var f: Text;
  74. begin
  75.    assign(f,filename);
  76.    {$I-}
  77.    reset(f);
  78.    close(f);
  79.    {$I+}
  80.    FileExist:=ioresult=0;
  81. end;
  82. { ************************************************************************** }
  83. begin
  84.    retcode:=Errorcode;
  85.    if paramcount<5 then
  86.    begin
  87.       writeln('ShopDoor to ''CreditCard Authorize system'' Interface');
  88.       writeln;
  89.       writeln('Usuage: ');
  90.       writeln;
  91.       writeln('CHKCARD.EXE %1 %2 %3 %4 %5');
  92.       writeln;
  93.       writeln('%1 = <creditcard no>');
  94.       writeln('%2 = <expire date>');
  95.       writeln('%3 = <valuta symbol>');
  96.       writeln('%4 = <amount of money>');
  97.       writeln('%5 = <node number>');
  98.       writeln;
  99.       halt(retcode); { Not enough Parameters: Error ! }
  100.    end;
  101.  
  102.    number:=paramstr(1); { Get CreditCard number }
  103.    expire:=paramstr(2); { Get Expire Date       }
  104.    valuta:=paramstr(3); { Get Valuta Symbol     }
  105.    amount:=paramstr(4); { Get Amount of money   }
  106.    nodenr:=paramstr(5); { Get Node-number       }
  107.  
  108.    { make filename for Authorize system }
  109.    if length(nodenr)=1 then
  110.       nodenr:='00'+nodenr;
  111.    if length(nodenr)=2 then
  112.       nodenr:='0'+nodenr;
  113.    ccfile  := 'SHOP'+nodenr+'.CC';
  114.    okfile  := 'NODE'+nodenr+'.OK';
  115.    decfile := 'NODE'+nodenr+'.DEC';
  116.  
  117.    { change number format }
  118.    hulpstr:='';
  119.    for n:=1 to 16 do
  120.    begin
  121.       hulpstr:=hulpstr+number[n];
  122.       if (n=4) or (n=8) or (n=12) then
  123.          hulpstr:=hulpstr+' ';
  124.    end;
  125.    number:=hulpstr;
  126.  
  127.    { change expire date format }
  128.    hulpstr:='';
  129.    for n:=1 to 5 do
  130.    begin
  131.       if n<>3 then hulpstr:=hulpstr+expire[n];
  132.    end;
  133.    expire:=hulpstr;
  134.  
  135.    { change amount in a round value }
  136.    val(amount,amount_real,code);
  137.    amount_int:=round(amount_real);
  138.    str(amount_int,amount);
  139.  
  140.    Assign(f_chk,ccfile);    { Create special file for Authorize system }
  141.    Rewrite(f_chk);
  142.    Writeln(f_chk,number);
  143.    Writeln(f_chk,expire);
  144.    Writeln(f_chk,amount);
  145.    Close(f_chk);
  146.  
  147.    delay(8000);   { wait for 8000ms : Authorize system shall examine the file }
  148.  
  149.    if fileexist(okfile) then
  150.       retcode:=Approved
  151.    else
  152.    begin
  153.       if fileexist(decfile) then
  154.          retcode:=Declined;
  155.    end;
  156.  
  157.    halt(retcode); { Stop Driver, change DOS Errorlevel }
  158. end.
  159. { ************************************************************************** }