Unicode C
Unicode C
CardConnect Get Profile
See more CardConnect Examples
Demonstrates how to get a profile.A GET request to the profile endpoint returns the stored data for the specified profile ID. ...
See https://developer.cardconnect.com/cardconnect-api?lang=json#get-profile-request
Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
const wchar_t *url;
const wchar_t *responseStr;
HCkJsonObjectW jsonResp;
const wchar_t *country;
const wchar_t *gsacard;
const wchar_t *address;
const wchar_t *city;
const wchar_t *acctid;
const wchar_t *defaultacct;
const wchar_t *accttype;
const wchar_t *token;
const wchar_t *license;
const wchar_t *phone;
const wchar_t *profileid;
const wchar_t *name;
const wchar_t *auoptout;
const wchar_t *postal;
const wchar_t *expiry;
const wchar_t *region;
const wchar_t *ssnl4;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
CkHttpW_putBasicAuth(http,TRUE);
CkHttpW_putLogin(http,L"API_USERNAME");
CkHttpW_putPassword(http,L"API_PASSWORD");
url = L"https://<site>.cardconnect.com:<port>/cardconnect/rest/profile/<profile ID>/<account ID>/<merchid>";
responseStr = CkHttpW_quickGetStr(http,url);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
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",CkHttpW_getLastStatus(http));
jsonResp = CkJsonObjectW_Create();
CkJsonObjectW_Load(jsonResp,responseStr);
CkJsonObjectW_putEmitCompact(jsonResp,FALSE);
wprintf(L"response JSON:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jsonResp));
// A successful response looks like this:
// {
// "country": "US",
// "gsacard": "N",
// "address": "123 MAIN STREET",
// "city": "ANYTOWN",
// "acctid": "1",
// "defaultacct": "Y",
// "accttype": "VISA",
// "token": "9441149619831111",
// "license": "123451254",
// "phone": "7778789999",
// "profileid": "16392957457306633141",
// "name": "TOM JONES",
// "auoptout": "N",
// "postal": "19090",
// "expiry": "0214",
// "region": "AK",
// "ssnl4": "3655"
// }
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
country = CkJsonObjectW_stringOf(jsonResp,L"country");
gsacard = CkJsonObjectW_stringOf(jsonResp,L"gsacard");
address = CkJsonObjectW_stringOf(jsonResp,L"address");
city = CkJsonObjectW_stringOf(jsonResp,L"city");
acctid = CkJsonObjectW_stringOf(jsonResp,L"acctid");
defaultacct = CkJsonObjectW_stringOf(jsonResp,L"defaultacct");
accttype = CkJsonObjectW_stringOf(jsonResp,L"accttype");
token = CkJsonObjectW_stringOf(jsonResp,L"token");
license = CkJsonObjectW_stringOf(jsonResp,L"license");
phone = CkJsonObjectW_stringOf(jsonResp,L"phone");
profileid = CkJsonObjectW_stringOf(jsonResp,L"profileid");
name = CkJsonObjectW_stringOf(jsonResp,L"name");
auoptout = CkJsonObjectW_stringOf(jsonResp,L"auoptout");
postal = CkJsonObjectW_stringOf(jsonResp,L"postal");
expiry = CkJsonObjectW_stringOf(jsonResp,L"expiry");
region = CkJsonObjectW_stringOf(jsonResp,L"region");
ssnl4 = CkJsonObjectW_stringOf(jsonResp,L"ssnl4");
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(jsonResp);
}