Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL cUrl
LOCAL cResponseStr
LOCAL oJsonResp
LOCAL cCountry
LOCAL cGsacard
LOCAL cAddress
LOCAL cCity
LOCAL cAcctid
LOCAL cDefaultacct
LOCAL cAccttype
LOCAL cToken
LOCAL cLicense
LOCAL cPhone
LOCAL cProfileid
LOCAL cName
LOCAL cAuoptout
LOCAL cPostal
LOCAL cExpiry
LOCAL cRegion
LOCAL cSsnl4
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
oHttp:BasicAuth := 1
oHttp:Login := "API_USERNAME"
oHttp:Password := "API_PASSWORD"
cUrl := "https://<site>.cardconnect.com:<port>/cardconnect/rest/profile/<profile ID>/<account ID>/<merchid>"
cResponseStr := oHttp:QuickGetStr(cUrl)
IF (oHttp:LastMethodSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
RETURN
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.
? "response status code = " + Str(oHttp:LastStatus)
oJsonResp := CreateObject("Chilkat.JsonObject")
oJsonResp:Load(cResponseStr)
oJsonResp:EmitCompact := 0
? "response JSON:"
? oJsonResp:Emit()
// 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
cCountry := oJsonResp:StringOf("country")
cGsacard := oJsonResp:StringOf("gsacard")
cAddress := oJsonResp:StringOf("address")
cCity := oJsonResp:StringOf("city")
cAcctid := oJsonResp:StringOf("acctid")
cDefaultacct := oJsonResp:StringOf("defaultacct")
cAccttype := oJsonResp:StringOf("accttype")
cToken := oJsonResp:StringOf("token")
cLicense := oJsonResp:StringOf("license")
cPhone := oJsonResp:StringOf("phone")
cProfileid := oJsonResp:StringOf("profileid")
cName := oJsonResp:StringOf("name")
cAuoptout := oJsonResp:StringOf("auoptout")
cPostal := oJsonResp:StringOf("postal")
cExpiry := oJsonResp:StringOf("expiry")
cRegion := oJsonResp:StringOf("region")
cSsnl4 := oJsonResp:StringOf("ssnl4")
oHttp:destroy()
oJsonResp:destroy()