...
The Moniepoint Communication Library provides a C# implementation for seamless communication with Moniepoint payment terminals through a serial port. This library facilitates developers in interacting with Moniepoint devices by enabling the sending of payment requests and checking the connection status.
DLL Name
The DLL associated with the Moniepoint Communication Library is named moniepoint.dll
You need the DLL file to enable communication
Constructor
public MoniepointCommunicationService(string portName, int baudRate, int timeoutMilliseconds)
...
Returns the version of the Moniepoint Communication Library.
2.
CheckConnectionPaymentSendAndReceive(out response, transactionRequest)
Checks the connection status with the Moniepoint payment terminal.
SendPaymentRequest(PaymentRequest request)
Sends a payment request to the Moniepoint payment terminal and get response.
Usage Example
Code Block | ||
---|---|---|
| ||
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 |
...
communicationService = new MoniepointCommunicationService( |
...
{
if (moniepointService.CheckConnection())
{
var paymentRequest = new PaymentRequest
{
TransactionType = "Sale",
Amount = "100.00",
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
}
}
}
...
portName, baudRate, timeoutMilliseconds))
{
var transactionRequest = new PaymentRequest
{
TransactionType = "1",
Amount = "100.00",
MerchantReference = "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
2 - Debit Card Purchase
...
11 - Gift Card Balance
Response CodesCode
00 - Approved or completed successfully
...
96 - System malfunction
98 - Exceeds cash limit
Response Class
The Response class represents the response data structure received from the Moniepoint payment terminal.
public class ResponseObject
{
public string MaskedPan { get; set; }
public string ResponseCode { get; set; }
public int Amount { get; set; }
public string AuthorizeCode { get; set; }
public string RetrievalRefNo { get; set; }
public string TerminalID { get; set; }
public string TransDate { get; set; }
public string TransTime { get; set; }
}
Sample Response - POS Transfer
Code Block |
---|
<?xml
version="1.0"?>
<Response>
<MaskedPan>null</MaskedPan>
<ResponseCode>00</ResponseCode>
<AuthorizeCode>null</AuthorizeCode>
<CardHolderName>null</CardHolderName>
<Amount>10000</Amount>
<RetrievalRefNo>null</RetrievalRefNo>
<TerminallD>2214YY0M
</TerminalID>
<TransTime>2024-09-27T00:24:31.000000000</TransTime>
<PaymentMethod>POS_TRANSFER</PaymentMethod>
<CardScheme>null</CardScheme>
</Response> |
Sample Response - Card Payment
Code Block |
---|
<?xml version="1.0"?>
<Response>
<MaskedPan>512345******1230</MaskedPan>
<ResponseCode>00</ResponseCode>
<AuthorizeCode>1B7D</AuthorizeCode>
<CardHolderName>CUSTOMER/ZENITH</CardHolderName>
<Amount>10000</Amount>
<RetrievalRefNo>000000000007</RetrievalRefNo>
<TerminalID></TerminalID>
<TransTime>2023-09-11T17:07:33.000000000</TransTime>
<PaymentMethod>CARD_PURCHASE</PaymentMethod>
<CardScheme>MASTERCARD</CardScheme>
</Response> |
Error codes
Code Block | ||
---|---|---|
| ||
public const int SuccessStatus = 0;
public const int PortNotOpenStatus = -1;
public const int SendErrorStatus = -2;
public const int ReceiveErrorStatus = -3;
public const int ReceiveTimeoutStatus = -4;
public const int InvalidResponseLengthStatus = -5;
public const int InvalidAcknowledgeResponseStatus = -6;
public const int InvalidConnectionStatusResponse = -7;
public const int ReceiveConnectionErrorStatus = -8;
public const int ReceiveTimeoutStatusWithPartialResponse = -9; |