T_SLTRNQR2 - Single Transaction Query by Merchant Reference Number


// Example Program: T_SLTRNQR2 // Description: // This program demonstrates the CTI_RunSingleTransQuery() subprocedure // which retrieves CyberSource's on-demand transaction query for a // single given transaction. // // This example demonstrates downloading and processing the report as // two separate API calls, as well as querying by merchant reference // number and date. // // This program assumes that you have correctly configured your merchant // and environment tables (CTICFGMCH and CTICFGENV) and that you have at // least one valid batch transaction on the given date. Ctl-Opt ActGrp(*Caller) BndDir('CTIBND'); /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); // This holds configuration values for the report request API call Dcl-Ds ReportDS LikeDS(CTI_OnDemandReportConfigDS_t) Inz(*LikeDS); reset ReportDS; reset ErrorDS; // Each API call requires a unique ID UniqueId = CTI_NextUniqueId(); ReportDS.MerchantId = 'YOUR_MERCHANT_ID'; ReportDS.Operation = CTI_DOWNLOAD_REPORT; // This will be where the program saves the downloaded report. ReportDS.ReportStmf = '/your/reports/single_transaction_query.xml'; // These must be the merchant reference number and transaction date of the // transaction to be queried. ReportDS.MerchRefNbr = 'YOUR_MERCH_REF_NUMBER'; ReportDS.TransDate = %Date( '2016-08-29' ); // Do not also pass a transaction request ID. if not CTI_RunSingleTransQuery( UniqueId : ReportDS : ErrorDS ); WriteToJobLog( 'Error Message Id: ' + ErrorDS.MessageId + NewLine ); WriteToJobLog( 'Error Message: ' + ErrorDS.Message + NewLine ); WriteToJobLog( 'Error Source: ' + ErrorDS.Source + NewLine ); endif; // Now that we have downloaded the report, it will have an associated // record in CTIRPT. We will pass the same unique ID to the API again // to process the specified report into the CTIRPT* physical files reset ReportDS; reset ErrorDS; ReportDS.MerchantId = 'YOUR_MERCHANT_ID'; ReportDS.Operation = CTI_PROCESS_REPORT; if not CTI_RunSingleTransQuery( UniqueId : ReportDS : ErrorDS ); WriteToJobLog( 'Error Message Id: ' + ErrorDS.MessageId + NewLine ); WriteToJobLog( 'Error Message: ' + ErrorDS.Message + NewLine ); WriteToJobLog( 'Error Source: ' + ErrorDS.Source + NewLine ); endif; *INLR = *ON; return;