Search code examples
iso8583openiso8583.netverifone

Asking sample code for ISO 8583 verifone vx520


I want to know the sample code for sending message to server and get back response to verifone vx520 terminal using ISO 8583.


Solution

  • As noted in a comment on your question, this is not a code sharing site, so such an open-ended question is a bit difficult to answer, but perhaps I can get you started on the right foot.

    First of all, let me start by suggesting that if you have control over the terminal code and the server that it will be talking to, I suggest you NOT use ISO8583. Yes, it's an industry standard and yes, it communicates data efficiently, BUT it is much more difficult to use than, say, VISA-1 or XML, or JSON etc. That means you have more opportunities for bugs to creep into your code. It also means that if something goes wrong, it takes a lot more effort to try and figure out what happened and try and fix it. I have used all these protocols and others besides and I'll tell you that ISO8583 is one of my least favorite to work with.

    Assuming you do not have a choice and you must use ISO8583 then it's worth noting that ISO8583 is nothing but a specification on how to assemble data packets in order to communicate. There is nothing special about the Vx520 terminal (or any other VeriFone terminal) that would change how you would implement it verses how you might do so on any other C++ platform EXCEPT that VeriFone DOES provide you with a library for working with this spec that you are free to use or ignore as you see fit.

    You don't need to use this library at all. You can roll your own and be just fine. You can find more information on the specification itself at Wikipedia, Code Project, and several other places (just ask your favorite search engine). Note that when I did my 8583 project, this library was not available to me. Perhaps I wouldn't have hated this protocol so much if I had had access to it... who knows?

    If you are still reading this, then I'll assume that ISO8583 is a requirement (or you are a glutton for punishment) and that you are interested in trying out this engine that VeriFone has provided.

    The first thing you will need to do (and hopefully, you have already done it) is to install ACT as part of the development suite (I also suggest you head over to DevNet and get the latest version of ACT before you get started...). Once installed, the library header can be found at %evoact%\include\iso8583.h. Documentation on how to use it can be found at %evoact%\docs. In particular, see chapter 6 of DOC00310_Verix_eVo_ACT_Programmers_Guide.pdf.

    Obviously, trying to include a whole chapter's worth of information here would be out of scope, but to give you a high-level idea of how the engine works, allow me to share a couple excerpts:

    This engine is designed to be table driven. A single routine is used for the assembly and disassembly of ISO 8583 packets. The assembly and disassembly of ISO 8583 packets is driven by the following structures:

    • Maps One or more collections of 64 bits that drive packet assembly and indicate what is in a message.
    • Field table Defines all the fields used by the application.
    • Convert table Defines data-conversion routines.
    • Variant tables Optional tables used to define variant fields.

    The process_8583() routine is used for the assembly and disassembly of ISO 8583 packets.

    An example of using process_8583() is given elsewhere as follows:

    #include "appl8583.h" 
    int packet_sz; 
    void assemble_packet () 
    { 
        packet_sz = process_8583 (0, field_table, test_map, buffer, sizeof( buffer));
        printf ("\ fOUTPUT SIZE %d", packet_sz); 
    }
    
    void disassemble_packet () 
    { 
        packet_sz = process_8583 (1, field_table, test_map, buffer, packet_sz); 
        printf ("\ fINPUT NOT PROCESSED %d", packet_sz); 
    }
    

    To incorporate this engine into an application, modify the APPL8583.C and APPL8583.H files so that each has all the application variables required in the bit map and set up the map properly. Compile APPL8583.C and link it with your application and the ISO 8583 library. Use the following procedures to transmit or receive an ISO 8583 packet using the ISO 8583 Interface Engine:

    To transmit an ISO 8583 packet

    1 Set data values in the application variables for those to transmit.

    2 Call the prot8583_main() routine. This constructs the complete message and returns the number of bytes in the constructed message.

    3 Call write() to transmit the message.

    To receive a message

    1 Call read() to receive the message.

    2 Call the process_8583() routine. This results in all fields being deposited into the application variables.

    3 Use the values in the application variables.