Delphi DLL
Delphi DLL
ClickBank Parse Instant Notification JSON
See more ClickBank Examples
Demonstrates how to parse the JSON of a ClickBank instant notification.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, JsonObject;
...
procedure TForm1.Button1Click(Sender: TObject);
var
json: HCkJsonObject;
transactionTime: PWideChar;
receipt: PWideChar;
transactionType: PWideChar;
vendor: PWideChar;
affiliate: PWideChar;
role: PWideChar;
totalAccountAmount: PWideChar;
paymentMethod: PWideChar;
totalOrderAmount: PWideChar;
totalTaxAmount: PWideChar;
totalShippingAmount: PWideChar;
currency: PWideChar;
orderLanguage: PWideChar;
customerShippingFirstName: PWideChar;
customerShippingLastName: PWideChar;
customerShippingFullName: PWideChar;
customerShippingPhoneNumber: PWideChar;
customerShippingEmail: PWideChar;
customerShippingAddressAddress1: PWideChar;
customerShippingAddressAddress2: PWideChar;
customerShippingAddressCity: PWideChar;
customerShippingAddressCounty: PWideChar;
customerShippingAddressState: PWideChar;
customerShippingAddressPostalCode: PWideChar;
customerShippingAddressCountry: PWideChar;
customerBillingFirstName: PWideChar;
customerBillingLastName: PWideChar;
customerBillingFullName: PWideChar;
customerBillingPhoneNumber: PWideChar;
customerBillingEmail: PWideChar;
customerBillingAddressState: PWideChar;
customerBillingAddressPostalCode: PWideChar;
customerBillingAddressCountry: PWideChar;
upsellUpsellOriginalReceipt: PWideChar;
upsellUpsellFlowId: Integer;
upsellUpsellSession: PWideChar;
upsellUpsellPath: PWideChar;
hopfeedHopfeedClickId: PWideChar;
hopfeedHopfeedApplicationId: Integer;
hopfeedHopfeedCreativeId: Integer;
hopfeedHopfeedApplicationPayout: PWideChar;
hopfeedHopfeedVendorPayout: PWideChar;
version: PWideChar;
attemptCount: Integer;
vendorVariablesV1: PWideChar;
vendorVariablesV2: PWideChar;
i: Integer;
count_i: Integer;
strVal: PWideChar;
itemNo: PWideChar;
productTitle: PWideChar;
shippable: Boolean;
recurring: Boolean;
accountAmount: PWideChar;
quantity: Integer;
downloadUrl: PWideChar;
lineItemType: PWideChar;
begin
json := CkJsonObject_Create();
CkJsonObject_Load(json,'{ ... }');
// 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"
// }
// }
//
//
transactionTime := CkJsonObject__stringOf(json,'transactionTime');
receipt := CkJsonObject__stringOf(json,'receipt');
transactionType := CkJsonObject__stringOf(json,'transactionType');
vendor := CkJsonObject__stringOf(json,'vendor');
affiliate := CkJsonObject__stringOf(json,'affiliate');
role := CkJsonObject__stringOf(json,'role');
totalAccountAmount := CkJsonObject__stringOf(json,'totalAccountAmount');
paymentMethod := CkJsonObject__stringOf(json,'paymentMethod');
totalOrderAmount := CkJsonObject__stringOf(json,'totalOrderAmount');
totalTaxAmount := CkJsonObject__stringOf(json,'totalTaxAmount');
totalShippingAmount := CkJsonObject__stringOf(json,'totalShippingAmount');
currency := CkJsonObject__stringOf(json,'currency');
orderLanguage := CkJsonObject__stringOf(json,'orderLanguage');
customerShippingFirstName := CkJsonObject__stringOf(json,'customer.shipping.firstName');
customerShippingLastName := CkJsonObject__stringOf(json,'customer.shipping.lastName');
customerShippingFullName := CkJsonObject__stringOf(json,'customer.shipping.fullName');
customerShippingPhoneNumber := CkJsonObject__stringOf(json,'customer.shipping.phoneNumber');
customerShippingEmail := CkJsonObject__stringOf(json,'customer.shipping.email');
customerShippingAddressAddress1 := CkJsonObject__stringOf(json,'customer.shipping.address.address1');
customerShippingAddressAddress2 := CkJsonObject__stringOf(json,'customer.shipping.address.address2');
customerShippingAddressCity := CkJsonObject__stringOf(json,'customer.shipping.address.city');
customerShippingAddressCounty := CkJsonObject__stringOf(json,'customer.shipping.address.county');
customerShippingAddressState := CkJsonObject__stringOf(json,'customer.shipping.address.state');
customerShippingAddressPostalCode := CkJsonObject__stringOf(json,'customer.shipping.address.postalCode');
customerShippingAddressCountry := CkJsonObject__stringOf(json,'customer.shipping.address.country');
customerBillingFirstName := CkJsonObject__stringOf(json,'customer.billing.firstName');
customerBillingLastName := CkJsonObject__stringOf(json,'customer.billing.lastName');
customerBillingFullName := CkJsonObject__stringOf(json,'customer.billing.fullName');
customerBillingPhoneNumber := CkJsonObject__stringOf(json,'customer.billing.phoneNumber');
customerBillingEmail := CkJsonObject__stringOf(json,'customer.billing.email');
customerBillingAddressState := CkJsonObject__stringOf(json,'customer.billing.address.state');
customerBillingAddressPostalCode := CkJsonObject__stringOf(json,'customer.billing.address.postalCode');
customerBillingAddressCountry := CkJsonObject__stringOf(json,'customer.billing.address.country');
upsellUpsellOriginalReceipt := CkJsonObject__stringOf(json,'upsell.upsellOriginalReceipt');
upsellUpsellFlowId := CkJsonObject_IntOf(json,'upsell.upsellFlowId');
upsellUpsellSession := CkJsonObject__stringOf(json,'upsell.upsellSession');
upsellUpsellPath := CkJsonObject__stringOf(json,'upsell.upsellPath');
hopfeedHopfeedClickId := CkJsonObject__stringOf(json,'hopfeed.hopfeedClickId');
hopfeedHopfeedApplicationId := CkJsonObject_IntOf(json,'hopfeed.hopfeedApplicationId');
hopfeedHopfeedCreativeId := CkJsonObject_IntOf(json,'hopfeed.hopfeedCreativeId');
hopfeedHopfeedApplicationPayout := CkJsonObject__stringOf(json,'hopfeed.hopfeedApplicationPayout');
hopfeedHopfeedVendorPayout := CkJsonObject__stringOf(json,'hopfeed.hopfeedVendorPayout');
version := CkJsonObject__stringOf(json,'version');
attemptCount := CkJsonObject_IntOf(json,'attemptCount');
vendorVariablesV1 := CkJsonObject__stringOf(json,'vendorVariables.v1');
vendorVariablesV2 := CkJsonObject__stringOf(json,'vendorVariables.v2');
i := 0;
count_i := CkJsonObject_SizeOfArray(json,'trackingCodes');
while i < count_i do
begin
CkJsonObject_putI(json,i);
strVal := CkJsonObject__stringOf(json,'trackingCodes[i]');
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(json,'lineItems');
while i < count_i do
begin
CkJsonObject_putI(json,i);
itemNo := CkJsonObject__stringOf(json,'lineItems[i].itemNo');
productTitle := CkJsonObject__stringOf(json,'lineItems[i].productTitle');
shippable := CkJsonObject_BoolOf(json,'lineItems[i].shippable');
recurring := CkJsonObject_BoolOf(json,'lineItems[i].recurring');
accountAmount := CkJsonObject__stringOf(json,'lineItems[i].accountAmount');
quantity := CkJsonObject_IntOf(json,'lineItems[i].quantity');
downloadUrl := CkJsonObject__stringOf(json,'lineItems[i].downloadUrl');
lineItemType := CkJsonObject__stringOf(json,'lineItems[i].lineItemType');
i := i + 1;
end;
CkJsonObject_Dispose(json);
end;