Sample code for 30+ languages & platforms
Unicode C++

CardConnect Inquire

See more CardConnect Examples

Demonstrates how to get information for an individual transaction, including its settlement status (setlstat) and the response codes from the initial authorization.

See https://developer.cardconnect.com/cardconnect-api?lang=json#inquire

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkHttpW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    bool success = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;

    http.put_BasicAuth(true);
    http.put_Login(L"API_USERNAME");
    http.put_Password(L"API_PASSWORD");

    const wchar_t *url = L"https://<site>.cardconnect.com:<port>/cardconnect/rest/inquire/<retref>/<merchid>";
    const wchar_t *responseStr = http.quickGetStr(url);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    // A response status of 200 indicates potential success.  The JSON response body
    // must be examined to determine if it was truly successful or an error.
    wprintf(L"response status code = %d\n",http.get_LastStatus());

    CkJsonObjectW jsonResp;
    jsonResp.Load(responseStr);
    jsonResp.put_EmitCompact(false);

    wprintf(L"response JSON:\n");
    wprintf(L"%s\n",jsonResp.emit());

    // A successful response looks like this:

    // {
    //   "amount": "0.00",
    //   "resptext": "Approval",
    //   "setlstat": "Voided",
    //   "capturedate": "20190422180044",
    //   "acctid": "1",
    //   "respcode": "00",
    //   "entrymode": "ECommerce",
    //   "merchid": "MERCHANT_ID",
    //   "token": "9418594164541111",
    //   "authcode": "PPS158",
    //   "respproc": "FNOR",
    //   "authdate": "20190422",
    //   "bintype": "",
    //   "profileid": "16618402968441604028",
    //   "lastfour": "1111",
    //   "name": "TOM JONES",
    //   "currency": "USD",
    //   "retref": "112989260941",
    //   "respstat": "A",
    //   "account": "9418594164541111"
    // }

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    const wchar_t *amount = jsonResp.stringOf(L"amount");
    const wchar_t *resptext = jsonResp.stringOf(L"resptext");
    const wchar_t *setlstat = jsonResp.stringOf(L"setlstat");
    const wchar_t *capturedate = jsonResp.stringOf(L"capturedate");
    const wchar_t *acctid = jsonResp.stringOf(L"acctid");
    const wchar_t *respcode = jsonResp.stringOf(L"respcode");
    const wchar_t *entrymode = jsonResp.stringOf(L"entrymode");
    const wchar_t *merchid = jsonResp.stringOf(L"merchid");
    const wchar_t *token = jsonResp.stringOf(L"token");
    const wchar_t *authcode = jsonResp.stringOf(L"authcode");
    const wchar_t *respproc = jsonResp.stringOf(L"respproc");
    const wchar_t *authdate = jsonResp.stringOf(L"authdate");
    const wchar_t *bintype = jsonResp.stringOf(L"bintype");
    const wchar_t *profileid = jsonResp.stringOf(L"profileid");
    const wchar_t *lastfour = jsonResp.stringOf(L"lastfour");
    const wchar_t *name = jsonResp.stringOf(L"name");
    const wchar_t *currency = jsonResp.stringOf(L"currency");
    const wchar_t *retref = jsonResp.stringOf(L"retref");
    const wchar_t *respstat = jsonResp.stringOf(L"respstat");
    const wchar_t *account = jsonResp.stringOf(L"account");
    }