询问 ISO 8583 verifone vx520 的示例代码

Asking sample code for ISO 8583 verifone vx520

我想知道使用 ISO 8583 向服务器发送消息并返回对 verifone vx520 终端的响应的示例代码。

正如在对您的问题的评论中所指出的,这不是一个代码共享站点,因此这样的 open-ended 问题有点难以回答,但也许我可以让您从右脚开始。

首先,让我首先建议,如果您可以控制终端代码和它将与之通信的服务器,我建议您不要 使用 ISO8583。是的,这是一个行业标准,是的,它可以有效地传输数据,但它比 VISA-1 或 XML,或 JSON 等更难使用。这意味着你有更多的机会错误潜入您的代码。这也意味着,如果出现问题,则需要花费更多的精力来尝试找出发生的问题并尝试修复它。我已经使用了所有这些协议和其他协议,我会告诉你 ISO8583 是我最不喜欢使用的协议之一。

假设您别无选择并且必须使用 ISO8583,那么值得注意的是,ISO8583 只不过是关于如何 assemble 数据包进行通信的规范。 Vx520 终端(或任何其他 VeriFone 终端)没有什么特别之处会改变您实现它的方式与您在任何其他 C++ 平台上的实现方式不同,除了 VeriFone 确实为您提供了一个库来处理这个规范,您可以随意使用或忽略。

你根本不需要使用这个库。你可以自己动手,就好了。您可以在 Wikipedia, Code Project 和其他几个地方找到有关规范本身的更多信息(只需询问您最喜欢的搜索引擎)。请注意,当我做我的 8583 项目时,这个库对我不可用。如果我可以访问它,也许我不会那么讨厌这个协议......谁知道呢?

如果您仍在阅读本文,那么我假设 ISO8583 是一项要求(或者您是一个贪吃的惩罚者)并且您有兴趣试用 VeriFone 提供的这个引擎。

您需要做的第一件事(希望您已经完成)是将 ACT 安装为开发套件的一部分(我还建议您先访问 DevNet 并获取最新版本的 ACT你开始......)。安装后,可以在 %evoact%\include\iso8583.h 找到库 header。有关如何使用它的文档可以在 %evoact%\docs 找到。具体请参见 DOC00310_Verix_eVo_ACT_Programmers_Guide.pdf.

的第 6 章

显然,试图在此处包含一整章的信息超出了范围,但是为了让您对引擎的工作原理有一个 high-level 的了解,请允许我分享一些摘录:

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.

使用process_8583()的例子在别处给出如下:

#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.