Files
CCU621M/app/pos_vtk/vtk_pos_protocol.h
T

70 lines
2.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef VTK_POS_PROTOCOL_H
#define VTK_POS_PROTOCOL_H
#include "publicdata/public_define.h"
#if (POS_VTK_EN)
#ifdef __cplusplus
extern "C" {
#endif
#include "main.h"
#include "pos_vtk/vtk_frame.h"
/* 预扣款 / 结算结果枚举 */
typedef enum
{
VTK_POS_RESULT_UNKNOWN = 0,
VTK_POS_RESULT_APPROVED = 1,
VTK_POS_RESULT_DECLINED = 2,
VTK_POS_RESULT_TIMEOUT = 3
} VTK_POS_RESULT_E;
/* 支付类响应解析结果 */
typedef struct
{
char messageName[4]; /* TLV(0x01) 的消息名,3 字节,末尾补 '\0' */
U32_T operationNumber; /* TLV(0x03) 中的操作号(十进制 ASCII */
U32_T amountMinor; /* TLV(0x04) 中的金额(分) */
VTK_POS_RESULT_E eResult; /* TLV(0x0D) 中的结果码(简单定义:0/1/2/...) */
} VTK_POS_PAY_RESP_T;
/* 构造预扣款请求帧(CDP
* @param[in] opNumber 会话操作号(Operation number
* @param[in] amountMinor 预扣款金额(分)
* @param[out] pOutFrame 输出串口帧缓冲
* @param[in] outMax 缓冲区大小
* @return U16_T 串口帧长度;0=失败
*/
U16_T vtk_build_preauth_request(U32_T opNumber, U32_T amountMinor,
U8_T *pOutFrame, U16_T outMax);
/* 构造结算请求帧(CRD
* @param[in] opNumber 会话操作号(同预扣款)
* @param[in] amountMinor 最终金额(分)
* @param[out] pOutFrame 输出串口帧缓冲
* @param[in] outMax 缓冲区大小
* @return U16_T 串口帧长度;0=失败
*/
U16_T vtk_build_settle_request(U32_T opNumber, U32_T amountMinor,
U8_T *pOutFrame, U16_T outMax);
/* 解析来自 POS 的支付类响应(适用于 CDP/CRD)
* @param[in] pFrame 串口帧(包含 0x1F 起始和 CRC)
* @param[in] frameLen 帧长度
* @param[out] pResp 解析出的关键字段
* @return U8_T 1=解析成功 0=失败(CRC/TLV/字段缺失等)
*/
U8_T vtk_parse_payment_response(const U8_T *pFrame, U16_T frameLen,
VTK_POS_PAY_RESP_T *pResp);
#ifdef __cplusplus
}
#endif
#endif /* POS_VTK_EN */
#endif /* VTK_POS_PROTOCOL_H */