Preciso integrar o gateway de pagamento da Gerencianet (www.gerencianet.com.br) para geração de boletos de cobrança. Acontece que estou tendo problemas com o uso da CURL.
Alguém já fez esta integração? Poderia dar uma força?
Segue exemplo da API em C
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.gerencianet.com.br/v1/charge");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: {{Authorization}}");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\n \"items\": [\n {\n \"name\": \"item\",\n \"value\": 500,\n \"amount\": 1\n }\n ]\n}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
E este é o teste que fiz usando o xHarbour
FUNCTION GERENCIANET()
cURL := CURL_EASY_INIT()
IF !EMPTY(cURL)
CURL_EASY_SETOPT(cURL, HB_CURLOPT_CUSTOMREQUEST, "POST")
CURL_EASY_SETOPT(cURL, HB_CURLOPT_URL, "https://sandbox.gerencianet.com.br/v1/charge")
CURL_EASY_SETOPT(cURL, HB_CURLOPT_RETURNTRANSFER, .T.)
CURL_EASY_SETOPT(cURL, HB_CURLOPT_ENCODING, "")
CURL_EASY_SETOPT(cURL, HB_CURLOPT_MAXREDIRS, 10)
CURL_EASY_SETOPT(cURL, HB_CURLOPT_TIMEOUT, 0)
CURL_EASY_SETOPT(cURL, HB_CURLOPT_FOLLOWLOCATION, .T.)
CURL_EASY_SETOPT(cURL, HB_CURLOPT_HTTP_VERSION, "CURL_HTTP_VERSION_1_1")
CURL_EASY_SETOPT(cURL, HB_CURLOPT_POSTFIELDS, {"grant_type","client_credentials"})
CURL_EASY_SETOPT(cURL, HB_CURLOPT_POSTFIELDS, {'"items": [{"name": "item","value": 500,"amount": 1}]'})
CURL_EASY_SETOPT(cURL, HB_CURLOPT_HTTPHEADER, {'Authorization: [{"Client_Id_1c055bbc11805306ad56442e71f4f6b771536fc2","Client_Secret_2884bd0e7ef116a1cfaeca5624b1725394644608"}]'})
CURL_EASY_SETOPT(cURL, HB_CURLOPT_HTTPHEADER, {'Content-Type: application/json'})
nCURLERR := CURL_EASY_PERFORM(cURL)
IF ncurlErr > 0
? "Curl Error: "+str(ncurlErr)
ELSE
? "PASSOU"
ENDIF
ENDIF
CURL_EASY_CLEANUP( cURL )
RETURN NIL
Quando executo teste que fiz, retorna o erro 60
Este erro está relacionado ao cURL configurado em seu servidor (ou computador) estar exigindo um certificado (https/ssl) local
Sei que é possÃvel também executar o codigo C direto, mas não faço idéia de como.
Agradeço desde já a atenção e ajuda