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