CreateSession
- Method
SlimCD.Sessions.CreateSession
Purpose
Loads data into SLIM CD and returns a session id.
Description
CreateSession is used to create a SessionID. SessionID values are later used as part of a secure and tamper-resistant URL so that a browser-style application can be launched to accept cardholder information outside of the developer’s software. CreateSession can also be used to send initial customer data to SLIM CD so that payment pages are pre-populated for the clerk, providing ease of data entry.
Business Rules
CreateSession must be called before ShowSession can display a page.
Argument List
Name Required Usage CheckSessionRequest Required Object containing properties for the request timeout Optional Integer wait time, in seconds, before timeout response is generated callback* Optional Function to call upon completion of asynchronous request *for JavaScript only
CheckSessionRequest Fields
Field Name Type Length Required Description UserName string 20 required Username or API Access Credential that accesses web service. Password string 20 required Plaintext password for the client account. SiteID integer 10 optional Assigned by the Slim CD administrator. ClientID integer 10 conditional Assigned by the Slim CD administrator. PriceID int 9 required numeric value provided by SLIMCD that is sent when processing a transaction FormName string 40 required name of the form to use when creating a session TransType string 20 required type of transaction to perform (SALE, CREDIT, VOID, etc). Amount string 20 required Amount of the transaction. UserField string varies optional This is a USER-SUPPLIED field, can be named whatever the developer wants, and can be used to store additional data with the form. In the case of the libraries, these field name/values are provided in a dictionary called “userfields”. In the case of the webservice/resource, these fields are simply included with other name/value pairs. - Passwords are required except when the username is set to an API Access Credential, in which case it should be passed in as an empty string.
- ClientID, SiteID, PriceID are required if not specified in the API Access Credential
- Form name is highly recommended. FormID can also be specified, but it is unique and prevents the form from being used by more than one clientid. If not FormName is specified, the system will select a form, producing unexpected results.
- TransType is required, unless specified on the form as an editable field.
- Amount is required, unless specified on the form as an editable field.
- UserFields are any field the developer wishes to send. For direct API calls, simply add the field to the name/value pairs. For libraries, add the fields to the “userfields” dictionary associated with the CreateSessionRequest object
Reply Fields
reply outer tag for the reply data block response Success, FAIL, Error response code 0, 1, 2 (respective) matching the above description If successful, this will contain the single word, OK. Otherwise it will contain a description of failure or error which occurred reponseurl The Slimcd.com url which was called for this operation datablock The confirmation text returned from the server. Reply Hierarchy
- reply
- response
- responsecode
- description
- responseurl
- datablock
- sessionid
Remarks
- Optional Fields fall into a few categories. These include Form Data, Customer Data, Payment Data, Clerk Identification Data, and Custom Developer Data.
- Form Data allows the developer to identify the pre-configured display form to use. Form configurations are created on the SLIM CD website and referenced by name or numerical value. This identification is sent when the session is created so that the proper form configuration will be used when displaying the form data to the clerk or consumer. (Note that at this time, specifying a form is optional. The system will use the lowest FormID available for the merchant if none is specified. This approach is subject to change and SLIM CD recommends supplying form names when sessions are created to insure the display functionality meets developer expectations)
- Customer Data can include any of the payment data supported by the SLIM CD gateway. This includes First Name, Last Name, Address, City, State, Zip, etc.
- Payment Data includes other fields supported by the SLIM CD, such as TransType and Amount. If the transaction type is not specified, it will default to SALE. Specialty fields can be provided, such as Hotel Checkin Date, etc. The “gateid” field can be provided to reference customer data from previous transactions without supplying that data or cardholder information.
- Please note that CreateSession will not accept certain cardholder data information. This is to ensure that PA-DSS avoidance and PCI Scope Reduction is obtained by discouraging applications from storing or sending cardholder data. Previously processed cardholder data can be referenced using the SLIM CD “gateid” values from those previous transactions.
- The following fields will not be accepted by the CreateSession function: Card Number, Track Data, CVV2, or PIN Block data fields. If the developer desires to provide this information to SLIM CD as part of a conversion that eliminates cardholder data storage, we recommend using the SLIM CD Developer’s Toolkit and perform the “LOAD” function.
Examples
Sample HTTP GET:
- (Note: Use of GET is NOT recommended for CreateSession, even with an API Access Credential, as it sends data insecurely)
Sample HTTP POST:
URL: https://stats.slimcd.com/soft/createsession.asp POSTDATA: clientid=1032&siteid=249949344&priceid=74&password=289075&amount=20&first_name=Frank&var1=test2Sample HTML Form with POST:
- Include
123<script type="text/javascript" src="https://trans.slimcd.com/soft/json/slimcd.js"></script>
Method
12345function CreateSession(request,callback)function CreateSession(request,timeout,callback)Request
12345678910111213request= {"username": "1032","clientid": "1032","siteid": "228226448","priceid": "74","password": "289075","formname": "simple","transtype": "SALE","amount": "10.00","userfield": "value"}Reply
12345678910111213callback ( {"reply":{"response": "Success","responsecode": "0","description": "OK","responseurl": "/soft/CreateSession.asp","datablock": {"sessionid": "6B9AC5C22EF62BB46EDBC2D2C49215D1157E3439"}}} );Sample Code
12345678910111213141516171819202122232425<script type="text/javascript" src="https://trans.slimcd.com/soft/json/slimcd.js"></script><script type="text/javascript">SlimCD.Sessions.CreateSession({"username": "1032","clientid": "1032","siteid": "228226448","priceid": "74","password": "289075","formname": "simple","transtype": "SALE","amount": "10.00","userfield": "value"},function (reply) {if (reply.response == "Success") {alert ('Batch Closed');} else {alert('There was a problem closing the batch:\r\n' + reply.description);}});</script>Downloads
- Include
123include 'slimcd.php';
Method
123function Sessions_CreateSession(Sessions_CreateSessionRequest $request,$timeout=false)Request
12345678910111213141516class Sessions_CreateSessionRequest{// property declarationpublic $username = '';public $password = '';public $siteid=0;public $clientid=0;public $priceid=0;public $formname='your_formname_goes_here';public $transtype='';public $amount=0;public $userfields=null;}JSON Reply
1234567891011{"response": "Success","responsecode": "0","description": "OK","responseurl": "/soft/CreateSession.asp","datablock": {"sessionid": "6B9AC5C22EF62BB46EDBC2D2C49215D1157E3439"}}Sample Code
12345678910111213141516171819202122232425include 'slimcd.php';// Create the Slim CD object$SlimCD = new SlimCD() ;// Create a CreateSession Request class$request = new Sessions_CreateSessionRequest() ;$request->username = '1032';$request->password = '289075';$request->clientid= '1032';$request->siteid= '228226448';$request->priceid= '74';$request->formname= "simple";$request->transtype= "SALE";$request->amount= '10.00';$request->userfields= array("mycustomfield","mycustomvalue");$result = $SlimCD->Sessions_CreateSession($request);if ($result->response == 'Success') {echo 'Success!' ;}else {echo $result->response . ':' . $result->description ;}Downloads
Download full sample source. - Include
123using SlimCD;
Method
123public CreateSessionReply CreateSession(CreateSessionRequest request, int timeout);Request
1234567891011121314public class CreateSessionRequest{public string username { get; set; }public string password { get; set; }public int clientid { get; set; }public int siteid { get; set; }public int priceid { get; set; }public string formname { get; set; }public string transtype { get; set; }public string amount { get; set; }public Dictionary<string, string> userfields { get; set; }}Reply
123456789101112public class CreateSessionReply{public string response;public string responsecode;public string description;public string responseurl;public string sessionid;public string senddata;public string recvdata;}Cross Reference: Client
Sample Code
12345678910111213141516171819202122232425SlimCD.Sessions sessions = new SlimCD.Sessions();sessions.debug = true;sessions.transURL = TransURL;sessions.statsURL = StatsURL;CreateSessionRequest request = new CreateSessionRequest();CreateSessionReply reply = new CreateSessionReply();request.username = 1032;request.clientid = 1032;request.siteid = 228226448;request.priceid = 74;request.password = 289075;request.formname = "simple";request.transtype = "SALE";request.amount = 10.00;reply = sessions.CreateSession(request, 60);if (reply.response.ToUpper() == "SUCCESS"){MessageBox.Show("Success");}else{MessageBox.Show("There was a problem:\n(" + reply.response & ") " + reply.description);}Downloads
Download full sample source. - Include
123#import "SlimCD.h"
Method
1234567typedef void (^SessionsCreateSessionReplyBlock)(SessionsCreateSessionReply *reply);- (void) sessionsCreateSessionWithRequest:(SessionsCreateSessionRequest*)request replyBlock:(SessionsCreateSessionReplyBlock)replyBlock;- (void) sessionsCreateSessionWithRequest:(SessionsCreateSessionRequest*)request timeout:(NSTimeInterval)timeout replyBlock:(SessionsCreateSessionReplyBlock)replyBlock;Request
1234567891011121314@interface SessionsCreateSessionRequest : SlimCDRequest@property (strong) NSString *userName;@property (strong) NSString *password;@property (strong) NSNumber *clientID;@property (strong) NSNumber *siteID;@property (strong) NSNumber *priceID;@property (strong) NSString *formID;@property (strong) NSString *formName;@property (strong) NSMutableDictionary *userFields;@endReply
1234567@interface SessionsCreateSessionReply : SlimCDReply@property (strong) NSString *sessionID;@endSample Code
12345678910111213141516171819202122232425SlimCD *api = [[SlimCD alloc] init];SessionsCreateSessionRequest *request = [[SessionsCreateSessionRequest alloc] init];request.userName = @"1032";request.password = @"289075";request.clientID = @1032;request.siteID = @228226448;request.priceID = @74;request.formID = @"POS_demo_form1";(request.userFields)[@"amount"] = @"12.34";(request.userFields)[@"transtype"] = @"SALE";(request.userFields)[@"field1"] = @"Value 1";(request.userFields)[@"field2"] = @"Value 2";[api sessionsCreateSessionWithRequest:request replyBlock:^(SessionsCreateSessionReply *reply ){if ( reply.responseCode == RC_SUCCESS ){NSLog(@"Session Created. Session ID = %@", reply.sessionID);}else{NSLog(@"Unable to create session.");}}]; - Method
123456public void getCreateSession(CreateSessionRequest sessionCreateRequest,int timeout, CreateSessionCallback callback);public void getCreateSession(CreateSessionRequest sessionCreateRequest,CreateSessionCallback callback)
Request
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104public class CreateSessionRequest {// request parameters.private String username;private int clientid;private int siteid;private int priceid;private String password;private String formname;private String transtype;private String amount;private HashMap<String,String> userfield;public CreateSessionRequest(){// set default values.username="";clientid=0;siteid=0;priceid=0;password="";formname="";transtype="";amount="";userfield=null;}// setter and getterspublic String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public int getClientid() {return clientid;}public void setClientid(int clientid) {this.clientid = clientid;}public int getSiteid() {return siteid;}public void setSiteid(int siteid) {this.siteid = siteid;}public int getPriceid() {return priceid;}public void setPriceid(int priceid) {this.priceid = priceid;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String getFormname() {return formname;}public void setFormname(String formname) {this.formname = formname;}public String getTranstype() {return transtype;}public void setTranstype(String transtype) {this.transtype = transtype;}public String getAmount() {return amount;}public void setAmount(String amount) {this.amount = amount;}public HashMap<String, String> getUserfield() {return userfield;}public void setUserfield(HashMap<String, String> userfield) {this.userfield = userfield;}}Reply
123456789101112131415public class CreateSessionReply{// response value.private String sessionid="";public String getSessionid() {return sessionid;}public void setSessionid(String sessionid) {this.sessionid = sessionid;}}Sample Code
12345678910111213141516171819202122232425262728293031323334// set the request parameters.CreateSessionRequest request=new CreateSessionRequest();request.setUsername("1032");request.setPassword("289075");request.setAmount("10.00");request.setClientid(1032);request.setFormname("simple");request.setPriceid(74);request.setSiteid(228226448);request.setTranstype("SALE");HashMap hashMap=new HashMap<String, String>();hashMap.put("key1", "value1");hashMap.put("key2","Value2");request.setUserfield(hashMap);//To make web service request.new SessionCreateSession().getCreateSession(request, new CreateSessionCallback() {@Overridepublic void getCreateSessionReply(CreateSessionReply reply){if (reply.getResponse().equals("Success"))textBox.setText("Success");elsetextBox.setText("There was a problem:\n" + reply.getResponse() +"\n Descriptin "+ reply.getDescription());}});Downloads
- URL
Protocols
- SOAP/XML
- HTTP POST
- HTTP GET
Request
Status Codes
Status Code Status Description Explanation 200 200 OK Approved or declined attempts will return a response with an XML reply block 500 500 Internal Server Error The response will not contain XML, as a server error has occurred. Reply
Output is in XML format if a status code of 200 is returned.
123456789101112<?xml version="1.0" encoding="utf-8" ?><reply><response>Success</response><responsecode>0</responsecode><description>OK</description><responseurl>/soft/createsession.asp</responseurl><datablock><sessionid>CD3054F53D176471D46F7272CF17634AD94FAC6E</sessionid></datablock></reply>If the <reply> block’s <response> tag does not indicate “Success”, the <description> tag will contain an error description which can be displayed to the end-user
Sample Code
Simple HTML form to show CreateSession
Remarks
- Any fields not recognized by CreateSession will be stored in the session so that you can retrieve them later with CheckSession or on the PostBack
- CreateSession uses the FormName to uniquely identify which form design to display with ShowSession. Forms can be exported from one clientid and imported into another to make installation of forms simple across merchants
- URL
123https://stats.slimcd.com/soft/json/jsonscript.asp?service=CreateSession
Protocols
- HTTP POST
- HTTP GET
This function accepts either name/value pairs or JSON
Request
Reply
12345678910111213{"reply":{"response": "Success","responsecode": "0","description": "OK","responseurl": "/soft/CreateSession.asp","datablock": {"sessionid": "6B9AC5C22EF62BB46EDBC2D2C49215D1157E3439"}}}Sample Code
Remarks
- None