When using c#, the easiest way to use the PayGate DDMS API is by using the excellent RestSharp package. You can get this via NuGet by searching for RestSharp.
private string baseUrl = "https://enterprise.paygate.cloud/ddmsapi";
private string username = "myUsername";
private string password = "myPassword";
private string apiKey = "myApiKey";
// Request
// Need to provide Username, Password, ApiKey and the payer's reference
// Create an anonymous type to hold the data
var payerRequest = new
{
Username = username,
Password = password,
ApiKey = apiKey,
PayerReference = "payerRef"
};
// PayGate DDMS API URL for the CreatePayer function
string paygateApiUrl = $"{baseUrl}/api/Payer/GetPayer";
// REST call to PayGate DDMS API: CreatePayer
var client = new RestClient(paygateApiUrl);
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddJsonBody(payerRequest);
IRestResponse response = client.Execute(request);
// Deserialise the response messages from PayGate
RestSharp.Deserializers.JsonDeserializer deserial = new RestSharp.Deserializers.JsonDeserializer();
PayerResponse paygateResponse = deserial.Deserialize<PayerResponse>(response);
// Display the response
if (paygateResponse.ValidationMessages != null)
foreach (string message in paygateResponse.ValidationMessages)
tbLog.AppendText(message + Environment.NewLine);
// For demonstration purposes we will use reflection to show the response properties.
foreach (PropertyInfo propertyInfo in paygateResponse.GetType().GetProperties())
tbLog.AppendText($"{propertyInfo.Name} - {propertyInfo.GetValue(paygateResponse)}" + Environment.NewLine);
Sample Visual Studio 2017 solution
We have prepared a sample Visual Studio Winforms application to get you started. This solution contains a definition of the NewAmount class.
The solution can be download from the PayGate portal at this address: https://portal.paygate.cloud/cdn/files/paygate/enterprise/sdk/ddms/RestApi/csharp/2.1.3/DDMSRestClient.zip