Sample code for 30+ languages & platforms
Dart

ClickBank Parse Instant Notification JSON

See more ClickBank Examples

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

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final json = CkJsonObject();

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

  var i = 0;
  var countI = 0;
  var strVal = '';
  var itemNo = '';
  var productTitle = '';
  var accountAmount = '';
  var quantity = 0;
  var downloadUrl = '';
  var lineItemType = '';

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

  i = 0;
  countI = json.sizeOfArray('lineItems');
  while (i < countI) {
    json.i = i;
    itemNo = json.stringOf('lineItems[i].itemNo');
    productTitle = json.stringOf('lineItems[i].productTitle');
    json.boolOf('lineItems[i].shippable');
    json.boolOf('lineItems[i].recurring');
    accountAmount = json.stringOf('lineItems[i].accountAmount');
    quantity = json.intOf('lineItems[i].quantity');
    downloadUrl = json.stringOf('lineItems[i].downloadUrl');
    lineItemType = json.stringOf('lineItems[i].lineItemType');
    i++;
  }
}