Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
CkHttp_put_BasicAuth $http 1
CkHttp_put_Login $http "API_USERNAME"
CkHttp_put_Password $http "API_PASSWORD"
set url "https://<site>.cardconnect.com:<port>/cardconnect/rest/profile/<profile ID>/<account ID>/<merchid>"
set responseStr [CkHttp_quickGetStr $http $url]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
exit
}
# 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.
puts "response status code = [CkHttp_get_LastStatus $http]"
set jsonResp [new_CkJsonObject]
CkJsonObject_Load $jsonResp $responseStr
CkJsonObject_put_EmitCompact $jsonResp 0
puts "response JSON:"
puts [CkJsonObject_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
set country [CkJsonObject_stringOf $jsonResp "country"]
set gsacard [CkJsonObject_stringOf $jsonResp "gsacard"]
set address [CkJsonObject_stringOf $jsonResp "address"]
set city [CkJsonObject_stringOf $jsonResp "city"]
set acctid [CkJsonObject_stringOf $jsonResp "acctid"]
set defaultacct [CkJsonObject_stringOf $jsonResp "defaultacct"]
set accttype [CkJsonObject_stringOf $jsonResp "accttype"]
set token [CkJsonObject_stringOf $jsonResp "token"]
set license [CkJsonObject_stringOf $jsonResp "license"]
set phone [CkJsonObject_stringOf $jsonResp "phone"]
set profileid [CkJsonObject_stringOf $jsonResp "profileid"]
set name [CkJsonObject_stringOf $jsonResp "name"]
set auoptout [CkJsonObject_stringOf $jsonResp "auoptout"]
set postal [CkJsonObject_stringOf $jsonResp "postal"]
set expiry [CkJsonObject_stringOf $jsonResp "expiry"]
set region [CkJsonObject_stringOf $jsonResp "region"]
set ssnl4 [CkJsonObject_stringOf $jsonResp "ssnl4"]
delete_CkHttp $http
delete_CkJsonObject $jsonResp