Exemplo requisição POST, PUT, GET e DELETE padrão PIX definido no SPI(Sistema de Pagamentos Instantâneos).
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define HOST_ADDR "127.0.0.1"
#define USER_ID "master"
#define USER_PWD "12345678"
int main()
{
int nRet = 0;
const char *pszHeaderList[] = { "Content-Type: application/xml; charset=utf-8" };
DWORD dwHeaderListCount = 1;
BYTE pbTestData[] =
"<?xml version=\"1.0\" encoding=\"UTF - 8\" standalone=\"no\"?><xml>sdfsdf</xml>";
const char szKeyId[] = "key";
const char szKeyCert[] = "key_cert";
const char szPIXChain[] = "pix_chain";
BYTE *pbResponseHeader = NULL;
DWORD dwResponseHeaderLen = 0;
BYTE *pbResponseBody = NULL;
DWORD dwResponseBodyLen = 0;
const char szUrl[] = "https://127.0.0.1:8000";
if (nRet) {
printf("Falha na funcao: DInitialize \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("Bibliotecas inicializadas.\n");
if (nRet) {
printf("Falha na funcao: DOpenSession \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("Sessao com o Dinamo estabelecida.\n");
szKeyId,
szKeyCert,
szPIXChain,
szUrl,
dwHeaderListCount,
pszHeaderList,
sizeof(pbTestData) - 1,
pbTestData,
0,
&dwResponseHeaderLen,
&pbResponseHeader,
&dwResponseBodyLen,
&pbResponseBody,
0);
if (nRet) {
printf("Falha na funcao: DPIXPost \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("PIX post executado com sucesso\n");
szKeyId,
szKeyCert,
szPIXChain,
szUrl,
dwHeaderListCount,
pszHeaderList,
sizeof(pbTestData) - 1,
pbTestData,
0,
&dwResponseHeaderLen,
&pbResponseHeader,
&dwResponseBodyLen,
&pbResponseBody,
0);
if (nRet) {
printf("Falha na funcao: DPIXPut \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("PIX put executado com sucesso\n");
szKeyId,
szKeyCert,
szPIXChain,
szUrl,
0,
NULL,
0,
&dwResponseHeaderLen,
&pbResponseHeader,
&dwResponseBodyLen,
&pbResponseBody,
0);
if (nRet) {
printf("Falha na funcao: DPIXGet \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("PIX get executado com sucesso\n");
szKeyId,
szKeyCert,
szPIXChain,
szUrl,
0,
NULL,
0,
&dwResponseHeaderLen,
&pbResponseHeader,
&dwResponseBodyLen,
&pbResponseBody,
0);
if (nRet) {
printf("Falha na funcao: DPIXDelete \nCodigo de erro: %d\n", nRet);
goto clean;
}
printf("PIX delete executado com sucesso\n");
clean:
if (hSession) {
printf("Sessao encerrada.\n");
}
printf("Bibliotecas finalizada.\n");
return nRet;
}
Application Programming Interface (API) do HSM Dinamo.
void * HSESSIONCTX
Definição dinamo.h:68
#define DEFAULT_PORT
Definição dinamo.h:1949
unsigned char BYTE
Definição dinamo.h:45
unsigned int DWORD
Definição dinamo.h:46
#define ENCRYPTED_CONN
Definição dinamo.h:585
#define SS_USER_PWD
Definição dinamo.h:576
void AAP_API DFree(void *p)
int AAP_API DPIXDelete(HSESSIONCTX hSession, const char *szKeyId, const char *szCertId, const char *szPIXCertChainId, const char *szURL, DWORD dwCountRequestHeaderList, const char *pszRequestHeaderList[], DWORD dwTimeOut, DWORD *pdwSizeResponseHeaders, BYTE **ppbResponseHeaders, DWORD *pdwSizeResponseBody, BYTE **ppbResponseBody, DWORD dwParam)
int AAP_API DPIXPost(HSESSIONCTX hSession, const char *szKeyId, const char *szCertId, const char *szPIXCertChainId, const char *szURL, DWORD dwCountRequestHeaderList, const char *pszRequestHeaderList[], DWORD dwSizeRequestData, BYTE *pbRequestData, DWORD dwTimeOut, DWORD *pdwSizeResponseHeaders, BYTE **ppbResponseHeaders, DWORD *pdwSizeResponseBody, BYTE **ppbResponseBody, DWORD dwParam)
int AAP_API DPIXGet(HSESSIONCTX hSession, const char *szKeyId, const char *szCertId, const char *szPIXCertChainId, const char *szURL, DWORD dwCountRequestHeaderList, const char *pszRequestHeaderList[], DWORD dwTimeOut, DWORD *pdwSizeResponseHeaders, BYTE **ppbResponseHeaders, DWORD *pdwSizeResponseBody, BYTE **ppbResponseBody, DWORD dwParam)
int AAP_API DPIXPut(HSESSIONCTX hSession, const char *szKeyId, const char *szCertId, const char *szPIXCertChainId, const char *szURL, DWORD dwCountRequestHeaderList, const char *pszRequestHeaderList[], DWORD dwSizeRequestData, BYTE *pbRequestData, DWORD dwTimeOut, DWORD *pdwSizeResponseHeaders, BYTE **ppbResponseHeaders, DWORD *pdwSizeResponseBody, BYTE **ppbResponseBody, DWORD dwParam)
int AAP_API DOpenSession(HSESSIONCTX *phSession, DWORD dwParam, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
int AAP_API DCloseSession(HSESSIONCTX *phSession, DWORD dwFlags)
int AAP_API DInitialize(DWORD dwReserved)
int nPort
Definição dinamo.h:3092
char szUserId[MAX_USR_LEN]
Definição dinamo.h:3093
char szAddr[MAX_ADDR_LEN]
Definição dinamo.h:3091
char szPassword[MAX_USR_PWD]
Definição dinamo.h:3094