REST API

Getting started with the REST API for Number

Our REST API allows full integration of Number services with a high degree of customization. You can use our REST API reference to learn about specific methods in the API.

Before you continue this section, we recommend reading sections about authentication, best practices, and input validation.

Examples

Authenticate

An example of using the Authenticate method.

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;
}

An example of using ConsentAnnual_ProcPayment method.

Void Transaction

An example of using CardSale_Void method.

Credit Transaction

An example of using CardSale_ApplyCredit method.

Query Transaction

An example of using Query_Transaction method.

An example of using Query_ConsentGeneral method.

Generate Receipt

An example of using ReceiptGenerate method.

Download our Postman Collections

The Complete Postman Collection

The complete postman collection includes sample requests for all of the API calls listed on this site.

Download the Complete Postman Collection:

The Essentials Postman Collection

The essentials postman collection includes sample requests to get you started with the essential API calls. The essentials collection includes:

  • Authentication

  • Voiding an open sale transaction

  • Crediting a previously settled sale transaction

  • Process an annual consent payment

  • Annual consent query

  • Transaction query

  • Generate a receipt

Download the Essentials Postman Collection:

Last updated

Was this helpful?