Consent General Query
URL Endpoint: https://easypay5.com/APIcardProcREST/v1.0.0/Query/ConsentGeneral
Request Method: POST
Headers:
Session Key is passed to the API via the header:
Content-Type: application/json
Accept: application/json
SessKey: A1842D663E9A4A72XXXXXXXX303541303234373138
Copied
{
"Query": "(A=-1)&&(G=1)&&(E>='3/29/2023')&&(E<'4/29/2023')"
}
{
"ConsentGeneral_QueryResult": {
"Consents": [
{
"AcctHolderFirstName": "Sean",
"AcctHolderID": 1140,
"AcctHolderLastName": "Tester",
"AcctNo": "0055",
"AuthTxID": 2175,
"ConsentType": "A",
"CreatedBy": "Sally_Smith",
"CreatedOn": "/Date(1706116462217-0500)/",
"CustID": 1165,
"CustomerRefID": "A1523644",
"EndDate": "/Date(1888113600000-0400)/",
"ID": 568,
"IsEnabled": true,
"MerchID": 1,
"ModifiedBy": ":",
"ModifiedOn": "/Date(-62135578800000-0500)/",
"NumDays": 2107,
"RPGUID": "4c269391-a698-4e10-a1a8-0353ee80d1a6",
"ServiceDescrip": "REST Test",
"StartDate": "/Date(1706072400000-0500)/"
}
],
"ErrCode": 0,
"ErrMsg": "",
"FunctionOk": true,
"NumRecords": 1,
"RespMsg": "Successfully Returned Consent Records : 1"
}
}
Copied
private void RESTConsentGeneralQuery(string SessKey, string Query) {
// Look for First Name frank
Query = "(K='FRANK')";
/// Session Key gathered using the Authenticate Command.
SessKey = "70826FC89809414BB4303231333441303331343335";
string json = JsonConvert.SerializeObject(new { Query });
byte[] data = Encoding.UTF8.GetBytes(json);
// create Request
WebRequest request = WebRequest.Create("https://easypay5.com/APIcardProcREST/v1.0.0/Query/ConsentGeneral");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = data.Length;
// use your session key obtained when you authenticated
request.Headers.Add("SessKey: " + SessKey);
string Myheaders = request.Headers.ToString();
string responseContent = null;
// Using the Try block will catch communication errors
try {
using (Stream stream = request.GetRequestStream()) {
stream.Write(data, 0, data.Length);
}
using (WebResponse response = request.GetResponse()) {
using (Stream stream = response.GetResponseStream()) {
using (StreamReader sr99 = new StreamReader(stream)) {
responseContent = sr99.ReadToEnd();
}
}
}
} catch (Exception ee) {
MessageBox.Show("Problem communicating with EasyPay Service:" + ee.Message);
/// important to insert your Logging function here
return;
}
// Check for null Response as this would be a critical communication error as well
if (responseContent == null) {
MessageBox.Show("Critical Error!");
/// important to insert your Logging function here
return;
}
/// develop Response Object
var Result = JsonConvert.DeserializeObject<dynamic>(responseContent);
bool FunctionOk = (bool)Result.ConsentGeneral_QueryResult.FunctionOk;
int ErrCode = (int)Result.ConsentGeneral_QueryResult.ErrCode;
string ErrMsg = (string)Result.ConsentGeneral_QueryResult.ErrMsg;
string RespMsg = (string)Result.ConsentGeneral_QueryResult.RespMsg;
//Check for unexpected Errors on cloud servers. If errors found Stop Processing and check ErrorCodes
if (!FunctionOk) {
MessageBox.Show(RespMsg + " " + ErrCode + " " + ErrMsg);
/// important to insert your Logging function here
return;
}
/// retrieve desired consents
var Consents = Result.ConsentGeneral_QueryResult.Consents;
foreach (var CnS in Consents) {
/// iterate through records if neccesary
/// Consent ID
int Txid = CnS.ID;
// card Number
string CardNumber = CnS.AcctNo;
// Reference ID
string RefID = CnS.CustomerRefID;
}
}