Sample code for 30+ languages & platforms
Xbase++

ClickBank Parse Instant Notification JSON

See more ClickBank Examples

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

Chilkat Xbase++ Downloads

Xbase++
LOCAL oJson
LOCAL cTransactionTime
LOCAL cReceipt
LOCAL cTransactionType
LOCAL cVendor
LOCAL cAffiliate
LOCAL cRole
LOCAL cTotalAccountAmount
LOCAL cPaymentMethod
LOCAL cTotalOrderAmount
LOCAL cTotalTaxAmount
LOCAL cTotalShippingAmount
LOCAL cCurrency
LOCAL cOrderLanguage
LOCAL cCustomerShippingFirstName
LOCAL cCustomerShippingLastName
LOCAL cCustomerShippingFullName
LOCAL cCustomerShippingPhoneNumber
LOCAL cCustomerShippingEmail
LOCAL cCustomerShippingAddressAddress1
LOCAL cCustomerShippingAddressAddress2
LOCAL cCustomerShippingAddressCity
LOCAL cCustomerShippingAddressCounty
LOCAL cCustomerShippingAddressState
LOCAL cCustomerShippingAddressPostalCode
LOCAL cCustomerShippingAddressCountry
LOCAL cCustomerBillingFirstName
LOCAL cCustomerBillingLastName
LOCAL cCustomerBillingFullName
LOCAL cCustomerBillingPhoneNumber
LOCAL cCustomerBillingEmail
LOCAL cCustomerBillingAddressState
LOCAL cCustomerBillingAddressPostalCode
LOCAL cCustomerBillingAddressCountry
LOCAL cUpsellUpsellOriginalReceipt
LOCAL nUpsellUpsellFlowId
LOCAL cUpsellUpsellSession
LOCAL cUpsellUpsellPath
LOCAL cHopfeedHopfeedClickId
LOCAL nHopfeedHopfeedApplicationId
LOCAL nHopfeedHopfeedCreativeId
LOCAL cHopfeedHopfeedApplicationPayout
LOCAL cHopfeedHopfeedVendorPayout
LOCAL cVersion
LOCAL nAttemptCount
LOCAL cVendorVariablesV1
LOCAL cVendorVariablesV2
LOCAL i
LOCAL nCount_i
LOCAL cStrVal
LOCAL cItemNo
LOCAL cProductTitle
LOCAL nShippable
LOCAL nRecurring
LOCAL cAccountAmount
LOCAL nQuantity
LOCAL cDownloadUrl
LOCAL cLineItemType

oJson := CreateObject("Chilkat.JsonObject")

oJson: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" 
//      }
//   }
//  
//  

cTransactionTime := oJson:StringOf("transactionTime")
cReceipt := oJson:StringOf("receipt")
cTransactionType := oJson:StringOf("transactionType")
cVendor := oJson:StringOf("vendor")
cAffiliate := oJson:StringOf("affiliate")
cRole := oJson:StringOf("role")
cTotalAccountAmount := oJson:StringOf("totalAccountAmount")
cPaymentMethod := oJson:StringOf("paymentMethod")
cTotalOrderAmount := oJson:StringOf("totalOrderAmount")
cTotalTaxAmount := oJson:StringOf("totalTaxAmount")
cTotalShippingAmount := oJson:StringOf("totalShippingAmount")
cCurrency := oJson:StringOf("currency")
cOrderLanguage := oJson:StringOf("orderLanguage")
cCustomerShippingFirstName := oJson:StringOf("customer.shipping.firstName")
cCustomerShippingLastName := oJson:StringOf("customer.shipping.lastName")
cCustomerShippingFullName := oJson:StringOf("customer.shipping.fullName")
cCustomerShippingPhoneNumber := oJson:StringOf("customer.shipping.phoneNumber")
cCustomerShippingEmail := oJson:StringOf("customer.shipping.email")
cCustomerShippingAddressAddress1 := oJson:StringOf("customer.shipping.address.address1")
cCustomerShippingAddressAddress2 := oJson:StringOf("customer.shipping.address.address2")
cCustomerShippingAddressCity := oJson:StringOf("customer.shipping.address.city")
cCustomerShippingAddressCounty := oJson:StringOf("customer.shipping.address.county")
cCustomerShippingAddressState := oJson:StringOf("customer.shipping.address.state")
cCustomerShippingAddressPostalCode := oJson:StringOf("customer.shipping.address.postalCode")
cCustomerShippingAddressCountry := oJson:StringOf("customer.shipping.address.country")
cCustomerBillingFirstName := oJson:StringOf("customer.billing.firstName")
cCustomerBillingLastName := oJson:StringOf("customer.billing.lastName")
cCustomerBillingFullName := oJson:StringOf("customer.billing.fullName")
cCustomerBillingPhoneNumber := oJson:StringOf("customer.billing.phoneNumber")
cCustomerBillingEmail := oJson:StringOf("customer.billing.email")
cCustomerBillingAddressState := oJson:StringOf("customer.billing.address.state")
cCustomerBillingAddressPostalCode := oJson:StringOf("customer.billing.address.postalCode")
cCustomerBillingAddressCountry := oJson:StringOf("customer.billing.address.country")
cUpsellUpsellOriginalReceipt := oJson:StringOf("upsell.upsellOriginalReceipt")
nUpsellUpsellFlowId := oJson:IntOf("upsell.upsellFlowId")
cUpsellUpsellSession := oJson:StringOf("upsell.upsellSession")
cUpsellUpsellPath := oJson:StringOf("upsell.upsellPath")
cHopfeedHopfeedClickId := oJson:StringOf("hopfeed.hopfeedClickId")
nHopfeedHopfeedApplicationId := oJson:IntOf("hopfeed.hopfeedApplicationId")
nHopfeedHopfeedCreativeId := oJson:IntOf("hopfeed.hopfeedCreativeId")
cHopfeedHopfeedApplicationPayout := oJson:StringOf("hopfeed.hopfeedApplicationPayout")
cHopfeedHopfeedVendorPayout := oJson:StringOf("hopfeed.hopfeedVendorPayout")
cVersion := oJson:StringOf("version")
nAttemptCount := oJson:IntOf("attemptCount")
cVendorVariablesV1 := oJson:StringOf("vendorVariables.v1")
cVendorVariablesV2 := oJson:StringOf("vendorVariables.v2")
i := 0
nCount_i := oJson:SizeOfArray("trackingCodes")
DO WHILE i < nCount_i
    oJson:I := i
    cStrVal := oJson:StringOf("trackingCodes[i]")
    i := i + 1
ENDDO
i := 0
nCount_i := oJson:SizeOfArray("lineItems")
DO WHILE i < nCount_i
    oJson:I := i
    cItemNo := oJson:StringOf("lineItems[i].itemNo")
    cProductTitle := oJson:StringOf("lineItems[i].productTitle")
    nShippable := oJson:BoolOf("lineItems[i].shippable")
    nRecurring := oJson:BoolOf("lineItems[i].recurring")
    cAccountAmount := oJson:StringOf("lineItems[i].accountAmount")
    nQuantity := oJson:IntOf("lineItems[i].quantity")
    cDownloadUrl := oJson:StringOf("lineItems[i].downloadUrl")
    cLineItemType := oJson:StringOf("lineItems[i].lineItemType")
    i := i + 1
ENDDO

oJson:destroy()