简体   繁体   English

如何在C#Windows应用程序上启用POS付款?

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

How the data on card is read to POS application? 如何将卡上的数据读取到POS应用程序?

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. 为了将卡信息发送到POS管理员应用程序,应该使用Keypress()事件。

How do i send card information from POS card swipe machine to POS app? 如何从POS刷卡机向POS应用发送卡信息? because just by installing drivers and configuring payment gateways would not send data to pos app. 因为仅安装驱动程序和配置支付网关就不会将数据发送到pos应用。 what i must do to make that keypress() event execute? 我必须怎么做才能使keypress()事件执行? im sure the developer has to write code to get that string data from the POS card swipe machine. 确保开发人员必须编写代码才能从POS卡刷卡机获取该字符串数据。 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? 因为没有办法Keypress()不可能在刷卡时在哪里执行Keypress()事件?

First off, this sounds like a PCI DSS nightmare. 首先,这听起来像是PCI DSS的噩梦。 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. 如果期望为此使用KeyPress事件,我假设您是从键盘楔MSR接收轨道信息的,这非常简单-它只是以纯文本形式显示轨道信息。 You could use a KeyPress event to handle each character entered, and then send the string on the track end sentinel (typically ? ): 您可以使用KeyPress事件来处理输入的每个字符,然后在跟踪结束标记(通常为? )上发送字符串:

Let's assume for simplicity's sake that you're swiping into a WinForms TextBox : 为了简单起见,假设您要刷入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: 在表单设计器中,选择文本框,转到“事件”并添加KeyPress处理程序,或者在表单的InitializeComponent()方法中,手动附加它:

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

Then define your KeyPress event in the Form's code-behind: 然后在表单的代码后面定义您的KeyPress事件:

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. 我们在这里所做的是在滑动触发的每个KeyPress事件参数上解析KeyChar ? 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. 是单个轨道的典型末端标记,并且有两个轨道被认为是处理卡所必需的(有关此格式的更多信息,请参见此处: http : //en.wikipedia.org/wiki/Magnetic_stripe_card#Financial_cards )-因此我们认为卡信息在第二条轨道的末尾完成。

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. 您将需要定义sendTrackInfo()方法进行格式化(删除标记,分离等),并将您在trackInfo.ToString()收集的跟踪数据发送到您的主管应用程序,可能是XML或流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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