REST API
Getting started with the REST API for Number
Examples
Authenticate
private void Authenticate() {
/// create request with account code and Token
string jsonContent = "{\"AcctCode\":\"EP9142446\",\"Token\":\"F31D16BA862F4EC6AE95CB90450C826A\"}";
byte[] data = Encoding.UTF8.GetBytes(jsonContent);
// Specify Number Endpoint
string MyUrl = "https://easypay5.com/APIcardProcREST/v1.0.0/Authenticate";
// create a webrequest
WebRequest request = WebRequest.Create(MyUrl);
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = data.Length;
string responseContent = null;
/// Important to handle any exceptions
try
{
// execute request
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
using (StreamReader sr = new StreamReader(stream))
{
responseContent = sr.ReadToEnd();
}
}
}
}
catch (Exception ee)
{
/// consume any communication exceptions and abort
MessageBox.Show("Communication Exception : " + ee.Message);
/// important to insert your Logging function here
return;
}
/// parse Json in any number of ways , we use Newtonsoft
var AuthResp = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(responseContent);
var MyResp = AuthResp.AuthenticateResult;
/// here are the important values to consume
bool FunctionOk = (bool)MyResp.FunctionOk;
bool AuthSuccess = (bool)MyResp.AuthSuccess;
int ErrCode = (int)MyResp.ErrCode;
string ErrMsg = (string)MyResp.ErrMsg;
string RespMsg = (string)MyResp.RespMsg;
//Check for unexpected Errors on cloud servers. If errors found log Error info and abort;
if (!FunctionOk)
{
MessageBox.Show("Aspen Error : " + ErrMsg + " : ErrorCode: " + ErrCode);
/// important to insert your Logging function here
return;
}
//Check for failures such as Invalid or Expired Credentials or Inactive Account.
if (!AuthSuccess)
{
MessageBox.Show("Failed Authentication : " + RespMsg);
/// important to insert your Logging function here
return;
}
/// Arriving here means that the Authentication was successful. You will retrieve a SessionKey and
/// a list of Merchant Records associated with this account. The session key will be used for all
/// subsequent API calls within the next 25 hours
string SessKey = (string)MyResp.SessKey;
var MerchantList = MyResp.MerchantList;
}Process Annual Consent
Void Transaction
Credit Transaction
Query Transaction
Consent General Query
Generate Receipt
Download our Postman Collections
Last updated
Was this helpful?