c#

Parent Previous Next

When using c#, the easiest way to use the 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, the payer's reference and the message you want to send

           // Create an anonymous type to hold the data

           // for a definition of CustomMessageRequest see the sample app at the link below

           var payerRequest = new

           {

               Username = username,

               Password = password,

               ApiKey = apiKey,

               PayerReference = "00000010",

               Status = 1

           };



           // paygate DDMS API URL for the CreatePayer function

           string paygateApiUrl = $"{baseUrl}/api/Payer/updatePayerStatus";


           // REST call to Paygate DDMS API: updatePayerStatus

           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(payerResponse);

           IRestResponse response = client.Execute(request);


           // Deserialise the response messages from paygate

           RestSharp.Deserializers.JsonDeserializer deserial = new RestSharp.Deserializers.JsonDeserializer();

           Response paygateResponse = deserial.Deserialize<Response>(response);


           // Display the response

           tbLog.AppendText("Success: " + paygateResponse.Success + Environment.NewLine);

           tbLog.AppendText("Message: " + paygateResponse.Message + Environment.NewLine);


           if (paygateResponse.ValidationMessages != null)

           {

               foreach (string message in paygateResponse.ValidationMessages)

                   tbLog.AppendText(message + 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 portal at this address: https://portal.paygate.cloud/cdn/files/paygate/enterprise/sdk/ddms/RestApi/csharp/2.1.7/DDMSRestClient.zip