Sample code for 30+ languages & platforms
Lua

ClickBank Parse Instant Notification JSON

See more ClickBank Examples

Demonstrates how to parse the JSON of a ClickBank instant notification.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local json = chilkat.JsonObject.new()

json:load("{  ...  }")

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

-- See the parsing code below..

-- Sample notification JSON:

-- {
--     "transactionTime": "2016-06-05T13:47:51-06:00",
--     "receipt": "CWOGBZLN",
--     "transactionType": "SALE",
--     "vendor": "testacct",
--     "affiliate": "affiliate1",
--     "role": "VENDOR",
--     "totalAccountAmount": 0.00,
--     "paymentMethod": "VISA",
--     "totalOrderAmount": 0.00,
--     "totalTaxAmount": 0.00,
--     "totalShippingAmount": 0.00,
--     "currency": "USD",
--     "orderLanguage": "EN",
--     "trackingCodes": [
--         "tracking_code"
--     ],
--     "lineItems": [
--         {
--             "itemNo": "1",
--             "productTitle": "Product Title",
--             "shippable": false,
--             "recurring": false,
--             "accountAmount": 5.00,
--             "quantity": 1,
--             "downloadUrl": "<download_url>"
--             "lineItemType": "CART"
--        }
--         {
--             "itemNo": "2",
--             "productTitle": "Second Product",
--             "shippable": false,
--             "recurring": true,
--             "accountAmount": 2.99,
--             "quantity": 1,
--             "downloadUrl": "<download_url>"
--             "lineItemType": "CART"
--        }
--
--     ],
--      "customer": {
--         "shipping": {
--             "firstName": "TEST",
--             "lastName": "GUY",
--             "fullName": "Test Guy",
--             "phoneNumber": "",
--             "email": "test@example.net",
--             "address": {
--                 "address1": "12 Test Lane",
--                 "address2": "Suite 100",
--                 "city": "LAS VEGAS",
--                 "county": "LAS VEGAS",
--                 "state": "NV",
--                 "postalCode": "89101",
--                 "country": "US"
--             }
--         },
--         "billing": {
--             "firstName": "TEST",
--             "lastName": "GUY",
--             "fullName": "Test Guy",
--             "phoneNumber": "",
--             "email": "test@example.net",
--             "address": {
--                 "state": "NV",
--                 "postalCode": "89101",
--                 "country": "US"
--             }
--         }
--     },
--      "upsell": {
--         "upsellOriginalReceipt": "XXXXXXXX",
--         "upsellFlowId": 55,
--         "upsellSession": "VVVVVVVVVV",
--         "upsellPath": "upsell_path"
--     },
--      "hopfeed": {
--         "hopfeedClickId": "hopfeed_click",
--         "hopfeedApplicationId": 0000,
--         "hopfeedCreativeId": 0000,
--         "hopfeedApplicationPayout": 0.00,
--         "hopfeedVendorPayout": 0.00
--     },
--      "version": 6.0,
--     "attemptCount": 1,
--      "vendorVariables": {
--        "v1": "variable1",
--        "v2": "variable2"
--     }
--  }
--
--

local strVal = ""
local itemNo = ""
local productTitle = ""
local shippable = false
local recurring = false
local accountAmount = ""
local quantity = 0
local downloadUrl = ""
local lineItemType = ""

local transactionTime = json:string_of("transactionTime")
local receipt = json:string_of("receipt")
local transactionType = json:string_of("transactionType")
local vendor = json:string_of("vendor")
local affiliate = json:string_of("affiliate")
local role = json:string_of("role")
local totalAccountAmount = json:string_of("totalAccountAmount")
local paymentMethod = json:string_of("paymentMethod")
local totalOrderAmount = json:string_of("totalOrderAmount")
local totalTaxAmount = json:string_of("totalTaxAmount")
local totalShippingAmount = json:string_of("totalShippingAmount")
local currency = json:string_of("currency")
local orderLanguage = json:string_of("orderLanguage")
local customerShippingFirstName = json:string_of("customer.shipping.firstName")
local customerShippingLastName = json:string_of("customer.shipping.lastName")
local customerShippingFullName = json:string_of("customer.shipping.fullName")
local customerShippingPhoneNumber = json:string_of("customer.shipping.phoneNumber")
local customerShippingEmail = json:string_of("customer.shipping.email")
local customerShippingAddressAddress1 = json:string_of("customer.shipping.address.address1")
local customerShippingAddressAddress2 = json:string_of("customer.shipping.address.address2")
local customerShippingAddressCity = json:string_of("customer.shipping.address.city")
local customerShippingAddressCounty = json:string_of("customer.shipping.address.county")
local customerShippingAddressState = json:string_of("customer.shipping.address.state")
local customerShippingAddressPostalCode = json:string_of("customer.shipping.address.postalCode")
local customerShippingAddressCountry = json:string_of("customer.shipping.address.country")
local customerBillingFirstName = json:string_of("customer.billing.firstName")
local customerBillingLastName = json:string_of("customer.billing.lastName")
local customerBillingFullName = json:string_of("customer.billing.fullName")
local customerBillingPhoneNumber = json:string_of("customer.billing.phoneNumber")
local customerBillingEmail = json:string_of("customer.billing.email")
local customerBillingAddressState = json:string_of("customer.billing.address.state")
local customerBillingAddressPostalCode = json:string_of("customer.billing.address.postalCode")
local customerBillingAddressCountry = json:string_of("customer.billing.address.country")
local upsellUpsellOriginalReceipt = json:string_of("upsell.upsellOriginalReceipt")
local upsellUpsellFlowId = json:int_of("upsell.upsellFlowId")
local upsellUpsellSession = json:string_of("upsell.upsellSession")
local upsellUpsellPath = json:string_of("upsell.upsellPath")
local hopfeedHopfeedClickId = json:string_of("hopfeed.hopfeedClickId")
local hopfeedHopfeedApplicationId = json:int_of("hopfeed.hopfeedApplicationId")
local hopfeedHopfeedCreativeId = json:int_of("hopfeed.hopfeedCreativeId")
local hopfeedHopfeedApplicationPayout = json:string_of("hopfeed.hopfeedApplicationPayout")
local hopfeedHopfeedVendorPayout = json:string_of("hopfeed.hopfeedVendorPayout")
local version = json:string_of("version")
local attemptCount = json:int_of("attemptCount")
local vendorVariablesV1 = json:string_of("vendorVariables.v1")
local vendorVariablesV2 = json:string_of("vendorVariables.v2")
local i = 0
local count_i = json:size_of_array("trackingCodes")
while i < count_i do
    json.i = i
    strVal = json:string_of("trackingCodes[i]")
    i = i + 1
end

i = 0
count_i = json:size_of_array("lineItems")
while i < count_i do
    json.i = i
    itemNo = json:string_of("lineItems[i].itemNo")
    productTitle = json:string_of("lineItems[i].productTitle")
    shippable = json:bool_of("lineItems[i].shippable")
    recurring = json:bool_of("lineItems[i].recurring")
    accountAmount = json:string_of("lineItems[i].accountAmount")
    quantity = json:int_of("lineItems[i].quantity")
    downloadUrl = json:string_of("lineItems[i].downloadUrl")
    lineItemType = json:string_of("lineItems[i].lineItemType")
    i = i + 1
end