Sample code for 30+ languages & platforms
Lua

CardConnect Funding

See more CardConnect Examples

Demonstrates how to get the merchant funding information.
The funding endpoint provides merchant funding information supported by supplemental transaction and funding adjustment detail. This information is provided by the host payment processing platform (for example, First Data Omaha). ...

See https://developer.cardconnect.com/cardconnect-api?lang=json#funding

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/funding?merchid=<merchid>&date=<MMDD>"
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:

-- ------
-- See the parsing code below...
-- ------

-- {
--   "fundingmasterid": 1121753252164835,
--   "fundingdate": "2019-04-22",
--   "adjustments": [
--     {
--       "fundingmasterid": 1121753252164835,
--       "amount": "-44.98",
--       "datechanged": "2019-04-22",
--       "fundingadjustmentid": 1121754400164838,
--       "description": "THE CARDHOLDER DID NOT AUTHORIZE THE CHARGE.",
--       "currency": "USD",
--       "category": "REVERSAL",
--       "type": "CHARGEBACKS/CHARGEBACK REVERSALS",
--       "dateadded": "2019-04-22",
--       "merchid": "MERCHANT_ID"
--     },
--     {
--       "fundingmasterid": 1121753252164835,
--       "amount": "-32.96",
--       "datechanged": "2019-04-22",
--       "fundingadjustmentid": 1121754401164838,
--       "description": "THIRD PARTY ADJUSTMENTS",
--       "currency": "USD",
--       "category": "THIRD PARTY",
--       "type": "THIRD PARTY ADJUSTMENTS",
--       "dateadded": "2019-04-22",
--       "merchid": "MERCHANT_ID"
--     }
--   ],
--   "datechanged": null,
--   "fundings": [
--     {
--       "fundingid": 1121753284164836,
--       "netsales": "129453.03",
--       "totalfunding": "129375.09",
--       "fee": "0",
--       "datechanged": "2019-04-22",
--       "deposittrancode": null,
--       "ddanumber": "3300770540",
--       "thirdparty": "-32.96",
--       "dateadded": "2019-04-22",
--       "fundingmasterid": 1121753252164835,
--       "reversal": "-44.98",
--       "interchangefee": "0",
--       "adjustment": "0",
--       "currency": "USD",
--       "depositachtracenumber": null,
--       "servicecharge": "0",
--       "otheradjustment": "0",
--       "abanumber": "121140399"
--     }
--   ],
--   "merchid": "MERCHANT_ID",
--   "txns": [
--     {
--       "date": "2019-04-19",
--       "amount": "76.75",
--       "downgradereasoncodes": null,
--       "fundingid": 1121753409164836,
--       "cardproc": "FNOR",
--       "sourcetransactionid": null,
--       "type": "SALE",
--       "batchid": 1900942289,
--       "respcode": "00",
--       "interchangeunitfee": "0",
--       "authcode": "PPS209",
--       "plancode": null,
--       "authdate": 20190419194808,
--       "fundingtxnid": 1121753252164835,
--       "cardbrand": "VISA",
--       "currency": "USD",
--       "terminalnumber": null,
--       "cardnumber": "42XXXXXXXXXX4242",
--       "cardtype": "Credit",
--       "retref": "109624271288",
--       "status": "Processed",
--       "interchangepercentfee": "0",
--       "invoicenumber": null
--     },
--     {
--       "date": "2019-04-19",
--       "amount": "9.99",
--       "downgradereasoncodes": null,
--       "fundingid": 1121753410164836,
--       "cardproc": "FNOR",
--       "sourcetransactionid": null,
--       "type": "SALE",
--       "batchid": 1900942289,
--       "respcode": "00",
--       "interchangeunitfee": "0",
--       "authcode": "PPS009",
--       "plancode": null,
--       "authdate": 20190419201502,
--       "fundingtxnid": 1121753252164835,
--       "cardbrand": "VISA",
--       "currency": "USD",
--       "terminalnumber": null,
--       "cardnumber": "47XXXXXXXXXX1443",
--       "cardtype": "Credit",
--       "retref": "109638272902",
--       "status": "Processed",
--       "interchangepercentfee": "0",
--       "invoicenumber": null
--     }
--   ]
-- }
--

-- Use this online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON

local amount = ""
local fundingadjustmentid = 0
local description = ""
local currency = ""
local category = ""
local v_type = ""
local dateadded = ""
local fundingid = 0
local netsales = ""
local totalfunding = ""
local fee = ""
local deposittrancode = ""
local ddanumber = ""
local thirdparty = ""
local reversal = ""
local interchangefee = ""
local adjustment = ""
local depositachtracenumber = ""
local servicecharge = ""
local otheradjustment = ""
local abanumber = ""
local date = ""
local downgradereasoncodes = ""
local cardproc = ""
local sourcetransactionid = ""
local batchid = 0
local respcode = ""
local interchangeunitfee = ""
local authcode = ""
local plancode = ""
local authdate = 0
local fundingtxnid = 0
local cardbrand = ""
local terminalnumber = ""
local cardnumber = ""
local cardtype = ""
local retref = ""
local status = ""
local interchangepercentfee = ""
local invoicenumber = ""

