Sample code for 30+ languages & platforms
PureBasic

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 PureBasic Downloads

PureBasic
IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    success.i = 0

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkHttp::setCkBasicAuth(http, 1)
    CkHttp::setCkLogin(http, "API_USERNAME")
    CkHttp::setCkPassword(http, "API_PASSWORD")

    url.s = "https://<site>.cardconnect.com:<port>/cardconnect/rest/profile/<profile ID>/<account ID>/<merchid>"
    responseStr.s = CkHttp::ckQuickGetStr(http,url)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        ProcedureReturn
    EndIf

    ; 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.
    Debug "response status code = " + Str(CkHttp::ckLastStatus(http))

    jsonResp.i = CkJsonObject::ckCreate()
    If jsonResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoad(jsonResp,responseStr)
    CkJsonObject::setCkEmitCompact(jsonResp, 0)

    Debug "response JSON:"
    Debug CkJsonObject::ckEmit(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.s = CkJsonObject::ckStringOf(jsonResp,"country")
    gsacard.s = CkJsonObject::ckStringOf(jsonResp,"gsacard")
    address.s = CkJsonObject::ckStringOf(jsonResp,"address")
    city.s = CkJsonObject::ckStringOf(jsonResp,"city")
    acctid.s = CkJsonObject::ckStringOf(jsonResp,"acctid")
    defaultacct.s = CkJsonObject::ckStringOf(jsonResp,"defaultacct")
    accttype.s = CkJsonObject::ckStringOf(jsonResp,"accttype")
    token.s = CkJsonObject::ckStringOf(jsonResp,"token")
    license.s = CkJsonObject::ckStringOf(jsonResp,"license")
    phone.s = CkJsonObject::ckStringOf(jsonResp,"phone")
    profileid.s = CkJsonObject::ckStringOf(jsonResp,"profileid")
    name.s = CkJsonObject::ckStringOf(jsonResp,"name")
    auoptout.s = CkJsonObject::ckStringOf(jsonResp,"auoptout")
    postal.s = CkJsonObject::ckStringOf(jsonResp,"postal")
    expiry.s = CkJsonObject::ckStringOf(jsonResp,"expiry")
    region.s = CkJsonObject::ckStringOf(jsonResp,"region")
    ssnl4.s = CkJsonObject::ckStringOf(jsonResp,"ssnl4")


    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(jsonResp)


    ProcedureReturn
EndProcedure