.netstandard2.0 Class library for communication with Asseco Group Ingenico POS Device written in C#
- Developed in Visual Studio 2019
- C# netstandard2.0
- Tested on Ingenico ict-220 Probably works on other models
You can download the IngenicoPOS Package form NuGet, which will automatically download all of the necessary dependencies, or you can install it with:
- Package Manager
Install-Package IngenicoPOS -Version 1.0.1
- .NET CLI
dotnet add package IngenicoPOS --version 1.0.1
- Paket CLI
paket add IngenicoPOS --version 1.0.1
or by adding PackageReference:
<PackageReference Include="IngenicoPOS" Version="1.0.1" />
- Download the latest release IngenicoPOS.dll from IngenicoPOS Releases
- Put the IngenicoPOS.dll to your project dependencies
- Add the IngenicoPOS.dll as a project dependency
NOTE: Make sure the project also depends on System.IO.Ports
To use the available classes, you will need to import them into the project (unless you really want to type IngenicoPOS. every single time):
using IngenicoPOS;
To Connect with the POS device, we will initialize POS class and connect to it
const string PORT = "COM9"; // Port of the POS Device (COM0 is just an example)
POS posDevice = new POS(PORT);
posDevice.Connect(); // Will return true if connection is made, otherwise will return false
// To check whether the posDevice is connected, we can do it with
if ( posDevice.IsConnected ) {
// The device is connected
} else {
// Nope :/
}
To charge a card, we can use the POS.Sale( Amount )
:
const string PORT = "COM9"; // Port of the POS Device (COM0 is just an example)
POS posDevice = new POS(PORT);
if ( posDevice.Connect() ) {
// We will charge the card for 100,00
SaleResponse res = posDevice.Sale(10000);
if ( res.Success ) {
// Sale was successful :D
} else{
// Sale wasn't successful :(
}
} else {
// Device not connected :/
}
- Clone the repository with
git clone https://github.com/F4pl0/ingenico-pos-dotnet-lib.git
- Open in Visual Studio 2019 (To eliminate compatibility issues)
- Get Dependent NuGet Packages (If they aren't already in the project)
Happy Development
- NuGet MSTest.TestAdapter Tests only
- NuGet MSTest.TestFramework Tests only
- NuGet System.IO.Ports Required for library
- Test01Connection
Tests the connectivity with the device on the PORT port. - Test02Sale
Upon connecting, tests thePOS.Sale( Int64 Amount )
Which returnsSaleResponse
.
The main test is to check whether theSaleResponse.Success
istrue
NOTE: Only public variables/functions are listed
This is the main class of the library.
Constructor | Description |
---|---|
POS (string PORT, int baudRate = 115200) | Default constructor that requires COM Port of the Device Serial and possibly baud rate |
Variable | Type | Description |
---|---|---|
IsConnected | bool | Boolean whether the device is connected |
NextTransactionNo | int | Number of next transaction |
POSPrints | bool | Boolean whether the POS device should print the reciept |
CurrencyISO | int | ISO Code of the currency |
CashierID | int | Cashier ID |
Language | string | Language from Consts.Language |
Function | Return Type | Description |
---|---|---|
Connect() | bool | Function to connect to the POS Device |
Sale( Int64 Amount) | SaleResponse | Function to charge the card |
Class with constants prior to the communication.
Sublcass | Description |
---|---|
TransactionType | Strings for different transaction types |
TransactionFlag | Response types from the POS |
Language | Different languages for the POS |
CardDataSource | Differet Card payment methods |
Static Functions for the core functionality of the library.
Function | Return Type | Description |
---|---|---|
BuildMessage( ECRMessage msg ) | string | Builds ready-to-send string from ECRMessage |
This class represents the message that is sent to the POS ( from ECR/PC.. )
Constructor | Description |
---|---|
ECRMessage () | Default constructor |
Variable | Type | Description |
---|---|---|
TerminalID | int | Terminal ID (Self-Explanatory) |
NextTransactionNo | int | Next transaction number (Self-Explanatory) |
CashierID | int | Cashier ID (Self-Explanatory) |
CurrencyISO | int | 3-Digit ISO Code of the currency |
TransactionAmount | Int64 | Amount of money to charge the card |
TransactionAmountCash | Int64 | Part of the transaction that is charged by the card |
TransactionType | string | Type of transaction (from Consts.TransactionType ) |
AuthorizationCode | string | Authorization code for Offline Sale |
InputLabel | string | Label for Input Data |
InsurancePolicyNumber | string | Insurance policy number which may be transferred to the host and printed on the receipt |
InstallmentsNumber | string | Number of installments |
LanguageID | string | Language (from Consts.Language ) |
PrintData | string | Data that should be printed on receipt. Data could be delimited by Carriage Return or Form Feed |
PayservicesData | string | TLV based data (Product code, service value,...) |
TransactionActivationCode | string | Transaction Activation Code for Mobile Payment. Regular purchase request shall be sent with TAC value to perform Mobile Payment InstantPaymentRef |
QRCodeData | string | QR code data for Instant Payment (Pull mode). |
POSPrints | bool | Flag whether the POS should print the reciept |
This class represents the message that POS device sends
Constructor | Description |
---|---|
POSMessage () | Default constructor |
POSMessage (string message) | Constructor for automatic string parsing |
Variable | Type | Description |
---|---|---|
TransactionFlag | string | Status of the transaction (from Consts.TransactionFlag ) |
TransactionType | string | Value from the request message |
TransactionAmount | Int64 | Value from the request message |
TransactionDate | string | Date of the transaction (DDMMYY) |
TransactionTime | string | Time of the transaction (HHMMSS) |
CardDataSource | string | Card Payment method (from Consts.CardDataSource ) |
AuthorizationCode | string | Authorization code ( if any ) |
Function | Return Type | Description |
---|---|---|
ParseAssign(string msg) | void | Parses the string and assignes the values to the object |
POS.Sale()
returns this class as a result to the transaction.
Constructor | Description |
---|---|
SaleResult(bool Success, POSMessage message) | Constructor for assigning all of the variables |
Variable | Type | Description |
---|---|---|
Success | bool | True if the transaction was successful, otherwise false |
Message | POSMessage | The message that POS last sent. Used for inspecting the cause of the failed/successful transaction etc... |