Consent Annual Query
URL Endpoint: https://easypay5.com/APIcardProcREST/v1.0.0/Query/ConsentAnnual
Request Method: POST
Headers:
Session Key is passed to the API via the header:
Content-Type: application/json
Accept: application/json
SessKey: A1842D663E9A4A72XXXXXXXX303541303234373138
Use this call to determine if the purchaser has a card on file. If you have created the consent (card on file) using a reference ID or PatientID then you can use the following Query to return an array of Consents ( Card On File Info ) for a particular patient with this PatientID:
F='213456')&&(H=1)&& (C>='01/21/2024') This will return consents with a particular PatientID which are still enabled and have not yet expired ( use todays date ).
You will want to present the user with the last 4 digits of each stored card so they can decide to choose a stored card or simply enter a new one. Easy Pay offers multiple ways of querying consent data. View the https://easypaysoftware.com/en/Querying Query Guide for more details.
{
"Query": "(A=-1)&&(G=1)&&(H='True')"
}
{
"ConsentAnnual_QueryResult": {
"Consents": [
{
"AcctHolderFirstName": "JOHN",
"AcctHolderID": 1,
"AcctHolderLastName": "DOE",
"AcctNo": "1111",
"AuthTxID": 15,
"CreatedBy": "John_Doe",
"CreatedOn": "\/Date(1549967986773-0500)\/",
"CustID": 15,
"CustomerRefID": "A12345NO-99",
"EndDate": "\/Date(1581483600000-0500)\/",
"ID": 12,
"IsEnabled": true,
"LimitLifeTime": 1000000.0000,
"LimitPerCharge": 1000000.0000,
"MerchID": 1,
"NumDays": 365,
"RPGUID": "",
"ServiceDescrip": "",
"StartDate": "\/Date(1549947600000-0500)\/"
},
{
"AcctHolderFirstName": "JOHN",
"AcctHolderID": 1,
"AcctHolderLastName": "DOE",
"AcctNo": "1111",
"AuthTxID": 14,
"CreatedBy": "John_Doe",
"CreatedOn": "\/Date(1549967948037-0500)\/",
"CustID": 14,
"CustomerRefID": "",
"EndDate": "\/Date(1581483600000-0500)\/",
"ID": 11,
"IsEnabled": true,
"LimitLifeTime": 1000000.0000,
"LimitPerCharge": 10000.0000,
"MerchID": 1,
"NumDays": 365,
"RPGUID": "",
"ServiceDescrip": "",
"StartDate": "\/Date(1549947600000-0500)\/"
}
],
"ErrCode": 0,
"ErrMsg": "",
"FunctionOk": true,
"NumRecords": 2,
"RespMsg": "Successfully Returned Consent Records : 2"
}
}
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
namespace SampleCode.Pages {
public class ConsentQuery1Model : PageModel {
public string msg = String.Empty;
public async Task OnGetAsync() {
// return all consents for merchant 1 with a Reference ID = CustID1234. json = { "Query": "(A=1)&&(F='CustID1234')"}
string query = "{\"Query\": \"(A=1)&&(F='CustID1234')\"}";
var client = new HttpClient();
client.BaseAddress = new Uri("https://easypay5.com/APIcardProcRESTstaging/v1.0.0/");
var request = new HttpRequestMessage(HttpMethod.Post, "Query/ConsentAnnual");
// use your session key obtained when you authenticated
request.Headers.Add("SessKey", "3481DDAA24E94C31AA303237343341303337353938");
var content = new StringContent(query, Encoding.UTF8, "application/json");
request.Content = content;
try {
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode) {
if (response.Content == null) {
logError("Response content was null");
return;
}
string responseContent = await response.Content.ReadAsStringAsync();
var jsonDom = JsonSerializer.Deserialize<JsonObject>(responseContent)!;
bool FunctionOk = (bool)jsonDom["ConsentAnnual_QueryResult"]["FunctionOk"];
//Check for unexpected errors. If errors found Stop Processing and check ErrorCodes
if (!FunctionOk) {
msg = (string)jsonDom["ConsentAnnual_QueryResult"]["ErrCode"] + " " + (string)jsonDom["ConsentAnnual_QueryResult"]["ErrMsg"];
logError(msg);
return;
}
// this just displays results as a string.
msg = "Number of records found: " + jsonDom["ConsentAnnual_QueryResult"]["NumRecords"].ToString();
msg += jsonDom["ConsentAnnual_QueryResult"]["Consents"].ToString();
} else { // request was NOT successful. Check and log error codes.
msg = response.StatusCode.ToString() + ": " + response.Content.ReadAsStringAsync();
logError(msg);
}
}
catch (Exception ex) {
logError(ex.Message);
msg = ex.Message;
}
}
private static void logError(string msg) {
// implement your logging function here.
}
}
}