PureBasic
PureBasic
ClickBank Parse Instant Notification JSON
See more ClickBank Examples
Demonstrates how to parse the JSON of a ClickBank instant notification.Chilkat PureBasic Downloads
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoad(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"
; }
; }
;
;
transactionTime.s
receipt.s
transactionType.s
vendor.s
affiliate.s
role.s
totalAccountAmount.s
paymentMethod.s
totalOrderAmount.s
totalTaxAmount.s
totalShippingAmount.s
currency.s
orderLanguage.s
customerShippingFirstName.s
customerShippingLastName.s
customerShippingFullName.s
customerShippingPhoneNumber.s
customerShippingEmail.s
customerShippingAddressAddress1.s
customerShippingAddressAddress2.s
customerShippingAddressCity.s
customerShippingAddressCounty.s
customerShippingAddressState.s
customerShippingAddressPostalCode.s
customerShippingAddressCountry.s
customerBillingFirstName.s
customerBillingLastName.s
customerBillingFullName.s
customerBillingPhoneNumber.s
customerBillingEmail.s
customerBillingAddressState.s
customerBillingAddressPostalCode.s
customerBillingAddressCountry.s
upsellUpsellOriginalReceipt.s
upsellUpsellFlowId.i
upsellUpsellSession.s
upsellUpsellPath.s
hopfeedHopfeedClickId.s
hopfeedHopfeedApplicationId.i
hopfeedHopfeedCreativeId.i
hopfeedHopfeedApplicationPayout.s
hopfeedHopfeedVendorPayout.s
version.s
attemptCount.i
vendorVariablesV1.s
vendorVariablesV2.s
i.i
count_i.i
strVal.s
itemNo.s
productTitle.s
shippable.i
recurring.i
accountAmount.s
quantity.i
downloadUrl.s
lineItemType.s
transactionTime = CkJsonObject::ckStringOf(json,"transactionTime")
receipt = CkJsonObject::ckStringOf(json,"receipt")
transactionType = CkJsonObject::ckStringOf(json,"transactionType")
vendor = CkJsonObject::ckStringOf(json,"vendor")
affiliate = CkJsonObject::ckStringOf(json,"affiliate")
role = CkJsonObject::ckStringOf(json,"role")
totalAccountAmount = CkJsonObject::ckStringOf(json,"totalAccountAmount")
paymentMethod = CkJsonObject::ckStringOf(json,"paymentMethod")
totalOrderAmount = CkJsonObject::ckStringOf(json,"totalOrderAmount")
totalTaxAmount = CkJsonObject::ckStringOf(json,"totalTaxAmount")
totalShippingAmount = CkJsonObject::ckStringOf(json,"totalShippingAmount")
currency = CkJsonObject::ckStringOf(json,"currency")
orderLanguage = CkJsonObject::ckStringOf(json,"orderLanguage")
customerShippingFirstName = CkJsonObject::ckStringOf(json,"customer.shipping.firstName")
customerShippingLastName = CkJsonObject::ckStringOf(json,"customer.shipping.lastName")
customerShippingFullName = CkJsonObject::ckStringOf(json,"customer.shipping.fullName")
customerShippingPhoneNumber = CkJsonObject::ckStringOf(json,"customer.shipping.phoneNumber")
customerShippingEmail = CkJsonObject::ckStringOf(json,"customer.shipping.email")
customerShippingAddressAddress1 = CkJsonObject::ckStringOf(json,"customer.shipping.address.address1")
customerShippingAddressAddress2 = CkJsonObject::ckStringOf(json,"customer.shipping.address.address2")
customerShippingAddressCity = CkJsonObject::ckStringOf(json,"customer.shipping.address.city")
customerShippingAddressCounty = CkJsonObject::ckStringOf(json,"customer.shipping.address.county")
customerShippingAddressState = CkJsonObject::ckStringOf(json,"customer.shipping.address.state")
customerShippingAddressPostalCode = CkJsonObject::ckStringOf(json,"customer.shipping.address.postalCode")
customerShippingAddressCountry = CkJsonObject::ckStringOf(json,"customer.shipping.address.country")
customerBillingFirstName = CkJsonObject::ckStringOf(json,"customer.billing.firstName")
customerBillingLastName = CkJsonObject::ckStringOf(json,"customer.billing.lastName")
customerBillingFullName = CkJsonObject::ckStringOf(json,"customer.billing.fullName")
customerBillingPhoneNumber = CkJsonObject::ckStringOf(json,"customer.billing.phoneNumber")
customerBillingEmail = CkJsonObject::ckStringOf(json,"customer.billing.email")
customerBillingAddressState = CkJsonObject::ckStringOf(json,"customer.billing.address.state")
customerBillingAddressPostalCode = CkJsonObject::ckStringOf(json,"customer.billing.address.postalCode")
customerBillingAddressCountry = CkJsonObject::ckStringOf(json,"customer.billing.address.country")
upsellUpsellOriginalReceipt = CkJsonObject::ckStringOf(json,"upsell.upsellOriginalReceipt")
upsellUpsellFlowId = CkJsonObject::ckIntOf(json,"upsell.upsellFlowId")
upsellUpsellSession = CkJsonObject::ckStringOf(json,"upsell.upsellSession")
upsellUpsellPath = CkJsonObject::ckStringOf(json,"upsell.upsellPath")
hopfeedHopfeedClickId = CkJsonObject::ckStringOf(json,"hopfeed.hopfeedClickId")
hopfeedHopfeedApplicationId = CkJsonObject::ckIntOf(json,"hopfeed.hopfeedApplicationId")
hopfeedHopfeedCreativeId = CkJsonObject::ckIntOf(json,"hopfeed.hopfeedCreativeId")
hopfeedHopfeedApplicationPayout = CkJsonObject::ckStringOf(json,"hopfeed.hopfeedApplicationPayout")
hopfeedHopfeedVendorPayout = CkJsonObject::ckStringOf(json,"hopfeed.hopfeedVendorPayout")
version = CkJsonObject::ckStringOf(json,"version")
attemptCount = CkJsonObject::ckIntOf(json,"attemptCount")
vendorVariablesV1 = CkJsonObject::ckStringOf(json,"vendorVariables.v1")
vendorVariablesV2 = CkJsonObject::ckStringOf(json,"vendorVariables.v2")
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"trackingCodes")
While i < count_i
CkJsonObject::setCkI(json, i)
strVal = CkJsonObject::ckStringOf(json,"trackingCodes[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"lineItems")
While i < count_i
CkJsonObject::setCkI(json, i)
itemNo = CkJsonObject::ckStringOf(json,"lineItems[i].itemNo")
productTitle = CkJsonObject::ckStringOf(json,"lineItems[i].productTitle")
shippable = CkJsonObject::ckBoolOf(json,"lineItems[i].shippable")
recurring = CkJsonObject::ckBoolOf(json,"lineItems[i].recurring")
accountAmount = CkJsonObject::ckStringOf(json,"lineItems[i].accountAmount")
quantity = CkJsonObject::ckIntOf(json,"lineItems[i].quantity")
downloadUrl = CkJsonObject::ckStringOf(json,"lineItems[i].downloadUrl")
lineItemType = CkJsonObject::ckStringOf(json,"lineItems[i].lineItemType")
i = i + 1
Wend
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure