Sample code for 30+ languages & platforms
Zig

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

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

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

    const http = try chilkat.Http.init();
    defer http.deinit();

    http.setBasicAuth(true);
    http.setLogin("API_USERNAME");
    http.setPassword("API_PASSWORD");

    const url = "https://<site>.cardconnect.com:<port>/cardconnect/rest/funding?merchid=<merchid>&date=<MMDD>";
    const response_str = http.quickGetStr(alloc, url) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    // 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.
    std.debug.print("response status code = {d}\n", .{http.getLastStatus()});

    const json_resp = try chilkat.JsonObject.init();
    defer json_resp.deinit();
    json_resp.load(response_str) catch {};
    json_resp.setEmitCompact(false);

    std.debug.print("response JSON:\n", .{});
    std.debug.print("{s}\n", .{try json_resp.emit(alloc)});

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

    var fundingmasterid: i32 = 0;
    var datechanged: [:0]const u8 = "";
    var merchid: [:0]const u8 = "";
    var i: i32 = 0;
    var count_i: i32 = 0;
    var amount: [:0]const u8 = "";
    var fundingadjustmentid: i32 = 0;
    var description: [:0]const u8 = "";
    var currency: [:0]const u8 = "";
    var category: [:0]const u8 = "";
    var v_type: [:0]const u8 = "";
    var dateadded: [:0]const u8 = "";
    var fundingid: i32 = 0;
    var netsales: [:0]const u8 = "";
    var totalfunding: [:0]const u8 = "";
    var fee: [:0]const u8 = "";
    var deposittrancode: [:0]const u8 = "";
    var ddanumber: [:0]const u8 = "";
    var thirdparty: [:0]const u8 = "";
    var reversal: [:0]const u8 = "";
    var interchangefee: [:0]const u8 = "";
    var adjustment: [:0]const u8 = "";
    var depositachtracenumber: [:0]const u8 = "";
    var servicecharge: [:0]const u8 = "";
    var otheradjustment: [:0]const u8 = "";
    var abanumber: [:0]const u8 = "";
    var date: [:0]const u8 = "";
    var downgradereasoncodes: [:0]const u8 = "";
    var cardproc: [:0]const u8 = "";
    var sourcetransactionid: [:0]const u8 = "";
    var batchid: i32 = 0;
    var respcode: [:0]const u8 = "";
    var interchangeunitfee: [:0]const u8 = "";
    var authcode: [:0]const u8 = "";
    var plancode: [:0]const u8 = "";
    var authdate: i32 = 0;
    var fundingtxnid: i32 = 0;
    var cardbrand: [:0]const u8 = "";
    var terminalnumber: [:0]const u8 = "";
    var cardnumber: [:0]const u8 = "";
    var cardtype: [:0]const u8 = "";
    var retref: [:0]const u8 = "";
    var status: [:0]const u8 = "";
    var interchangepercentfee: [:0]const u8 = "";
    var invoicenumber: [:0]const u8 = "";

    fundingmasterid = json_resp.intOf("fundingmasterid");
    _ = try json_resp.stringOf(alloc, "fundingdate");
    datechanged = try json_resp.stringOf(alloc, "datechanged");
    merchid = try json_resp.stringOf(alloc, "merchid");
    i = 0;
    count_i = json_resp.sizeOfArray("adjustments");
    while (i < count_i) {
        json_resp.setI(i);
        fundingmasterid = json_resp.intOf("adjustments[i].fundingmasterid");
        amount = try json_resp.stringOf(alloc, "adjustments[i].amount");
        datechanged = try json_resp.stringOf(alloc, "adjustments[i].datechanged");
        fundingadjustmentid = json_resp.intOf("adjustments[i].fundingadjustmentid");
        description = try json_resp.stringOf(alloc, "adjustments[i].description");
        currency = try json_resp.stringOf(alloc, "adjustments[i].currency");
        category = try json_resp.stringOf(alloc, "adjustments[i].category");
        v_type = try json_resp.stringOf(alloc, "adjustments[i].type");
        dateadded = try json_resp.stringOf(alloc, "adjustments[i].dateadded");
        merchid = try json_resp.stringOf(alloc, "adjustments[i].merchid");
        i = i + 1;
    }

    i = 0;
    count_i = json_resp.sizeOfArray("fundings");
    while (i < count_i) {
        json_resp.setI(i);
        fundingid = json_resp.intOf("fundings[i].fundingid");
        netsales = try json_resp.stringOf(alloc, "fundings[i].netsales");
        totalfunding = try json_resp.stringOf(alloc, "fundings[i].totalfunding");
        fee = try json_resp.stringOf(alloc, "fundings[i].fee");
        datechanged = try json_resp.stringOf(alloc, "fundings[i].datechanged");
        deposittrancode = try json_resp.stringOf(alloc, "fundings[i].deposittrancode");
        ddanumber = try json_resp.stringOf(alloc, "fundings[i].ddanumber");
        thirdparty = try json_resp.stringOf(alloc, "fundings[i].thirdparty");
        dateadded = try json_resp.stringOf(alloc, "fundings[i].dateadded");
        fundingmasterid = json_resp.intOf("fundings[i].fundingmasterid");
        reversal = try json_resp.stringOf(alloc, "fundings[i].reversal");
        interchangefee = try json_resp.stringOf(alloc, "fundings[i].interchangefee");
        adjustment = try json_resp.stringOf(alloc, "fundings[i].adjustment");
        currency = try json_resp.stringOf(alloc, "fundings[i].currency");
        depositachtracenumber = try json_resp.stringOf(alloc, "fundings[i].depositachtracenumber");
        servicecharge = try json_resp.stringOf(alloc, "fundings[i].servicecharge");
        otheradjustment = try json_resp.stringOf(alloc, "fundings[i].otheradjustment");
        abanumber = try json_resp.stringOf(alloc, "fundings[i].abanumber");
        i = i + 1;
    }

    i = 0;
    count_i = json_resp.sizeOfArray("txns");
    while (i < count_i) {
        json_resp.setI(i);
        date = try json_resp.stringOf(alloc, "txns[i].date");
        amount = try json_resp.stringOf(alloc, "txns[i].amount");
        downgradereasoncodes = try json_resp.stringOf(alloc, "txns[i].downgradereasoncodes");
        fundingid = json_resp.intOf("txns[i].fundingid");
        cardproc = try json_resp.stringOf(alloc, "txns[i].cardproc");
        sourcetransactionid = try json_resp.stringOf(alloc, "txns[i].sourcetransactionid");
        v_type = try json_resp.stringOf(alloc, "txns[i].type");
        batchid = json_resp.intOf("txns[i].batchid");
        respcode = try json_resp.stringOf(alloc, "txns[i].respcode");
        interchangeunitfee = try json_resp.stringOf(alloc, "txns[i].interchangeunitfee");
        authcode = try json_resp.stringOf(alloc, "txns[i].authcode");
        plancode = try json_resp.stringOf(alloc, "txns[i].plancode");
        authdate = json_resp.intOf("txns[i].authdate");
        fundingtxnid = json_resp.intOf("txns[i].fundingtxnid");
        cardbrand = try json_resp.stringOf(alloc, "txns[i].cardbrand");
        currency = try json_resp.stringOf(alloc, "txns[i].currency");
        terminalnumber = try json_resp.stringOf(alloc, "txns[i].terminalnumber");
        cardnumber = try json_resp.stringOf(alloc, "txns[i].cardnumber");
        cardtype = try json_resp.stringOf(alloc, "txns[i].cardtype");
        retref = try json_resp.stringOf(alloc, "txns[i].retref");
        status = try json_resp.stringOf(alloc, "txns[i].status");
        interchangepercentfee = try json_resp.stringOf(alloc, "txns[i].interchangepercentfee");
        invoicenumber = try json_resp.stringOf(alloc, "txns[i].invoicenumber");
        i = i + 1;
    }
}