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