T_ATHMDD - Authorization with Merchant-Defined Data fields


// Example Program: T_ATHMDD // Description: // This is a test program to illustrate how to call the CTI_Run() // subprocedure to perform an authorization with Merchant-Defined // Data fields. // // To achieve this, generate a unique ID with CTI_NextUniqueId(), and // then populate and write a record to CTIWSHDR and a record in // CTIWSMDD.Then, call CTI_Run() passing in your unique ID as well as // the other parameters shown. // // CTI_Run() will return *On if no error was encountered, or *Off // if an error occurred. If an error occurred, you should look at // the fields in ErrorDS to retrieve information about the error. // // Otherwise, you can perform a CHAIN against the CTIWSRSP physical // file, and retrieve the result fields. Ctl-Opt ActGrp(*Caller) BndDir('CTIBND') Option(*NoDebugIO); Dcl-F CTIWSHDR Disk(*Ext) Keyed Qualified Usage(*Input:*Output); Dcl-F CTIWSMDD Disk(*Ext) Keyed Qualified Usage(*Input:*Output); Dcl-F CTIWSRSP Disk(*Ext) Keyed Qualified Usage(*Input); Dcl-Ds HDR ExtName('CTIWSHDR':*Output) Qualified End-Ds; Dcl-Ds MDD ExtName('CTIWSMDD':*Output) Qualified End-Ds; Dcl-Ds RSP ExtName('CTIWSRSP':*Input) Qualified End-Ds; /COPY QRPGLECPY,CTICB // This is included for demo output purposes. Dcl-Pr WriteToJobLog Int(10) Extproc('Qp0zLprintf'); pString Pointer Value Options(*String); End-Pr; Dcl-C NewLine x'15'; // This stores the unique ID for this API call Dcl-S UniqueId Like(CTI_UniqueId_t) Inz; // This holds any error information returned by the API call Dcl-Ds ErrorDS LikeDS(CTI_ErrorDS_t) Inz(*LikeDS); // Modify these fields to specify different card details Dcl-S CardNumber Char(20) Inz('4111111111111111'); Dcl-S CardCV Char(4) Inz('1234'); // Modify this field to use your merchant ID Dcl-S MerchantId Like(CTI_MerchantId_t) Inz('ikrengel'); reset ErrorDS; // Each API call requires a unique ID UniqueId = CTI_NextUniqueId(); // CTIWSHDR needs to be populated with the transaction data clear HDR; HDR.UID = UniqueId; HDR.CRTDT = %Timestamp(); HDR.ATHRUN = CTI_TRUE; HDR.MCHID = MerchantId; HDR.MCHREFCD = 'MYREFCD134'; HDR.CCCRDTYP = '001'; // 001=Visa, 003=AmEx HDR.CCEXPMM = '10'; HDR.CCEXPYY = '2021'; HDR.BTFNAM = 'Jim'; HDR.BTLNAM = 'Jones'; HDR.BTST1 = '123 Central'; HDR.BTCTY = 'Mankato'; HDR.BTSTT = 'MN'; HDR.BTPSTCD = '56001'; HDR.BTCNTRY = 'US'; HDR.BTEML = 'asdf@asdf.com'; HDR.PTCUR = 'USD'; HDR.PTGNDAMT = '12.12'; write CTIWSHDR.CTIWSHDRR HDR; // Any merchant-defined fields need to be populated in CTIWSMDD clear MDD; MDD.UID = UniqueId; MDD.MCHDDTA1 = 'test data 1'; MDD.MCHDDTA2 = 'test data 2'; MDD.MCHDDTA3 = 'test data 3'; //MDD.MCHDDTA4 = 'test data 4'; //MDD.MCHDDTA5 = 'test data 5'; //MDD.MCHDDTA6 = 'test data 6'; //MDD.MCHDDTA7 = 'test data 7'; //MDD.MCHDDTA8 = 'test data 8'; //MDD.MCHDDTA9 = 'test data 9'; //MDD.MCHDDTA10 = 'test data 10'; //MDD.MCHDDTA11 = 'test data 11'; //MDD.MCHDDTA12 = 'test data 12'; //MDD.MCHDDTA13 = 'test data 13'; //MDD.MCHDDTA14 = 'test data 14'; //MDD.MCHDDTA15 = 'test data 15'; //MDD.MCHDDTA16 = 'test data 16'; //MDD.MCHDDTA17 = 'test data 17'; //MDD.MCHDDTA18 = 'test data 18'; //MDD.MCHDDTA19 = 'test data 19'; //MDD.MCHDDTA20 = 'test data 20'; //MDD.MCHDDTA21 = 'test data 21'; //MDD.MCHDDTA22 = 'test data 22'; //MDD.MCHDDTA23 = 'test data 23'; //MDD.MCHDDTA24 = 'test data 24'; //MDD.MCHDDTA25 = 'test data 25'; //MDD.MCHDDTA26 = 'test data 26'; //MDD.MCHDDTA27 = 'test data 27'; //MDD.MCHDDTA28 = 'test data 28'; //MDD.MCHDDTA29 = 'test data 29'; //MDD.MCHDDTA30 = 'test data 30'; //MDD.MCHDDTA31 = 'test data 31'; //MDD.MCHDDTA32 = 'test data 32'; //MDD.MCHDDTA33 = 'test data 33'; //MDD.MCHDDTA34 = 'test data 34'; //MDD.MCHDDTA35 = 'test data 35'; //MDD.MCHDDTA36 = 'test data 36'; //MDD.MCHDDTA37 = 'test data 37'; //MDD.MCHDDTA38 = 'test data 38'; //MDD.MCHDDTA39 = 'test data 39'; //MDD.MCHDDTA40 = 'test data 40'; //MDD.MCHDDTA41 = 'test data 41'; //MDD.MCHDDTA42 = 'test data 42'; //MDD.MCHDDTA43 = 'test data 43'; //MDD.MCHDDTA44 = 'test data 44'; //MDD.MCHDDTA45 = 'test data 45'; //MDD.MCHDDTA46 = 'test data 46'; //MDD.MCHDDTA47 = 'test data 47'; //MDD.MCHDDTA48 = 'test data 48'; //MDD.MCHDDTA49 = 'test data 49'; //MDD.MCHDDTA50 = 'test data 50'; //MDD.MCHDDTA51 = 'test data 51'; //MDD.MCHDDTA52 = 'test data 52'; //MDD.MCHDDTA53 = 'test data 53'; //MDD.MCHDDTA54 = 'test data 54'; //MDD.MCHDDTA55 = 'test data 55'; //MDD.MCHDDTA56 = 'test data 56'; //MDD.MCHDDTA57 = 'test data 57'; //MDD.MCHDDTA58 = 'test data 58'; //MDD.MCHDDTA59 = 'test data 59'; //MDD.MCHDDTA60 = 'test data 60'; //MDD.MCHDDTA61 = 'test data 61'; //MDD.MCHDDTA62 = 'test data 62'; //MDD.MCHDDTA63 = 'test data 63'; //MDD.MCHDDTA64 = 'test data 64'; //MDD.MCHDDTA65 = 'test data 65'; //MDD.MCHDDTA66 = 'test data 66'; //MDD.MCHDDTA67 = 'test data 67'; //MDD.MCHDDTA68 = 'test data 68'; //MDD.MCHDDTA69 = 'test data 69'; //MDD.MCHDDTA70 = 'test data 70'; //MDD.MCHDDTA71 = 'test data 71'; //MDD.MCHDDTA72 = 'test data 72'; //MDD.MCHDDTA73 = 'test data 73'; //MDD.MCHDDTA74 = 'test data 74'; //MDD.MCHDDTA75 = 'test data 75'; //MDD.MCHDDTA76 = 'test data 76'; //MDD.MCHDDTA77 = 'test data 77'; //MDD.MCHDDTA78 = 'test data 78'; //MDD.MCHDDTA79 = 'test data 79'; //MDD.MCHDDTA80 = 'test data 80'; //MDD.MCHDDTA81 = 'test data 81'; //MDD.MCHDDTA82 = 'test data 82'; //MDD.MCHDDTA83 = 'test data 83'; //MDD.MCHDDTA84 = 'test data 84'; //MDD.MCHDDTA85 = 'test data 85'; //MDD.MCHDDTA86 = 'test data 86'; //MDD.MCHDDTA87 = 'test data 87'; //MDD.MCHDDTA88 = 'test data 88'; //MDD.MCHDDTA89 = 'test data 89'; //MDD.MCHDDTA90 = 'test data 90'; //MDD.MCHDDTA91 = 'test data 91'; //MDD.MCHDDTA92 = 'test data 92'; //MDD.MCHDDTA93 = 'test data 93'; //MDD.MCHDDTA94 = 'test data 94'; //MDD.MCHDDTA95 = 'test data 95'; //MDD.MCHDDTA96 = 'test data 96'; //MDD.MCHDDTA97 = 'test data 97'; //MDD.MCHDDTA98 = 'test data 98'; //MDD.MCHDDTA99 = 'test data 99'; //MDD.MCHDDTA100 = 'test data 100'; write CTIWSMDD.CTIWSMDDR MDD; if not CTI_Run( UniqueId : ErrorDS : CardNumber : CardCV : MerchantId ); // If CTI_Run() returns *Off then an error occured. // You should check ErrorDS subfields for info: // ErrorDS.Subproc = Name of CTI subprocedure that threw error // ErrorDS.MessageId = Message ID of the error message // ErrorDS.Message = Error message description // ErrorDS.LogFile = Path to a log file created in the IFS that can // be used for troubleshooting. Log files are generated // automatically whenever an error occurs. You can also force log // files to generate by modifying the value of the LOGALL field in // CTICFGMCH for the provided Merchant ID. // ErrorDS.Source = // - CTI_SOURCE_INTERNAL is a general product error. // This could be due to issues with input data, or the // inability to access physical files, etc. // // - CTI_SOURCE_TRANSMIT is a product error that specifically // occurred during HTTPS communication with the CyberSource // webservice. This could be due to issues with your network // configuration, proxy setup, internet connection, etc. // // - CTI_SOURCE_REMOTE is an error message provided by CyberSource. WriteToJobLog( 'Error Message Id: ' + ErrorDS.MessageId + NewLine ); WriteToJobLog( 'Error Message: ' + ErrorDS.Message + NewLine ); WriteToJobLog( 'Error Source: ' + ErrorDS.Source + NewLine ); // All error information is also written to the file CTIERR. else; // If CTI_Run() returned *On the request was successful. You can // access the results in the CTIWSRSP file using the same UniqueID // that was used to create the request record in CTIWSRSP. chain UniqueId CTIWSRSP.CTIWSRSPR RSP; if %Found(CTIWSRSP); // For this sample code we're writing the response data to the job // log, but generally you would extract the data and pass it into // your own data tables. The CTIWSHDR, CTIWSITM, and CTIWSRSP files // should not be used for long-term data storage and should instead // be considered short-term transactional files. WriteToJobLog( 'CCAMT: ' + RSP.CCAMT + NewLine ); WriteToJobLog( 'CCATHCD: ' + RSP.CCATHCD + NewLine ); WriteToJobLog( 'CCATHDT: ' + RSP.CCATHDT + NewLine ); WriteToJobLog( 'RSNCD: ' + %Char(RSP.RSNCD) + NewLine ); WriteToJobLog( 'CCRSNCD: ' + RSP.CCRSNCD + NewLine ); WriteToJobLog( 'REQID: ' + RSP.REQID + NewLine ); WriteToJobLog( 'REQTK: ' + RSP.REQTK + NewLine ); WriteToJobLog( 'CCAVSCD: ' + RSP.CCAVSCD + NewLine ); WriteToJobLog( 'CCAVSCDR: ' + RSP.CCAVSCDR + NewLine ); WriteToJobLog( 'CCPRCRSP: ' + RSP.CCPRCRSP + NewLine ); WriteToJobLog( 'LVL3ELG: ' + RSP.LVL3ELG + NewLine ); WriteToJobLog( 'UniqueID: ' + %Char(UniqueID) + NewLine ); endif; endif; // Write unique ID to job log for easy reference WriteToJobLog( 'T_ATHMDD Unique ID: ' + %Char(UniqueId) + NewLine ); *INLR = *On; return;