Sample code for 30+ languages & platforms
React Native

ClickBank Parse Instant Notification JSON

See more ClickBank Examples

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

Chilkat React Native Downloads

React Native
import { JsonObject } from '@chilkat/react-native'

function chilkatExample() {
  const json = new JsonObject();

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

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

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