Rust
Rust
ClickBank Parse Instant Notification JSON
See more ClickBank Examples
Demonstrates how to parse the JSON of a ClickBank instant notification.Chilkat Rust Downloads
let json = chilkat::JsonObject::new();
let _ = 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 mut i: i32 = 0;
let mut count_i: i32 = 0;
let transaction_time = json.string_of("transactionTime").unwrap_or_default();
let receipt = json.string_of("receipt").unwrap_or_default();
let transaction_type = json.string_of("transactionType").unwrap_or_default();
let vendor = json.string_of("vendor").unwrap_or_default();
let affiliate = json.string_of("affiliate").unwrap_or_default();
let role = json.string_of("role").unwrap_or_default();
let total_account_amount = json.string_of("totalAccountAmount").unwrap_or_default();
let payment_method = json.string_of("paymentMethod").unwrap_or_default();
let total_order_amount = json.string_of("totalOrderAmount").unwrap_or_default();
let total_tax_amount = json.string_of("totalTaxAmount").unwrap_or_default();
let total_shipping_amount = json.string_of("totalShippingAmount").unwrap_or_default();
let currency = json.string_of("currency").unwrap_or_default();
let order_language = json.string_of("orderLanguage").unwrap_or_default();
let customer_shipping_first_name = json.string_of("customer.shipping.firstName").unwrap_or_default();
let customer_shipping_last_name = json.string_of("customer.shipping.lastName").unwrap_or_default();
let customer_shipping_full_name = json.string_of("customer.shipping.fullName").unwrap_or_default();
let customer_shipping_phone_number = json.string_of("customer.shipping.phoneNumber").unwrap_or_default();
let customer_shipping_email = json.string_of("customer.shipping.email").unwrap_or_default();
let customer_shipping_address_address1 = json.string_of("customer.shipping.address.address1").unwrap_or_default();
let customer_shipping_address_address2 = json.string_of("customer.shipping.address.address2").unwrap_or_default();
let customer_shipping_address_city = json.string_of("customer.shipping.address.city").unwrap_or_default();
let customer_shipping_address_county = json.string_of("customer.shipping.address.county").unwrap_or_default();
let customer_shipping_address_state = json.string_of("customer.shipping.address.state").unwrap_or_default();
let customer_shipping_address_postal_code = json.string_of("customer.shipping.address.postalCode").unwrap_or_default();
let customer_shipping_address_country = json.string_of("customer.shipping.address.country").unwrap_or_default();
let customer_billing_first_name = json.string_of("customer.billing.firstName").unwrap_or_default();
let customer_billing_last_name = json.string_of("customer.billing.lastName").unwrap_or_default();
let customer_billing_full_name = json.string_of("customer.billing.fullName").unwrap_or_default();
let customer_billing_phone_number = json.string_of("customer.billing.phoneNumber").unwrap_or_default();
let customer_billing_email = json.string_of("customer.billing.email").unwrap_or_default();
let customer_billing_address_state = json.string_of("customer.billing.address.state").unwrap_or_default();
let customer_billing_address_postal_code = json.string_of("customer.billing.address.postalCode").unwrap_or_default();
let customer_billing_address_country = json.string_of("customer.billing.address.country").unwrap_or_default();
let upsell_upsell_original_receipt = json.string_of("upsell.upsellOriginalReceipt").unwrap_or_default();
let upsell_upsell_flow_id = json.int_of("upsell.upsellFlowId");
let upsell_upsell_session = json.string_of("upsell.upsellSession").unwrap_or_default();
let upsell_upsell_path = json.string_of("upsell.upsellPath").unwrap_or_default();
let hopfeed_hopfeed_click_id = json.string_of("hopfeed.hopfeedClickId").unwrap_or_default();
let hopfeed_hopfeed_application_id = json.int_of("hopfeed.hopfeedApplicationId");
let hopfeed_hopfeed_creative_id = json.int_of("hopfeed.hopfeedCreativeId");
let hopfeed_hopfeed_application_payout = json.string_of("hopfeed.hopfeedApplicationPayout").unwrap_or_default();
let hopfeed_hopfeed_vendor_payout = json.string_of("hopfeed.hopfeedVendorPayout").unwrap_or_default();
let version = json.string_of("version").unwrap_or_default();
let attempt_count = json.int_of("attemptCount");
let vendor_variables_v1 = json.string_of("vendorVariables.v1").unwrap_or_default();
let vendor_variables_v2 = json.string_of("vendorVariables.v2").unwrap_or_default();
i = 0;
count_i = json.size_of_array("trackingCodes");
while i < count_i {
json.set_i(i);
let _ = json.string_of("trackingCodes[i]").unwrap_or_default();
i = i + 1;
}
i = 0;
count_i = json.size_of_array("lineItems");
while i < count_i {
json.set_i(i);
let _ = json.string_of("lineItems[i].itemNo").unwrap_or_default();
let _ = json.string_of("lineItems[i].productTitle").unwrap_or_default();
let _ = json.bool_of("lineItems[i].shippable");
let _ = json.bool_of("lineItems[i].recurring");
let _ = json.string_of("lineItems[i].accountAmount").unwrap_or_default();
let _ = json.int_of("lineItems[i].quantity");
let _ = json.string_of("lineItems[i].downloadUrl").unwrap_or_default();
let _ = json.string_of("lineItems[i].lineItemType").unwrap_or_default();
i = i + 1;
}