1

I am tasked with creating a program that can initiate a payment on an Ingenico card terminal. It is a smaller part to a larger project to create a custom P.O.S system for a business. But I am facing a variety of road blocks making this problem difficult.

  1. I have no experience in programming with serial ports. The documentation I have found online only depicts writing strings or bytes. The examples are simple but do not tell me enough information.

  2. There is no documentation for the device I am using. Ingenico does not provide this information. The only way I have been able to figure out what data the card reader is expecting to initiate a payment is via this already completed project on github. Here is the link

https://github.com/Ousret/pyTeliumManager

This implementation is in python, and is using a linux-based system. We would be using this but we need a more custom implementation, hence why I am doing this in java.

I have looked and looked in this project to find how the data is structured and then sent over the serial port connection, but at this point I am missing it out of ignorance. I'm not familiar with python at all and the only thing I know is that the data to initiate a payment is as follows...

  • a float for the transaction amount

  • three strings, one for the currency type (USD, EUR etc) payment method (card) and the checkout ID (which can be anything, this is for personal book keeping)

  • and three booleans, one if you would like to wait for the transaction to be approved, one if you would like bank verification and one if you would like the payees payment information saved. (Ive set all these to false as they're not necessary at this moment. I am just trying to write something that works as a proof of concept before building an interface)

Now, here's some of my test code, and most of this is similar to what I've found on the internet through my research.

    public static void main(String[] args) {
    SerialPort cerealPort = new SerialPort("COM9");

        try {


            System.out.println("Port opened: " + cerealPort.openPort());
            System.out.println("reading bytes " + cerealPort.readBytes());
            System.out.println("name " + cerealPort.getPortName());
            cerealPort.writeString("bing bong");



            //cerealPort.setEventsMask(256);


            System.out.println("Params setted: " + cerealPort.setParams(9600, 8, 1, 0));
            System.out.println("\"Hello World!!!\" successfully writen to port: " + cerealPort.writeBytes("Hello World!!!".getBytes()));

            System.out.println("Port closed: " + cerealPort.closePort());
        }
        catch (SerialPortException ex){
            System.out.println(ex);
        }
    }

} 

This code really doesn't really do anything and was just to test that communication with the device is working properly. Note that nothing happens on the terminal when this code is run.

Now I have this class called TelliumData, which has the data members I described.

public class TelliumData {
float amount;
String paymentMode = "debit";
String currency = "USD";
String checkoutId = "1";
boolean transactionWait = false; // waits for trans to end. Set to True if you need valid transaction status otherwise, set it to False.
boolean collectPaymentInfo = false;
boolean forceBankVerify = false;

}

I have 0 idea how to pass this information to the terminal using the functions in JSSC

My question is, at its core, how to I send this data over a serial port?

I have tried using .writebytes and .writeint to send over all data one by one but this doesn't do anything and doesn't trigger a payment initialization on the card reader.

I don't understand how the python implementation has done it either. It would be great if someone could explain how that data is packaged and sent.

0 Answers0