Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) ClickBank Parse Instant Notification JSONDemonstrates how to parse the JSON of a ClickBank instant notification.
#include <CkJsonObject.h> void ChilkatSample(void) { CkString strOut; CkJsonObject json; 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" // } // } // // const char *transactionTime = 0; const char *receipt = 0; const char *transactionType = 0; const char *vendor = 0; const char *affiliate = 0; const char *role = 0; const char *totalAccountAmount = 0; const char *paymentMethod = 0; const char *totalOrderAmount = 0; const char *totalTaxAmount = 0; const char *totalShippingAmount = 0; const char *currency = 0; const char *orderLanguage = 0; const char *customerShippingFirstName = 0; const char *customerShippingLastName = 0; const char *customerShippingFullName = 0; const char *customerShippingPhoneNumber = 0; const char *customerShippingEmail = 0; const char *customerShippingAddressAddress1 = 0; const char *customerShippingAddressAddress2 = 0; const char *customerShippingAddressCity = 0; const char *customerShippingAddressCounty = 0; const char *customerShippingAddressState = 0; const char *customerShippingAddressPostalCode = 0; const char *customerShippingAddressCountry = 0; const char *customerBillingFirstName = 0; const char *customerBillingLastName = 0; const char *customerBillingFullName = 0; const char *customerBillingPhoneNumber = 0; const char *customerBillingEmail = 0; const char *customerBillingAddressState = 0; const char *customerBillingAddressPostalCode = 0; const char *customerBillingAddressCountry = 0; const char *upsellUpsellOriginalReceipt = 0; int upsellUpsellFlowId; const char *upsellUpsellSession = 0; const char *upsellUpsellPath = 0; const char *hopfeedHopfeedClickId = 0; int hopfeedHopfeedApplicationId; int hopfeedHopfeedCreativeId; const char *hopfeedHopfeedApplicationPayout = 0; const char *hopfeedHopfeedVendorPayout = 0; const char *version = 0; int attemptCount; const char *vendorVariablesV1 = 0; const char *vendorVariablesV2 = 0; int i; int count_i; const char *strVal = 0; const char *itemNo = 0; const char *productTitle = 0; bool shippable; bool recurring; const char *accountAmount = 0; int quantity; const char *downloadUrl = 0; const char *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"); upsellUpsellSession = json.stringOf("upsell.upsellSession"); upsellUpsellPath = json.stringOf("upsell.upsellPath"); hopfeedHopfeedClickId = json.stringOf("hopfeed.hopfeedClickId"); hopfeedHopfeedApplicationId = json.IntOf("hopfeed.hopfeedApplicationId"); hopfeedHopfeedCreativeId = json.IntOf("hopfeed.hopfeedCreativeId"); hopfeedHopfeedApplicationPayout = json.stringOf("hopfeed.hopfeedApplicationPayout"); hopfeedHopfeedVendorPayout = json.stringOf("hopfeed.hopfeedVendorPayout"); version = json.stringOf("version"); attemptCount = json.IntOf("attemptCount"); vendorVariablesV1 = json.stringOf("vendorVariables.v1"); vendorVariablesV2 = json.stringOf("vendorVariables.v2"); i = 0; count_i = json.SizeOfArray("trackingCodes"); while (i < count_i) { json.put_I(i); strVal = json.stringOf("trackingCodes[i]"); i = i + 1; } i = 0; count_i = json.SizeOfArray("lineItems"); while (i < count_i) { json.put_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; } SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.