Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL cUrl
LOCAL cResponseStr
LOCAL oJsonResp
LOCAL cAmount
LOCAL cResptext
LOCAL cSetlstat
LOCAL cCapturedate
LOCAL cAcctid
LOCAL cRespcode
LOCAL cEntrymode
LOCAL cMerchid
LOCAL cToken
LOCAL cAuthcode
LOCAL cRespproc
LOCAL cAuthdate
LOCAL cBintype
LOCAL cProfileid
LOCAL cLastfour
LOCAL cName
LOCAL cCurrency
LOCAL cRetref
LOCAL cRespstat
LOCAL cAccount

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/inquire/<retref>/<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:

//  {
//    "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

cAmount := oJsonResp:StringOf("amount")
cResptext := oJsonResp:StringOf("resptext")
cSetlstat := oJsonResp:StringOf("setlstat")
cCapturedate := oJsonResp:StringOf("capturedate")
cAcctid := oJsonResp:StringOf("acctid")
cRespcode := oJsonResp:StringOf("respcode")
cEntrymode := oJsonResp:StringOf("entrymode")
cMerchid := oJsonResp:StringOf("merchid")
cToken := oJsonResp:StringOf("token")
cAuthcode := oJsonResp:StringOf("authcode")
cRespproc := oJsonResp:StringOf("respproc")
cAuthdate := oJsonResp:StringOf("authdate")
cBintype := oJsonResp:StringOf("bintype")
cProfileid := oJsonResp:StringOf("profileid")
cLastfour := oJsonResp:StringOf("lastfour")
cName := oJsonResp:StringOf("name")
cCurrency := oJsonResp:StringOf("currency")
cRetref := oJsonResp:StringOf("retref")
cRespstat := oJsonResp:StringOf("respstat")
cAccount := oJsonResp:StringOf("account")

oHttp:destroy()
oJsonResp:destroy()