Java
Chilkat2 Java
ClickBank Parse Instant Notification JSON
See more ClickBank Examples
Demonstrates how to parse the JSON of a ClickBank instant notification.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.JsonObject;
public class ChilkatExample {
public static void main(String[] args) {
JsonObject 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"
// }
// }
//
//
String strVal = "";
String itemNo = "";
String productTitle = "";
boolean shippable = false;
boolean recurring = false;
String accountAmount = "";
int quantity = 0;
String downloadUrl = "";
String lineItemType = "";
String transactionTime = json.stringOf("transactionTime");
String receipt = json.stringOf("receipt");
String transactionType = json.stringOf("transactionType");
String vendor = json.stringOf("vendor");
String affiliate = json.stringOf("affiliate");
String role = json.stringOf("role");
String totalAccountAmount = json.stringOf("totalAccountAmount");
String paymentMethod = json.stringOf("paymentMethod");
String totalOrderAmount = json.stringOf("totalOrderAmount");
String totalTaxAmount = json.stringOf("totalTaxAmount");
String totalShippingAmount = json.stringOf("totalShippingAmount");
String currency = json.stringOf("currency");
String orderLanguage = json.stringOf("orderLanguage");
String customerShippingFirstName = json.stringOf("customer.shipping.firstName");
String customerShippingLastName = json.stringOf("customer.shipping.lastName");
String customerShippingFullName = json.stringOf("customer.shipping.fullName");
String customerShippingPhoneNumber = json.stringOf("customer.shipping.phoneNumber");
String customerShippingEmail = json.stringOf("customer.shipping.email");
String customerShippingAddressAddress1 = json.stringOf("customer.shipping.address.address1");
String customerShippingAddressAddress2 = json.stringOf("customer.shipping.address.address2");
String customerShippingAddressCity = json.stringOf("customer.shipping.address.city");
String customerShippingAddressCounty = json.stringOf("customer.shipping.address.county");
String customerShippingAddressState = json.stringOf("customer.shipping.address.state");
String customerShippingAddressPostalCode = json.stringOf("customer.shipping.address.postalCode");
String customerShippingAddressCountry = json.stringOf("customer.shipping.address.country");
String customerBillingFirstName = json.stringOf("customer.billing.firstName");
String customerBillingLastName = json.stringOf("customer.billing.lastName");
String customerBillingFullName = json.stringOf("customer.billing.fullName");
String customerBillingPhoneNumber = json.stringOf("customer.billing.phoneNumber");
String customerBillingEmail = json.stringOf("customer.billing.email");
String customerBillingAddressState = json.stringOf("customer.billing.address.state");
String customerBillingAddressPostalCode = json.stringOf("customer.billing.address.postalCode");
String customerBillingAddressCountry = json.stringOf("customer.billing.address.country");
String upsellUpsellOriginalReceipt = json.stringOf("upsell.upsellOriginalReceipt");
int upsellUpsellFlowId = json.intOf("upsell.upsellFlowId");
String upsellUpsellSession = json.stringOf("upsell.upsellSession");
String upsellUpsellPath = json.stringOf("upsell.upsellPath");
String hopfeedHopfeedClickId = json.stringOf("hopfeed.hopfeedClickId");
int hopfeedHopfeedApplicationId = json.intOf("hopfeed.hopfeedApplicationId");
int hopfeedHopfeedCreativeId = json.intOf("hopfeed.hopfeedCreativeId");
String hopfeedHopfeedApplicationPayout = json.stringOf("hopfeed.hopfeedApplicationPayout");
String hopfeedHopfeedVendorPayout = json.stringOf("hopfeed.hopfeedVendorPayout");
String version = json.stringOf("version");
int attemptCount = json.intOf("attemptCount");
String vendorVariablesV1 = json.stringOf("vendorVariables.v1");
String vendorVariablesV2 = json.stringOf("vendorVariables.v2");
int i = 0;
int count_i = json.sizeOfArray("trackingCodes");
while (i < count_i) {
json.setI(i);
strVal = json.stringOf("trackingCodes[i]");
i = i + 1;
}
i = 0;
count_i = json.sizeOfArray("lineItems");
while (i < count_i) {
json.setI(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");
downloadUrl = json.stringOf("lineItems[i].downloadUrl");
lineItemType = json.stringOf("lineItems[i].lineItemType");
i = i + 1;
}
}
}