Re: Credit Card Validation from a 4GL application
Posted in 1995
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Here the data and files. Excuse the mess I am no expert at any of this but it works great. CREDIT CARD VERIFICATION PROGRAM This is a short description of how I developped a program to use the commercial ICVERIFY program to interface to INFORMIX-4GL or R4GL. I also have the same interface to ISQL. The ICVERIFY program looks at the data directory and scans for files that end with .REQ . It picks up the request and dials the creditcard service with a modem and then gets an answer for the transaction which was posted in the .REQ file. When it has picked up the file it moves it to .HLD and when it has received the answer it moves it to .ANS. This process usually takes 13 to 23 seconds. The use gets a small display at the bottom of the screen that scrolls every 5 seconds to let him know that it is being processed. My C program creates the .REQ file using parameters from the CALL in informix-4GL . It then watches the directory where the file was put and scans for the .HLD and the .ANS files. When the .ANS file is there it picks it up and uses the data returned from the creditcard service and fills in the appropriate fields on the screen and saves the form. I have build some safegard for refused or cancelled creditcard authorizations but there may be more messages from the creditcard company that I don;t know about. To use this you must create a .4ge program that includes call to C-program. or create a new 4glgo engine to use it with R4GL. I included the programs to generate the new 4glgo that I called sell and selldbug. The C program is called credit.ec. You also need to use fgisell.c The script to create the sell engine is called mksell. I included the source for chk_cre.4gl so you can debug your program. I included the 4gl source code for the simple call to credit_chk() in psc_cshr1.4gl. This program is just a module part of a large set of modules. You can use the example of the call to credit_chk(...) as a start for your application. I also included the form that goes with this 4gl module psc_cshr1.per. You can contact IC-SYSTEMS at 283 Beau Forest Dr. Oakland CA 94611 (510) 339-3480. ICVERIFY is not cheap but the return in time saved pays the program in no time. Good luck to all of you. Guy St-Amant gstamant@aol.com (305) 779-7803 ---------------------------------------------------------------------- /** credit.ec program Guy St-Amant July 1994 **/ #include "ctools.h" #include <stdio.h> #include <string.h> #include <sys/signal.h> #include <setjmp.h> $include sqlca; #define ERROR (-1) /* Program Created by Guy St-Amant February 94 */ int FROMTIMEOUT = 1, MAXTRIES = 15,tries,loop; FILE *ap,*hp,*rp,*fopen(); int abort_p(); int oldint,oldquit,oldhup,oldterm,oldalarm; static jmp_buf jmp; int credit_chk() { char creditcard[ 20 ]; char exp[ 5 ]; char sh_exp[ 5 ]; char sh_creditcard[ 20 ]; char trans_type[ 2 ]; char apv_code[ 7 ]; char seq_no[ 7 ]; char sh_seq_no[ 7 ]; char ref_no[ 9 ]; char ref_noap[ 9 ]; char sh_ref_no[ 9 ]; char sh_apv_code[ 7 ]; char capt_msgap[ 50 ]; char capt_msgapp[ 50 ]; char sh_capt_msg[ 16 ]; char tmp_capt_msg[ 16 ]; dec_t totalrec; dec_t p_trans; dec_t p_tot; char camt1[ 38 ]; char lname[ 16 ]; char notes[ 66 ]; char sh_notes[ 66 ]; char ic_msg[ 71 ]; int ret_code; char ext[80]; char ext1[80]; char icver_ida[4]; int cnt,i,k,c_cnt; char *lognm; char *getlogin(); char *getenv(); char *icver_id = icver_ida; char trans_short; char trans_proc[3]; char afile[34]; char rfile[34]; char hfile[34]; char msg[60]; char cmd[81]; char comment[21]; char messag[190]; char ret_msg[161]; char *pdest; char *trans_msg = ic_msg; char *apv_no; char *ref_nop = ref_no; char *ref_nopp = ref_noap; char *capt_msg = capt_msgap; char *capt_msgp = capt_msgapp; char *ref_id; char *seq_nop = seq_no; char *apv_codep = apv_code; lognm = getlogin(); icver_id=getenv("ICVER_ID"); strcpy(ic_msg,""); if (stcmpr(icver_id,"") == 0) /* If not set then use 008 */ strcpy(icver_id,"008"); popdec(&totalrec); popquote(notes,66); popquote(ref_no,9); popquote(seq_no,7); popquote(apv_code,7); popquote(trans_type,2); popquote(exp,5); popquote(creditcard,20); /** printf("\\n\\r %s %s %s %s ",creditcard,exp,trans_type,notes); **/ /** pf_getval("card", creditcard, CCHARTYPE, 20); **/ /** pf_getval("exp", exp, CCHARTYPE, 5); **/ /** pf_getval("t0",trans_type, CCHARTYPE, 2); **/ /** pf_getval("apvc",apv_code, CCHARTYPE, 7); **/ /** pf_getval("seq_no",seq_no, CCHARTYPE, 7); **/ /** pf_getval("ref_no",ref_no, CCHARTYPE, 9); **/ /** pf_getval("f067",notes, CCHARTYPE, 66); **/ /** pf_getval("f066", &totalrec, CDECIMALTYPE, 0); **/ stchar(exp,sh_exp,5); c_cnt=byleng(sh_exp,5); ldchar(exp,c_cnt,sh_exp); stchar(creditcard,sh_creditcard,20); c_cnt=byleng(sh_creditcard,20); ldchar(creditcard,c_cnt,sh_creditcard); stchar(apv_code,sh_apv_code,7); c_cnt=byleng(sh_apv_code,7); ldchar(apv_code,c_cnt,sh_apv_code); stchar(ref_no,sh_ref_no,9); c_cnt=byleng(sh_ref_no,9); ldchar(ref_no,c_cnt,sh_ref_no); stchar(seq_no,sh_seq_no,7); c_cnt=byleng(sh_seq_no,7); ldchar(seq_no,c_cnt,sh_seq_no); stchar(notes,sh_notes,66); c_cnt=byleng(sh_notes,66); ldchar(notes,c_cnt,sh_notes); dectoasc(&totalrec, camt1, 11, 2); ldchar(camt1,11,camt1); /**printf(" %s %s %s %s %s %s\\r\\n",sh_creditcard,sh_exp,sh_apv_code,sh_seq_no,sh_ref_no,trans_type); **/ strcpy(ext,",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\ "\\",\\"\\",\\"\\",\\"\\""); strcpy(ext1,",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\",\\"\\", \\"\\",\\"\\",\\"\\""); trans_short = trans_type[0]; switch(trans_short) { case 'S': strcpy(trans_proc,"C1"); sprintf(messag,"\\"%s\\",\\"%s,\\",\\"%s\\",\\"%s\\",\\"%s\\",\\"%s\\"%s\\n", trans_proc,lognm,sh_notes,sh_creditcard,sh_exp,camt1,ext); break; case 'V': deccvint(0,&p_trans