Giter Club home page Giter Club logo

ingenico-pos-dotnet-lib's Introduction

ingenico-pos-dotnet-lib

Build Status GitHub release Open Source Love svg1
.netstandard2.0 Class library for communication with Asseco Group Ingenico POS Device written in C#

Info

  • Developed in Visual Studio 2019
  • C# netstandard2.0
  • Tested on Ingenico ict-220 Probably works on other models

Download

Donwloading the package from NuGet

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" />

Manually downloading the assembly

  1. Download the latest release IngenicoPOS.dll from IngenicoPOS Releases
  2. Put the IngenicoPOS.dll to your project dependencies
  3. Add the IngenicoPOS.dll as a project dependency

NOTE: Make sure the project also depends on System.IO.Ports

Usage

Import

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;

Connection

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 :/
}

Sale

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 :/
}

Development

  1. Clone the repository with
git clone https://github.com/F4pl0/ingenico-pos-dotnet-lib.git
  1. Open in Visual Studio 2019 (To eliminate compatibility issues)
  2. Get Dependent NuGet Packages (If they aren't already in the project)

Happy Development

Dependencies

  • NuGet MSTest.TestAdapter Tests only
  • NuGet MSTest.TestFramework Tests only
  • NuGet System.IO.Ports Required for library

Tests

  1. Test01Connection
    Tests the connectivity with the device on the PORT port.
  2. Test02Sale
    Upon connecting, tests the POS.Sale( Int64 Amount ) Which returns SaleResponse.
    The main test is to check whether the SaleResponse.Success is true

Classes

NOTE: Only public variables/functions are listed

POS

This is the main class of the library.

Constructors

Constructor Description
POS (string PORT, int baudRate = 115200) Default constructor that requires COM Port of the Device Serial and possibly baud rate

Variables

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

Functions

Function Return Type Description
Connect() bool Function to connect to the POS Device
Sale( Int64 Amount) SaleResponse Function to charge the card

Consts

Class with constants prior to the communication.

Subclasses / Constant sets

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

Utils

Static Functions for the core functionality of the library.

Functions

Function Return Type Description
BuildMessage( ECRMessage msg ) string Builds ready-to-send string from ECRMessage

ECRMessage

This class represents the message that is sent to the POS ( from ECR/PC.. )

Constructors

Constructor Description
ECRMessage () Default constructor

Variables

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

POSMessage

This class represents the message that POS device sends

Constructors

Constructor Description
POSMessage () Default constructor
POSMessage (string message) Constructor for automatic string parsing

Variables

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 )

Functions

Function Return Type Description
ParseAssign(string msg) void Parses the string and assignes the values to the object

SaleResult

POS.Sale() returns this class as a result to the transaction.

Constructors

Constructor Description
SaleResult(bool Success, POSMessage message) Constructor for assigning all of the variables

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...

ingenico-pos-dotnet-lib's People

Contributors

f4pl0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ingenico-pos-dotnet-lib's Issues

POS Connected

Hello!

Does this solution supports iWL250 terminal?

i try to connect but device can't interaction .

Network

Since most pos machine is connected via network, how can we communicate with pos machine via tcp/ip instead of serial port?

System.FormatException: 'wrong input string format.'

Hi,
i'm trying to use this library for my Ingenico ICT220 but i got this error on this line:
SaleResult res = posDevice.Sale(importo);

"importo" is: Int64 importo = Convert.ToInt64(100);

Using the source code, the error is in the ParseAssing method, on this line:
_terminalID = int.Parse(parseArr[0].Substring(3, 2));

parseArr has only one element with these values: "\0\0\0\0\0\0\0\0\0\0"

What could be wrong? Maybe some POS setting?

Thank you so much in advance.

EDIT:
I changed the baudrate to 9600 as in the pos settings, and now i have this error on the same line:
System.ArgumentOutOfRangeException: 'Index e length devono fare riferimento a una posizione nella stringa. Nome parametro: length'
(sorry it's in italian).

parseArr now is: "\u0015\u0003i"
So i receive a NACK, but i have no information after that.
Maybe some setting into the pos device?

Hello

Sorry for the basic request, but how can I test the library? Is there a sandbox, emulator or I've to ask someone for a phisical device?

posDevice.Sale method return null in iCT250 ingenico

Hello,
I applied the as it is shown in the readme, I changed the SaleResponse to SaleResult because there wasn't any SaleResponse class.
However, I still got posDevice.Sale result null.
Should It return Success false if the transaction is unsuccessful and true if it is successful?
How can we solve this problem?

iPP 350

Hi, does it support iPP 350 ingenico devices ?

The iPP 350 doesn't seems to have the insurancepolicy number fields.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.