VFN_StartSession()

This subprocedure is used to open a session with a Verifone device.

Subprocedure Prototype

D VFN_StartSession...
D                 PR              N   Extproc('VFN_StartSession')

Returns *OFF if an error occurs during processing, *ON otherwise.

D  pRequestDS                         LikeDS(VFN_StartSessionReqDS_t)
D                                     Const
 
D  pResponseDS                        LikeDS(VFN_StartSessionRspDS_t)
 
D  pErrorDS                           LikeDS(VFN_ErrorDS_t)
D                                     Options(*Nopass)

Optional parameter that, if passed, will contain error data returned from the subprocedure.

Example Code


// Example Program: T_STRSES // Description: // This is a test program to illustrate how to call the // VFN_StartSession() subprocedure. This subprocedure opens a session // on the device which is required for all payment and line item // transactions. When this is complete, you should call // VFN_EndSession() (demonstrated in example program T_ENDSES). Ctl-Opt DftActGrp(*No) ActGrp(*Caller) BndDir('PTTIBND'); /COPY QRPGLECPY,VFNCB // 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 will capture returned error information Dcl-Ds ErrorDS LikeDS(VFN_ErrorDS_t) Inz(*LikeDS); // This will be used to pass request information to the API call Dcl-Ds StrSesReqDS LikeDS(VFN_StartSessionReqDS_t) Inz(*LikeDS); // This will store parsed response data from the API call Dcl-Ds StrSesRspDS LikeDS(VFN_StartSessionRspDS_t) Inz(*LikeDS); reset ErrorDS; reset StrSesReqDS; reset StrSesRspDS; // This must be a device that has already been successfully registered // with VFN_Register() and which exists in VFNDVC. StrSesReqDS.DeviceID = 'test'; // These fields can be assigned a log file name, and will write the // request and response xml data to the logging directory. StrSesReqDS.RequestLog = 'T_STRSES_Request.xml'; StrSesReqDS.ResponseLog = 'T_STRSES_Response.xml'; // This data structure should be populated per the Verifone documentation // and many of the fields are considered optional. StrSesReqDS.Invoice = '1'; StrSesReqDS.StoreNum = ''; StrSesReqDS.Lane = ''; StrSesReqDS.CashierID = ''; StrSesReqDS.ServerID = ''; StrSesReqDS.ShiftID = ''; StrSesReqDS.TableNum = ''; StrSesReqDS.BusinessDate = %Date(); StrSesReqDS.PurchaseID = ''; // if VFN_StartSession() returns *Off, it means that an error occurred // as part of the overall communication process, and the information // will be in ErrorDS - ErrorDS.Message is the main field to look at // for troubleshooting. if not VFN_StartSession( StrSesReqDS : StrSesRspDS : ErrorDS ); // handle error WriteToJobLog( 'Message ID: ' + ErrorDS.MessageId + NewLine ); WriteToJobLog( 'Message: ' + ErrorDS.Message + NewLine ); *INLR = *On; return; else; // Now you can check the response data structure for any status info // or data returned from the device: WriteToJobLog( 'Response Text: ' + StrSesRspDS.ResponseText + NewLine ); WriteToJobLog( 'Result: ' + StrSesRspDS.Result + NewLine ); WriteToJobLog( 'Response Code: ' + StrSesRspDS.ResultCode + NewLine ); WriteToJobLog( 'Termination Status: ' + StrSesRspDS.TerminationStatus + NewLine ); endif; *INLR = *On; return;

Data Structures

D VFN_StartSessionReqDS_t...
D                 DS                  Qualified Template Inz
 
D  DeviceID                           Like(VFN_DeviceId_t)

Required

The ID of the payment device, registered in VFNDVC, with which a session is to be opened.

D  RequestLog                         Like(VFN_Var1Kv_t)

Specifies the file name or path of the request log file. Will have no effect if logging is not enabled.

Example: "req_log.txt","/tmp/logs/request.txt"

D  ResponseLog                        Like(VFN_Var1Kv_t)

Specifies the file name or path of the response log file. Will have no effect if logging is not enabled.

Example: "rsp_log.txt","/tmp/logs/response.txt"

D  Invoice                       6A   Varying

Required

D  StoreNum                      6A   Varying
 
D  Lane                          2A
 
D  CashierID                    10A   Varying
 
D  ServerID                      3A
 
D  ShiftID                       1A
 
D  TableNum                      5A
 
D  POS_IP                       15A

Unimplemented

Used for Unsolicited Consumer Selection Events

D  POS_Port                      5A
D  BusinessDate                   D   Inz(*Sys)

Unimplemented

Used for Unsolicited Consumer Selection Events

D  SwipeAhead                    1A

Unimplemented

Used for Unsolicited Consumer Selection Events

D  PurchaseID                   25A   Varying

Required for Level II processing.

D  TrainingMode                   N   Inz(*Off)
 
D  ConnectTimeout...
D                                3P 0 Inz(-1)

Override the default value set in VFN_Register() or REGVFNDVC.

Default Value: -1

D  WriteTimeout...
D                                3P 0 Inz(-1)

Override the default value set in VFN_Register() or REGVFNDVC.

Default Value: -1

D  ReadTimeout...
D                                3P 0 Inz(-1)

Override the default value set in VFN_Register() or REGVFNDVC.

Default Value: -1

D VFN_StartSessionRspDS_t...
D                 DS                  Qualified Template Inz
 
D  ResponseText                       Like(VFN_Var1Kv_t)

This field corresponds to the field RESPONSE_TEXT in your device's Verifone documentation.

D  Result                             Like(VFN_Var1Kv_t)

This field corresponds to the field RESULT in your device's Verifone documentation.

D  ResultCode                   10A   Varying

This field corresponds to the field RESULT_CODE in your device's Verifone documentation.

D  TerminationStatus...
D                                     Like(VFN_Var1Kv_t)

This field corresponds to the field TERMINATION_STATUS in your device's Verifone documentation.

D  TrainingMode                       Like(VFN_Var1Kv_t)

This field corresponds to the field TRAINING_MODE in your device's Verifone documentation.

D  Counter                      10P 0

This field corresponds to the field COUNTER in your device's Verifone documentation.