Tcl
Tcl
ClickBank Parse Instant Notification JSON
See more ClickBank Examples
Demonstrates how to parse the JSON of a ClickBank instant notification.Chilkat Tcl Downloads
load ./chilkat.dll
set json [new_CkJsonObject]
CkJsonObject_Load $json "{ ... }"
# 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"
# }
# }
#
#
set transactionTime [CkJsonObject_stringOf $json "transactionTime"]
set receipt [CkJsonObject_stringOf $json "receipt"]
set transactionType [CkJsonObject_stringOf $json "transactionType"]
set vendor [CkJsonObject_stringOf $json "vendor"]
set affiliate [CkJsonObject_stringOf $json "affiliate"]
set role [CkJsonObject_stringOf $json "role"]
set totalAccountAmount [CkJsonObject_stringOf $json "totalAccountAmount"]
set paymentMethod [CkJsonObject_stringOf $json "paymentMethod"]
set totalOrderAmount [CkJsonObject_stringOf $json "totalOrderAmount"]
set totalTaxAmount [CkJsonObject_stringOf $json "totalTaxAmount"]
set totalShippingAmount [CkJsonObject_stringOf $json "totalShippingAmount"]
set currency [CkJsonObject_stringOf $json "currency"]
set orderLanguage [CkJsonObject_stringOf $json "orderLanguage"]
set customerShippingFirstName [CkJsonObject_stringOf $json "customer.shipping.firstName"]
set customerShippingLastName [CkJsonObject_stringOf $json "customer.shipping.lastName"]
set customerShippingFullName [CkJsonObject_stringOf $json "customer.shipping.fullName"]
set customerShippingPhoneNumber [CkJsonObject_stringOf $json "customer.shipping.phoneNumber"]
set customerShippingEmail [CkJsonObject_stringOf $json "customer.shipping.email"]
set customerShippingAddressAddress1 [CkJsonObject_stringOf $json "customer.shipping.address.address1"]
set customerShippingAddressAddress2 [CkJsonObject_stringOf $json "customer.shipping.address.address2"]
set customerShippingAddressCity [CkJsonObject_stringOf $json "customer.shipping.address.city"]
set customerShippingAddressCounty [CkJsonObject_stringOf $json "customer.shipping.address.county"]
set customerShippingAddressState [CkJsonObject_stringOf $json "customer.shipping.address.state"]
set customerShippingAddressPostalCode [CkJsonObject_stringOf $json "customer.shipping.address.postalCode"]
set customerShippingAddressCountry [CkJsonObject_stringOf $json "customer.shipping.address.country"]
set customerBillingFirstName [CkJsonObject_stringOf $json "customer.billing.firstName"]
set customerBillingLastName [CkJsonObject_stringOf $json "customer.billing.lastName"]
set customerBillingFullName [CkJsonObject_stringOf $json "customer.billing.fullName"]
set customerBillingPhoneNumber [CkJsonObject_stringOf $json "customer.billing.phoneNumber"]
set customerBillingEmail [CkJsonObject_stringOf $json "customer.billing.email"]
set customerBillingAddressState [CkJsonObject_stringOf $json "customer.billing.address.state"]
set customerBillingAddressPostalCode [CkJsonObject_stringOf $json "customer.billing.address.postalCode"]
set customerBillingAddressCountry [CkJsonObject_stringOf $json "customer.billing.address.country"]
set upsellUpsellOriginalReceipt [CkJsonObject_stringOf $json "upsell.upsellOriginalReceipt"]
set upsellUpsellFlowId [CkJsonObject_IntOf $json "upsell.upsellFlowId"]
set upsellUpsellSession [CkJsonObject_stringOf $json "upsell.upsellSession"]
set upsellUpsellPath [CkJsonObject_stringOf $json "upsell.upsellPath"]
set hopfeedHopfeedClickId [CkJsonObject_stringOf $json "hopfeed.hopfeedClickId"]
set hopfeedHopfeedApplicationId [CkJsonObject_IntOf $json "hopfeed.hopfeedApplicationId"]
set hopfeedHopfeedCreativeId [CkJsonObject_IntOf $json "hopfeed.hopfeedCreativeId"]
set hopfeedHopfeedApplicationPayout [CkJsonObject_stringOf $json "hopfeed.hopfeedApplicationPayout"]
set hopfeedHopfeedVendorPayout [CkJsonObject_stringOf $json "hopfeed.hopfeedVendorPayout"]
set version [CkJsonObject_stringOf $json "version"]
set attemptCount [CkJsonObject_IntOf $json "attemptCount"]
set vendorVariablesV1 [CkJsonObject_stringOf $json "vendorVariables.v1"]
set vendorVariablesV2 [CkJsonObject_stringOf $json "vendorVariables.v2"]
set i 0
set count_i [CkJsonObject_SizeOfArray $json "trackingCodes"]
while {$i < $count_i} {
CkJsonObject_put_I $json $i
set strVal [CkJsonObject_stringOf $json "trackingCodes[i]"]
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "lineItems"]
while {$i < $count_i} {
CkJsonObject_put_I $json $i
set itemNo [CkJsonObject_stringOf $json "lineItems[i].itemNo"]
set productTitle [CkJsonObject_stringOf $json "lineItems[i].productTitle"]
set shippable [CkJsonObject_BoolOf $json "lineItems[i].shippable"]
set recurring [CkJsonObject_BoolOf $json "lineItems[i].recurring"]
set accountAmount [CkJsonObject_stringOf $json "lineItems[i].accountAmount"]
set quantity [CkJsonObject_IntOf $json "lineItems[i].quantity"]
set downloadUrl [CkJsonObject_stringOf $json "lineItems[i].downloadUrl"]
set lineItemType [CkJsonObject_stringOf $json "lineItems[i].lineItemType"]
set i [expr $i + 1]
}
delete_CkJsonObject $json