Sample code for 30+ languages & platforms
PureBasic

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

PureBasic
IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    success.i = 0

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkHttp::setCkBasicAuth(http, 1)
    CkHttp::setCkLogin(http, "API_USERNAME")
    CkHttp::setCkPassword(http, "API_PASSWORD")

    url.s = "https://<site>.cardconnect.com:<port>/cardconnect/rest/funding?merchid=<merchid>&date=<MMDD>"
    responseStr.s = CkHttp::ckQuickGetStr(http,url)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        ProcedureReturn
    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.
    Debug "response status code = " + Str(CkHttp::ckLastStatus(http))

    jsonResp.i = CkJsonObject::ckCreate()
    If jsonResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoad(jsonResp,responseStr)
    CkJsonObject::setCkEmitCompact(jsonResp, 0)

    Debug "response JSON:"
    Debug CkJsonObject::ckEmit(jsonResp)

    ; 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

    fundingmasterid.i
    fundingdate.s
    datechanged.s
    merchid.s
    i.i
    count_i.i
    amount.s
    fundingadjustmentid.i
    description.s
    currency.s
    category.s
    v_type.s
    dateadded.s
    fundingid.i
    netsales.s
    totalfunding.s
    fee.s
    deposittrancode.s
    ddanumber.s
    thirdparty.s
    reversal.s
    interchangefee.s
    adjustment.s
    depositachtracenumber.s
    servicecharge.s
    otheradjustment.s
    abanumber.s
    date.s
    downgradereasoncodes.s
    cardproc.s
    sourcetransactionid.s
    batchid.i
    respcode.s
    interchangeunitfee.s
    authcode.s
    plancode.s
    authdate.i
    fundingtxnid.i
    cardbrand.s
    terminalnumber.s
    cardnumber.s
    cardtype.s
    retref.s
    status.s
    interchangepercentfee.s
    invoicenumber.s

    fundingmasterid = CkJsonObject::ckIntOf(jsonResp,"fundingmasterid")
    fundingdate = CkJsonObject::ckStringOf(jsonResp,"fundingdate")
    datechanged = CkJsonObject::ckStringOf(jsonResp,"datechanged")
    merchid = CkJsonObject::ckStringOf(jsonResp,"merchid")
    i = 0
    count_i = CkJsonObject::ckSizeOfArray(jsonResp,"adjustments")
    While i < count_i
        CkJsonObject::setCkI(jsonResp, i)
        fundingmasterid = CkJsonObject::ckIntOf(jsonResp,"adjustments[i].fundingmasterid")
        amount = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].amount")
        datechanged = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].datechanged")
        fundingadjustmentid = CkJsonObject::ckIntOf(jsonResp,"adjustments[i].fundingadjustmentid")
        description = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].description")
        currency = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].currency")
        category = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].category")
        v_type = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].type")
        dateadded = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].dateadded")
        merchid = CkJsonObject::ckStringOf(jsonResp,"adjustments[i].merchid")
        i = i + 1
    Wend
    i = 0
    count_i = CkJsonObject::ckSizeOfArray(jsonResp,"fundings")
    While i < count_i
        CkJsonObject::setCkI(jsonResp, i)
        fundingid = CkJsonObject::ckIntOf(jsonResp,"fundings[i].fundingid")
        netsales = CkJsonObject::ckStringOf(jsonResp,"fundings[i].netsales")
        totalfunding = CkJsonObject::ckStringOf(jsonResp,"fundings[i].totalfunding")
        fee = CkJsonObject::ckStringOf(jsonResp,"fundings[i].fee")
        datechanged = CkJsonObject::ckStringOf(jsonResp,"fundings[i].datechanged")
        deposittrancode = CkJsonObject::ckStringOf(jsonResp,"fundings[i].deposittrancode")
        ddanumber = CkJsonObject::ckStringOf(jsonResp,"fundings[i].ddanumber")
        thirdparty = CkJsonObject::ckStringOf(jsonResp,"fundings[i].thirdparty")
        dateadded = CkJsonObject::ckStringOf(jsonResp,"fundings[i].dateadded")
        fundingmasterid = CkJsonObject::ckIntOf(jsonResp,"fundings[i].fundingmasterid")
        reversal = CkJsonObject::ckStringOf(jsonResp,"fundings[i].reversal")
        interchangefee = CkJsonObject::ckStringOf(jsonResp,"fundings[i].interchangefee")
        adjustment = CkJsonObject::ckStringOf(jsonResp,"fundings[i].adjustment")
        currency = CkJsonObject::ckStringOf(jsonResp,"fundings[i].currency")
        depositachtracenumber = CkJsonObject::ckStringOf(jsonResp,"fundings[i].depositachtracenumber")
        servicecharge = CkJsonObject::ckStringOf(jsonResp,"fundings[i].servicecharge")
        otheradjustment = CkJsonObject::ckStringOf(jsonResp,"fundings[i].otheradjustment")
        abanumber = CkJsonObject::ckStringOf(jsonResp,"fundings[i].abanumber")
        i = i + 1
    Wend
    i = 0
    count_i = CkJsonObject::ckSizeOfArray(jsonResp,"txns")
    While i < count_i
        CkJsonObject::setCkI(jsonResp, i)
        date = CkJsonObject::ckStringOf(jsonResp,"txns[i].date")
        amount = CkJsonObject::ckStringOf(jsonResp,"txns[i].amount")
        downgradereasoncodes = CkJsonObject::ckStringOf(jsonResp,"txns[i].downgradereasoncodes")
        fundingid = CkJsonObject::ckIntOf(jsonResp,"txns[i].fundingid")
        cardproc = CkJsonObject::ckStringOf(jsonResp,"txns[i].cardproc")
        sourcetransactionid = CkJsonObject::ckStringOf(jsonResp,"txns[i].sourcetransactionid")
        v_type = CkJsonObject::ckStringOf(jsonResp,"txns[i].type")
        batchid = CkJsonObject::ckIntOf(jsonResp,"txns[i].batchid")
        respcode = CkJsonObject::ckStringOf(jsonResp,"txns[i].respcode")
        interchangeunitfee = CkJsonObject::ckStringOf(jsonResp,"txns[i].interchangeunitfee")
        authcode = CkJsonObject::ckStringOf(jsonResp,"txns[i].authcode")
        plancode = CkJsonObject::ckStringOf(jsonResp,"txns[i].plancode")
        authdate = CkJsonObject::ckIntOf(jsonResp,"txns[i].authdate")
        fundingtxnid = CkJsonObject::ckIntOf(jsonResp,"txns[i].fundingtxnid")
        cardbrand = CkJsonObject::ckStringOf(jsonResp,"txns[i].cardbrand")
        currency = CkJsonObject::ckStringOf(jsonResp,"txns[i].currency")
        terminalnumber = CkJsonObject::ckStringOf(jsonResp,"txns[i].terminalnumber")
        cardnumber = CkJsonObject::ckStringOf(jsonResp,"txns[i].cardnumber")
        cardtype = CkJsonObject::ckStringOf(jsonResp,"txns[i].cardtype")
        retref = CkJsonObject::ckStringOf(jsonResp,"txns[i].retref")
        status = CkJsonObject::ckStringOf(jsonResp,"txns[i].status")
        interchangepercentfee = CkJsonObject::ckStringOf(jsonResp,"txns[i].interchangepercentfee")
        invoicenumber = CkJsonObject::ckStringOf(jsonResp,"txns[i].invoicenumber")
        i = i + 1
    Wend


    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(jsonResp)


    ProcedureReturn
EndProcedure