Sample code for 30+ languages & platforms
Lua

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

Lua
local chilkat = require("chilkat")

local success = false

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

local http = chilkat.Http.new()

http.basic_auth = true
http.login = "API_USERNAME"
http.password = "API_PASSWORD"

local url = "https://<site>.cardconnect.com:<port>/cardconnect/rest/inquire/<retref>/<merchid>"
local responseStr = http:quick_get_str(url)
if not http.last_method_success then
    print(http.last_error_text)
    return
end

-- 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.
print("response status code = " .. http.last_status)

local jsonResp = chilkat.JsonObject.new()
jsonResp:load(responseStr)
jsonResp.emit_compact = false

print("response JSON:")
print(jsonResp: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

local amount = jsonResp:string_of("amount")
local resptext = jsonResp:string_of("resptext")
local setlstat = jsonResp:string_of("setlstat")
local capturedate = jsonResp:string_of("capturedate")
local acctid = jsonResp:string_of("acctid")
local respcode = jsonResp:string_of("respcode")
local entrymode = jsonResp:string_of("entrymode")
local merchid = jsonResp:string_of("merchid")
local token = jsonResp:string_of("token")
local authcode = jsonResp:string_of("authcode")
local respproc = jsonResp:string_of("respproc")
local authdate = jsonResp:string_of("authdate")
local bintype = jsonResp:string_of("bintype")
local profileid = jsonResp:string_of("profileid")
local lastfour = jsonResp:string_of("lastfour")
local name = jsonResp:string_of("name")
local currency = jsonResp:string_of("currency")
local retref = jsonResp:string_of("retref")
local respstat = jsonResp:string_of("respstat")
local account = jsonResp:string_of("account")