Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Returns the version of the Moniepoint Communication Library.

...

2. CheckConnection()

Checks the connection status with the Moniepoint payment terminal.

PaymentSendAndReceive(out response, transactionRequest)

Sends a payment request to the Moniepoint payment terminal and get response.

Usage Example

Code Block
languagec#
using System;
using MoniepointLibrary;

namespace MoniepointApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string response;

            try
            {
                string portName = "COM1";
                int baudRate = 115200;
                int timeoutMilliseconds = 90000; //90 seconds

                using (var moniepointServicecommunicationService = new MoniepointCommunicationService("COM1"portName, 9600baudRate, 5000timeoutMilliseconds))
                {
    if (moniepointService.CheckConnection())
    {
        var paymentRequest
                    var transactionRequest = new PaymentRequest
        {
            TransactionType
                    {
                        TransactionType = "Sale1",
            Amount
                        Amount = "100.00",
            MerchantReference
                        MerchantReference = "123456"
        };

        var paymentResponse = moniepointService.SendPaymentRequest(paymentRequest);
        if (paymentResponse.Status == "success")
        {
            var responseData = paymentResponse.ResponseData;
            var responseObject = paymentResponse.ResponseDataObject as Response;
        }
        else
        {
            // Handle error or timeout
        }
    }
}ABC123"
                    };

                    int paymentStatus = communicationService.PaymentSendAndReceive(out response, transactionRequest);

                    if (paymentStatus == MoniepointCommunicationService.SuccessStatus)
                    {
                        Console.WriteLine("Payment Response Data: " + response);
                    }
                    else
                    {
                        Console.WriteLine("Error code: {0}, description: {1}", paymentStatus, communicationService.GetErrorMessage(paymentStatus));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }

            Console.WriteLine("Press Enter to exit...");
        }
    }
}

Transaction Type

1 - Credit Card Purchase

...

96 - System malfunction

98 - Exceeds cash limit

Response Class

The Response class represents the response data structure received from the Moniepoint payment terminal.

...