FoxPro Programming
retrieving data from credit card swiper
Gravatar is a globally recognized avatar based on your email address. retrieving data from credit card swiper
  JohnB
  All
  Mar 26, 2017 @ 03:49am

I am retrieving credit card details from a Magtek credit card swiper. The declare looks like this

declare Integer GetKSN in MTPPSCRA.dll String @,integer ksnlen,integer opstatus

and I call it like this:

r = GetKSN(@lcksn,lnksn,lnopstatus)

I don't get any error and r = 0 meaning success.

lcksn should contain a 20 character hexadecimal string that looks something like 9502580000005F20239A

but I am getting something unreadable.

Gravatar is a globally recognized avatar based on your email address. re: retrieving data from credit card swiper
  Rick Strahl
  JohnB
  Mar 26, 2017 @ 05:51pm

Are you getting binary data or string data? If you get string data it's probably base64 encoded. Use:

STRCONV(lcBase64String,14)

to turn it into its binary representation.

Or vice versa if if the data is binary and you want to turn it into base64 content.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: retrieving data from credit card swiper
  JohnB
  Rick Strahl
  Mar 29, 2017 @ 07:31pm

Thanks, Rick.

I actually had to use the strconv(lcstr,15) option to get what I needed.

Hope all is well with you. John

Gravatar is a globally recognized avatar based on your email address. re: retrieving data from credit card swiper
  JohnB
  JohnB
  Mar 30, 2017 @ 05:26pm

I'm back.

This follow up is to see how to deal with dlls. The function I am trying to call is defined like this:

c++ const CARD_DATA* __stdcall GetCardDataInfo();

typedef struct CARD_DATA { //a bunch of fields BYTE DataType; char *Track1; etc... )

In foxpro, I have:

declare String GetCardDataInfo in MTPPSCRA.dll

buffer = GetCardDataInfo() && after this buffer contains a double quote ???

how do I deal with the struct?

Gravatar is a globally recognized avatar based on your email address. re: retrieving data from credit card swiper
  Rick Strahl
  JohnB
  Mar 31, 2017 @ 02:19pm

You can't access this data directly. You have to load it into a predefined string buffer (REPL(" ",1024) or whatever the size is) which gives you the data structure as a binary binary blob of data. After that you have to parse the binary data using bit logic which - sucks.

You can't access C code directly from FoxPro easily - you can do the parsing using one of the various bin parsers but that's extremely tedious and error prone as you have to figure out how much data every piece of data in the structure takes up and then convert and map that to FoxPro. It's possible, but really painful.

The better choice is to build a C++ Win32 dll that calls the third party DLL and provides you the data in a usable format either as individual values, or something exported to a format you can read like XML or JSON or a text file.

+++ Rick ---

© 1996-2024