locked
Seding packets to a pinpad for payment by credit cards. RRS feed

  • Question

  • Good morning,

    In my software, I am trying to convert a monetary field value to an HEX or preferably a ASCII format, then, save it to a file and print and send the data via a generic text printer using an Ethernet connection. The printer port is 192.168.0.162 so the pinpad does move when sending a file, but does not go further then the welcome screen. (but it goes out of sleep)

    When using a small program called "Packet sender" I am able to make it work perfectly, I am understanding the codification but I do not know how to convert and save it to a file to be printed. Here an image that will help you understand.

    Thank for your time

    Claude


    Claude Larocque

    Tuesday, March 14, 2017 11:23 AM

Answers

  • Hi Claude Larocque,

     I try to search the solution for this issue.

    I find that with the help of winsock control we can send data to host.

    it uses UDP and TCP to send the data.

    below is one example of that.

    Dim ByteX as Byte
    Dim X as Long
    Dim FileX as Interger
    
    Winsock3.LocalPort = 10000
    Winsock3.RemoteHost = "211.233.70.51"
    Winsock3.RemotePort = 9500
    
    FileX = FreeFile
    Open App.Path + "udp1.dat" for Binary as FileX
    X = 1
    Do Until X = FileLen(App.Path + "udp1.dat") + 1
    Get #FileX, X, ByteX
    Winsock3.SendData ByteX
    X = X + 1
    Loop
    Close FileX
    

    Reference:

    Sending Binary Data Via UDP Protocol (Winsock)

    Winsock 3

    I find many examples in which people are using winsock, but those are VB examples.

    you can try to search further in this direction to find the solution.

    I did not use this control or code before to send data to host so I am not sure whether it will work or not.

    but I find this resource so provide it to you.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 17, 2017 9:13 AM

All replies

  • Hi Claude Larocque,

    you can try to use function like below.

    Function AscEncode(str)
        Dim i
        Dim sAscii
        
        sAscii = ""
        For i = 1 To Len(str)
            sAscii = sAscii + CStr(Hex(Asc(Mid(str, i, 1))))
        Next
        
        AscEncode = sAscii
        Debug.Print AscEncode
    End Function

    Reference:

    MS Access: Asc Function

    ASCII Table

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 15, 2017 5:38 AM
  • Hi Deepak,

    First let me thank you to have taking the time to answer, since the last 3 hours, I use your code in Access to try to figure out how could I make that work, I have created a form named "frmGlobalPayments" on which I have some fields and button that allows me to do some test.

    It seems to partially work, when I enter the code that I know it works from a program named "Packet Sender", the code generated on my Access form "frmGlobalPayments" is slightly different then it should be, I thought that ASCII and HEX are universal no? Anyway, the image below will show you the progress I made and the result, the problem is that the HEX code is much different and the ASCII code has a \ to many, so when I print it to send the data to the pinpad, it goes out of sleep, but do nothing. When I use the Packet Sender it does the same with the code generated with Access.

    Here is the image and thank you again for your time and help.

    Claude


    Claude Larocque

    Wednesday, March 15, 2017 8:59 AM
  • Hi Claude Larocque,

    I am something missing in your above description.

    when I try to convert the text "sale of 1.00 $" to ASCII.

    I get "73616C65206F6620312E30302024"

    I did not get any \ in the value.

    also I have a question , how you send this value to packet sender?

    by manually copy paste or with any code?

    I am not aware with this application.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 16, 2017 9:27 AM
  • Hi Deepak,

    You're right, this is the first time I do not find any code for sending packets within Microsoft Access, I can create a text file and print it to a generic only text printer on port 192.168.0.162, the pinpad goes out of sleep but nothing happens.

    So I guess the solution is to send in an ASCII format or HEX format, but it does not work either, really hard to find VBA that can send data in packets.

    Any idea?

    Thanks,

    Claude


    Claude Larocque

    Note: You're right I copy and paste the code in the program Packet sender...

    Thursday, March 16, 2017 1:20 PM
  • Hi Claude Larocque,

     I try to search the solution for this issue.

    I find that with the help of winsock control we can send data to host.

    it uses UDP and TCP to send the data.

    below is one example of that.

    Dim ByteX as Byte
    Dim X as Long
    Dim FileX as Interger
    
    Winsock3.LocalPort = 10000
    Winsock3.RemoteHost = "211.233.70.51"
    Winsock3.RemotePort = 9500
    
    FileX = FreeFile
    Open App.Path + "udp1.dat" for Binary as FileX
    X = 1
    Do Until X = FileLen(App.Path + "udp1.dat") + 1
    Get #FileX, X, ByteX
    Winsock3.SendData ByteX
    X = X + 1
    Loop
    Close FileX
    

    Reference:

    Sending Binary Data Via UDP Protocol (Winsock)

    Winsock 3

    I find many examples in which people are using winsock, but those are VB examples.

    you can try to search further in this direction to find the solution.

    I did not use this control or code before to send data to host so I am not sure whether it will work or not.

    but I find this resource so provide it to you.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 17, 2017 9:13 AM