Unicode C
Unicode C
ClickBank Parse Instant Notification JSON
See more ClickBank Examples
Demonstrates how to parse the JSON of a ClickBank instant notification.Chilkat Unicode C Downloads
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkJsonObjectW json;
const wchar_t *transactionTime;
const wchar_t *receipt;
const wchar_t *transactionType;
const wchar_t *vendor;
const wchar_t *affiliate;
const wchar_t *role;
const wchar_t *totalAccountAmount;
const wchar_t *paymentMethod;
const wchar_t *totalOrderAmount;
const wchar_t *totalTaxAmount;
const wchar_t *totalShippingAmount;
const wchar_t *currency;
const wchar_t *orderLanguage;
const wchar_t *customerShippingFirstName;
const wchar_t *customerShippingLastName;
const wchar_t *customerShippingFullName;
const wchar_t *customerShippingPhoneNumber;
const wchar_t *customerShippingEmail;
const wchar_t *customerShippingAddressAddress1;
const wchar_t *customerShippingAddressAddress2;
const wchar_t *customerShippingAddressCity;
const wchar_t *customerShippingAddressCounty;
const wchar_t *customerShippingAddressState;
const wchar_t *customerShippingAddressPostalCode;
const wchar_t *customerShippingAddressCountry;
const wchar_t *customerBillingFirstName;
const wchar_t *customerBillingLastName;
const wchar_t *customerBillingFullName;
const wchar_t *customerBillingPhoneNumber;
const wchar_t *customerBillingEmail;
const wchar_t *customerBillingAddressState;
const wchar_t *customerBillingAddressPostalCode;
const wchar_t *customerBillingAddressCountry;
const wchar_t *upsellUpsellOriginalReceipt;
int upsellUpsellFlowId;
const wchar_t *upsellUpsellSession;
const wchar_t *upsellUpsellPath;
const wchar_t *hopfeedHopfeedClickId;
int hopfeedHopfeedApplicationId;
int hopfeedHopfeedCreativeId;
const wchar_t *hopfeedHopfeedApplicationPayout;
const wchar_t *hopfeedHopfeedVendorPayout;
const wchar_t *version;
int attemptCount;
const wchar_t *vendorVariablesV1;
const wchar_t *vendorVariablesV2;
int i;
int count_i;
const wchar_t *strVal;
const wchar_t *itemNo;
const wchar_t *productTitle;
BOOL shippable;
BOOL recurring;
const wchar_t *accountAmount;
int quantity;
const wchar_t *downloadUrl;
const wchar_t *lineItemType;
json = CkJsonObjectW_Create();
CkJsonObjectW_Load(json,L"{ ... }");
// 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 = CkJsonObjectW_stringOf(json,L"transactionTime");
receipt = CkJsonObjectW_stringOf(json,L"receipt");
transactionType = CkJsonObjectW_stringOf(json,L"transactionType");
vendor = CkJsonObjectW_stringOf(json,L"vendor");
affiliate = CkJsonObjectW_stringOf(json,L"affiliate");
role = CkJsonObjectW_stringOf(json,L"role");
totalAccountAmount = CkJsonObjectW_stringOf(json,L"totalAccountAmount");
paymentMethod = CkJsonObjectW_stringOf(json,L"paymentMethod");
totalOrderAmount = CkJsonObjectW_stringOf(json,L"totalOrderAmount");
totalTaxAmount = CkJsonObjectW_stringOf(json,L"totalTaxAmount");
totalShippingAmount = CkJsonObjectW_stringOf(json,L"totalShippingAmount");
currency = CkJsonObjectW_stringOf(json,L"currency");
orderLanguage = CkJsonObjectW_stringOf(json,L"orderLanguage");
customerShippingFirstName = CkJsonObjectW_stringOf(json,L"customer.shipping.firstName");
customerShippingLastName = CkJsonObjectW_stringOf(json,L"customer.shipping.lastName");
customerShippingFullName = CkJsonObjectW_stringOf(json,L"customer.shipping.fullName");
customerShippingPhoneNumber = CkJsonObjectW_stringOf(json,L"customer.shipping.phoneNumber");
customerShippingEmail = CkJsonObjectW_stringOf(json,L"customer.shipping.email");
customerShippingAddressAddress1 = CkJsonObjectW_stringOf(json,L"customer.shipping.address.address1");
customerShippingAddressAddress2 = CkJsonObjectW_stringOf(json,L"customer.shipping.address.address2");
customerShippingAddressCity = CkJsonObjectW_stringOf(json,L"customer.shipping.address.city");
customerShippingAddressCounty = CkJsonObjectW_stringOf(json,L"customer.shipping.address.county");
customerShippingAddressState = CkJsonObjectW_stringOf(json,L"customer.shipping.address.state");
customerShippingAddressPostalCode = CkJsonObjectW_stringOf(json,L"customer.shipping.address.postalCode");
customerShippingAddressCountry = CkJsonObjectW_stringOf(json,L"customer.shipping.address.country");
customerBillingFirstName = CkJsonObjectW_stringOf(json,L"customer.billing.firstName");
customerBillingLastName = CkJsonObjectW_stringOf(json,L"customer.billing.lastName");
customerBillingFullName = CkJsonObjectW_stringOf(json,L"customer.billing.fullName");
customerBillingPhoneNumber = CkJsonObjectW_stringOf(json,L"customer.billing.phoneNumber");
customerBillingEmail = CkJsonObjectW_stringOf(json,L"customer.billing.email");
customerBillingAddressState = CkJsonObjectW_stringOf(json,L"customer.billing.address.state");
customerBillingAddressPostalCode = CkJsonObjectW_stringOf(json,L"customer.billing.address.postalCode");
customerBillingAddressCountry = CkJsonObjectW_stringOf(json,L"customer.billing.address.country");
upsellUpsellOriginalReceipt = CkJsonObjectW_stringOf(json,L"upsell.upsellOriginalReceipt");
upsellUpsellFlowId = CkJsonObjectW_IntOf(json,L"upsell.upsellFlowId");
upsellUpsellSession = CkJsonObjectW_stringOf(json,L"upsell.upsellSession");
upsellUpsellPath = CkJsonObjectW_stringOf(json,L"upsell.upsellPath");
hopfeedHopfeedClickId = CkJsonObjectW_stringOf(json,L"hopfeed.hopfeedClickId");
hopfeedHopfeedApplicationId = CkJsonObjectW_IntOf(json,L"hopfeed.hopfeedApplicationId");
hopfeedHopfeedCreativeId = CkJsonObjectW_IntOf(json,L"hopfeed.hopfeedCreativeId");
hopfeedHopfeedApplicationPayout = CkJsonObjectW_stringOf(json,L"hopfeed.hopfeedApplicationPayout");
hopfeedHopfeedVendorPayout = CkJsonObjectW_stringOf(json,L"hopfeed.hopfeedVendorPayout");
version = CkJsonObjectW_stringOf(json,L"version");
attemptCount = CkJsonObjectW_IntOf(json,L"attemptCount");
vendorVariablesV1 = CkJsonObjectW_stringOf(json,L"vendorVariables.v1");
vendorVariablesV2 = CkJsonObjectW_stringOf(json,L"vendorVariables.v2");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(json,L"trackingCodes");
while (i < count_i) {
CkJsonObjectW_putI(json,i);
strVal = CkJsonObjectW_stringOf(json,L"trackingCodes[i]");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(json,L"lineItems");
while (i < count_i) {
CkJsonObjectW_putI(json,i);
itemNo = CkJsonObjectW_stringOf(json,L"lineItems[i].itemNo");
productTitle = CkJsonObjectW_stringOf(json,L"lineItems[i].productTitle");
shippable = CkJsonObjectW_BoolOf(json,L"lineItems[i].shippable");
recurring = CkJsonObjectW_BoolOf(json,L"lineItems[i].recurring");
accountAmount = CkJsonObjectW_stringOf(json,L"lineItems[i].accountAmount");
quantity = CkJsonObjectW_IntOf(json,L"lineItems[i].quantity");
downloadUrl = CkJsonObjectW_stringOf(json,L"lineItems[i].downloadUrl");
lineItemType = CkJsonObjectW_stringOf(json,L"lineItems[i].lineItemType");
i = i + 1;
}
CkJsonObjectW_Dispose(json);
}