local fundingmasterid = jsonResp:int_of("fundingmasterid")
local fundingdate = jsonResp:string_of("fundingdate")
local datechanged = jsonResp:string_of("datechanged")
local merchid = jsonResp:string_of("merchid")
local i = 0
local count_i = jsonResp:size_of_array("adjustments")
while i < count_i do
    jsonResp.i = i
    fundingmasterid = jsonResp:int_of("adjustments[i].fundingmasterid")
    amount = jsonResp:string_of("adjustments[i].amount")
    datechanged = jsonResp:string_of("adjustments[i].datechanged")
    fundingadjustmentid = jsonResp:int_of("adjustments[i].fundingadjustmentid")
    description = jsonResp:string_of("adjustments[i].description")
    currency = jsonResp:string_of("adjustments[i].currency")
    category = jsonResp:string_of("adjustments[i].category")
    v_type = jsonResp:string_of("adjustments[i].type")
    dateadded = jsonResp:string_of("adjustments[i].dateadded")
    merchid = jsonResp:string_of("adjustments[i].merchid")
    i = i + 1
end

i = 0
count_i = jsonResp:size_of_array("fundings")
while i < count_i do
    jsonResp.i = i
    fundingid = jsonResp:int_of("fundings[i].fundingid")
    netsales = jsonResp:string_of("fundings[i].netsales")
    totalfunding = jsonResp:string_of("fundings[i].totalfunding")
    fee = jsonResp:string_of("fundings[i].fee")
    datechanged = jsonResp:string_of("fundings[i].datechanged")
    deposittrancode = jsonResp:string_of("fundings[i].deposittrancode")
    ddanumber = jsonResp:string_of("fundings[i].ddanumber")
    thirdparty = jsonResp:string_of("fundings[i].thirdparty")
    dateadded = jsonResp:string_of("fundings[i].dateadded")
    fundingmasterid = jsonResp:int_of("fundings[i].fundingmasterid")
    reversal = jsonResp:string_of("fundings[i].reversal")
    interchangefee = jsonResp:string_of("fundings[i].interchangefee")
    adjustment = jsonResp:string_of("fundings[i].adjustment")
    currency = jsonResp:string_of("fundings[i].currency")
    depositachtracenumber = jsonResp:string_of("fundings[i].depositachtracenumber")
    servicecharge = jsonResp:string_of("fundings[i].servicecharge")
    otheradjustment = jsonResp:string_of("fundings[i].otheradjustment")
    abanumber = jsonResp:string_of("fundings[i].abanumber")
    i = i + 1
end

i = 0
count_i = jsonResp:size_of_array("txns")
while i < count_i do
    jsonResp.i = i
    date = jsonResp:string_of("txns[i].date")
    amount = jsonResp:string_of("txns[i].amount")
    downgradereasoncodes = jsonResp:string_of("txns[i].downgradereasoncodes")
    fundingid = jsonResp:int_of("txns[i].fundingid")
    cardproc = jsonResp:string_of("txns[i].cardproc")
    sourcetransactionid = jsonResp:string_of("txns[i].sourcetransactionid")
    v_type = jsonResp:string_of("txns[i].type")
    batchid = jsonResp:int_of("txns[i].batchid")
    respcode = jsonResp:string_of("txns[i].respcode")
    interchangeunitfee = jsonResp:string_of("txns[i].interchangeunitfee")
    authcode = jsonResp:string_of("txns[i].authcode")
    plancode = jsonResp:string_of("txns[i].plancode")
    authdate = jsonResp:int_of("txns[i].authdate")
    fundingtxnid = jsonResp:int_of("txns[i].fundingtxnid")
    cardbrand = jsonResp:string_of("txns[i].cardbrand")
    currency = jsonResp:string_of("txns[i].currency")
    terminalnumber = jsonResp:string_of("txns[i].terminalnumber")
    cardnumber = jsonResp:string_of("txns[i].cardnumber")
    cardtype = jsonResp:string_of("txns[i].cardtype")
    retref = jsonResp:string_of("txns[i].retref")
    status = jsonResp:string_of("txns[i].status")
    interchangepercentfee = jsonResp:string_of("txns[i].interchangepercentfee")
    invoicenumber = jsonResp:string_of("txns[i].invoicenumber")
    i = i + 1
end