简体   繁体   中英

How to enable POS payment on my C# windows application?

How the data on card is read to POS application?

I have been told some of the information such as card no and the holder's name is displayed on to the screen of the supervisor's terminal. In order to send the card information to the POS supervisor app, Keypress() event SHOULD BE used.

How do i send card information from POS card swipe machine to POS app? because just by installing drivers and configuring payment gateways would not send data to pos app. what i must do to make that keypress() event execute? im sure the developer has to write code to get that string data from the POS card swipe machine. Would you be generous enough to go through the process and show some sample code (sample code in online or some code you would like to share) on how to do it? because there is no way from out of no where the Keypress() event executes on a card swipe?

First off, this sounds like a PCI DSS nightmare. Displaying card information on screen is a definite problem, and the following code leaves you vulnerable to keylogging and memory parsing. That said...

If you're expected to use a KeyPress event for this, I assume you're receiving the track info from a keyboard wedge MSR, which is pretty simple - it just spits out the track info in plain text. You could use a KeyPress event to handle each character entered, and then send the string on the track end sentinel (typically ? ):

Let's assume for simplicity's sake that you're swiping into a WinForms TextBox :

In your Form Designer select your text box, go to Events and add a KeyPress handler, or alternatively in your Form's InitializeComponent() method, attach it manually:

this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);

Then define your KeyPress event in the Form's code-behind:

private StringBuilder trackInfo;
private bool track1Complete = false;

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar != '?' && !track1Complete)
    {
        trackInfo.Append(e.KeyChar);
    }
    else if (e.KeyChar == '?' && !track1Complete)
    {
        trackInfo.Append(e.KeyChar);
        trackInfo.AppendLine();
        track1Complete = true;
    }
    else if (e.KeyChar != '?' && track1Complete)
    {
        trackInfo.Append(e.KeyChar);
    }
    else if (e.KeyChar == '?' && track1Complete)
    {
        trackInfo.Append(e.KeyChar);
        trackInfo.AppendLine();
        sendTrackInfo();
    }
}

What we're doing here is parsing the KeyChar on each KeyPress event argument triggered by the swipe. ? is the typical end sentinel for a single track, and there are two tracks that are considered necessary for processing a card (see here for more on the format: http://en.wikipedia.org/wiki/Magnetic_stripe_card#Financial_cards ) - so we consider the card info completed at the end of the second track.

You're going to need to define the sendTrackInfo() method referenced above to format (remove sentinels, separate, etc) and send the track data you've collected in trackInfo.ToString() to your supervisor app, possibly in XML or as a stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM