T_SUBRTV - Retrieve a Subscription


// Example Program: T_SUBRTV // Description: // This is a test program to illustrate how to call the CTI_Run() // subprocedure to retrieve a subscription/profile/token. // // To achieve this, generate a unique ID with CTI_NextUniqueId(), and // then populate and write a record to CTIWSHDR. 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 CTIWSRSP Disk(*Ext) Keyed Qualified Usage(*Input); Dcl-Ds HDR ExtName('CTIWSHDR':*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 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.PSRTVRUN = CTI_TRUE; HDR.MCHID = MerchantId; HDR.MCHREFCD = 'MYREFCD134'; // This Subscription ID needs to have been created already HDR.RSISUBID = '4333152637005000001518'; write CTIWSHDR.CTIWSHDRR HDR; if not CTI_Run( UniqueId : ErrorDS : *Omit : *Omit : 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( 'MCHREFCD: ' + RSP.MCHREFCD + NewLine ); WriteToJobLog( 'REQID: ' + RSP.REQID + NewLine ); WriteToJobLog( 'RSNCD: ' + %Char(RSP.RSNCD) + NewLine ); WriteToJobLog( 'REQTK: ' + RSP.REQTK + NewLine ); WriteToJobLog( 'PRSNCD: ' + %Char(RSP.PRSNCD) + NewLine ); WriteToJobLog( 'PCITY: ' + RSP.PCITY + NewLine ); WriteToJobLog( 'PCMNTS: ' + RSP.PCMNTS + NewLine ); WriteToJobLog( 'PCNTRY: ' + RSP.PCNTRY + NewLine ); WriteToJobLog( 'PCUR: ' + RSP.PCUR + NewLine ); WriteToJobLog( 'PCACTID: ' + RSP.PCACTID + NewLine ); WriteToJobLog( 'PEMAIL: ' + RSP.PEMAIL + NewLine ); WriteToJobLog( 'PFNAME: ' + RSP.PFNAME + NewLine ); WriteToJobLog( 'PFREQ: ' + RSP.PFREQ + NewLine ); WriteToJobLog( 'PLNAME: ' + RSP.PLNAME + NewLine ); WriteToJobLog( 'PDFLD1: ' + RSP.PDFLD1 + NewLine ); WriteToJobLog( 'PDFLD2: ' + RSP.PDFLD2 + NewLine ); WriteToJobLog( 'PDFLD3: ' + RSP.PDFLD3 + NewLine ); WriteToJobLog( 'PDFLD4: ' + RSP.PDFLD4 + NewLine ); WriteToJobLog( 'PMREFCD: ' + RSP.PMREFCD + NewLine ); WriteToJobLog( 'PSFLD1: ' + RSP.PSFLD1 + NewLine ); WriteToJobLog( 'PSFLD2: ' + RSP.PSFLD2 + NewLine ); WriteToJobLog( 'PSFLD3: ' + RSP.PSFLD3 + NewLine ); WriteToJobLog( 'PSFLD4: ' + RSP.PSFLD4 + NewLine ); WriteToJobLog( 'PPHNNBR: ' + RSP.PPHNNBR + NewLine ); WriteToJobLog( 'PPOSTCD: ' + RSP.PPOSTCD + NewLine ); WriteToJobLog( 'PRECURAMT: ' + RSP.PRECURAMT + NewLine ); WriteToJobLog( 'PSETUPAMT: ' + RSP.PSETUPAMT + NewLine ); WriteToJobLog( 'PSTCITY: ' + RSP.PSTCITY + NewLine ); WriteToJobLog( 'PSTCMPNY: ' + RSP.PSTCMPNY + NewLine ); WriteToJobLog( 'PSTCNTRY: ' + RSP.PSTCNTRY + NewLine ); WriteToJobLog( 'PSTFNAME: ' + RSP.PSTFNAME + NewLine ); WriteToJobLog( 'PSTLNAME: ' + RSP.PSTLNAME + NewLine ); WriteToJobLog( 'PSTPOSTCD: ' + RSP.PSTPOSTCD + NewLine ); WriteToJobLog( 'PSTSTATE: ' + RSP.PSTSTATE + NewLine ); WriteToJobLog( 'PSTSTR1: ' + RSP.PSTSTR1 + NewLine ); WriteToJobLog( 'PSTSTR2: ' + RSP.PSTSTR2 + NewLine ); WriteToJobLog( 'PSTATE: ' + RSP.PSTATE + NewLine ); WriteToJobLog( 'PSTATUS: ' + RSP.PSTATUS + NewLine ); WriteToJobLog( 'PSTREET1: ' + RSP.PSTREET1 + NewLine ); WriteToJobLog( 'PSTREET2: ' + RSP.PSTREET2 + NewLine ); WriteToJobLog( 'PTITLE: ' + RSP.PTITLE + NewLine ); WriteToJobLog( 'PCDACTNBR: ' + RSP.PCDACTNBR + NewLine ); WriteToJobLog( 'PCDEXPMON: ' + RSP.PCDEXPMON + NewLine ); WriteToJobLog( 'PCDEXPYR: ' + RSP.PCDEXPYR + NewLine ); WriteToJobLog( 'PCDTYPE: ' + RSP.PCDTYPE + NewLine ); WriteToJobLog( 'PSUBID: ' + RSP.PSUBID + NewLine ); WriteToJobLog( 'PAPRREC: ' + RSP.PAPRREC + NewLine ); WriteToJobLog( 'PTOTPMTS: ' + %Char(RSP.PTOTPMTS) + NewLine ); WriteToJobLog( 'PAUTORNW: ' + RSP.PAUTORNW + NewLine ); WriteToJobLog( 'PBILLPAY: ' + RSP.PBILLPAY + NewLine ); WriteToJobLog( 'PCDISSNBR: ' + RSP.PCDISSNBR + NewLine ); WriteToJobLog( 'PCDSTMON: ' + RSP.PCDSTMON + NewLine ); WriteToJobLog( 'PCDSTYR: ' + RSP.PCDSTYR + NewLine ); WriteToJobLog( 'PCKACTNBR: ' + RSP.PCKACTNBR + NewLine ); WriteToJobLog( 'PCKACTTYP: ' + RSP.PCKACTTYP + NewLine ); WriteToJobLog( 'PCKAUTID: ' + RSP.PCKAUTID + NewLine ); WriteToJobLog( 'PCKRTNBR: ' + RSP.PCKRTNBR + NewLine ); WriteToJobLog( 'PCKSECCD: ' + RSP.PCKSECCD + NewLine ); WriteToJobLog( 'PCMPNAM: ' + RSP.PCMPNAM + NewLine ); WriteToJobLog( 'PCMPTXID: ' + RSP.PCMPTXID + NewLine ); WriteToJobLog( 'PDOB: ' + RSP.PDOB + NewLine ); WriteToJobLog( 'PDLNBR: ' + RSP.PDLNBR + NewLine ); WriteToJobLog( 'PDLSTT: ' + RSP.PDLSTT + NewLine ); WriteToJobLog( 'PENDDT: ' + RSP.PENDDT + NewLine ); WriteToJobLog( 'PMCHREFCD: ' + RSP.PMCHREFCD + NewLine ); WriteToJobLog( 'POMCHID: ' + RSP.POMCHID + NewLine ); WriteToJobLog( 'PSTRDT: ' + RSP.PSTRDT + NewLine ); WriteToJobLog( 'PSUBIDNEW: ' + RSP.PSUBIDNEW + NewLine ); endif; endif; *INLR = *On; return;