.netstandard2.0 Class library for communication with Asseco Group Ingenico POS Device written in C#
You can download the IngenicoPOS Package form NuGet, which will automatically download all of the necessary dependencies, or you can install it with:
Install-Package IngenicoPOS -Version 1.0.1
dotnet add package IngenicoPOS --version 1.0.1
paket add IngenicoPOS --version 1.0.1
or by adding PackageReference:
<PackageReference Include="IngenicoPOS" Version="1.0.1" />
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 :/
}
git clone https://github.com/F4pl0/ingenico-pos-dotnet-lib.git
Happy Development
POS.Sale( Int64 Amount )
Which returns SaleResponse
.SaleResponse.Success
is true
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 | string | Reference number for Instant Payment – mandatory for Instant Payment Refund (same value as in response on Instant Payment Purchase or Inquiry) |
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... |