Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Calculate a X_RISKIFIED_HMAC_SHA256 for riskified.com API CallsDemonstrates how to calculate the value for the X_RISKIFIED_HMAC_SHA256 header for riskified.com HTTP requests (REST API calls).
Use ChilkatAx-win32.pkg Procedure Test Handle hoJson Boolean iSuccess String sJsonBody Handle hoCrypt String sHmacHexStr Handle hoSbHmacHex String sTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Create the JSON that is to be the body of the HTTP request. // The JSON created by this code is shown at the bottom of this example. // // The JSON Code Generator at http://tools.chilkat.io/ can be used // to generate the following code from sample JSON. Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateNull Of hoJson "order.cancel_reason" To iSuccess Get ComUpdateNull Of hoJson "order.cancelled_at" To iSuccess Get ComUpdateString Of hoJson "order.cart_token" "68778783ad298f1c80c3bafcddeea02f" To iSuccess Get ComUpdateNull Of hoJson "order.closed_at" To iSuccess Get ComUpdateString Of hoJson "order.created_at" "2008-01-10T11:00:00-05:00" To iSuccess Get ComUpdateString Of hoJson "order.currency" "USD" To iSuccess Get ComUpdateString Of hoJson "order.email" "bob.norman@hostmail.com" To iSuccess Get ComUpdateString Of hoJson "order.gateway" "authorize_net" To iSuccess Get ComUpdateNumber Of hoJson "order.id" "450789469" To iSuccess Get ComUpdateString Of hoJson "order.total_discounts" "0.00" To iSuccess Get ComUpdateString Of hoJson "order.total_price" "409.94" To iSuccess Get ComUpdateString Of hoJson "order.updated_at" "2008-01-10T11:00:00-05:00" To iSuccess Get ComUpdateString Of hoJson "order.note" "some note made by the shop’s stuff member" To iSuccess Get ComUpdateNull Of hoJson "order.browser_ip" To iSuccess Get ComUpdateString Of hoJson "order.discount_codes[0].amount" "10.00" To iSuccess Get ComUpdateString Of hoJson "order.discount_codes[0].code" "TENOFF" To iSuccess Get ComUpdateString Of hoJson "order.line_items[0].title" "IPod Nano - 8gb - green" To iSuccess Get ComUpdateNumber Of hoJson "order.line_items[0].price" "199.00" To iSuccess Get ComUpdateNumber Of hoJson "order.line_items[0].product_id" "632910392" To iSuccess Get ComUpdateNumber Of hoJson "order.line_items[0].quantity" "1" To iSuccess Get ComUpdateString Of hoJson "order.line_items[0].sku" "IPOD2008GREEN" To iSuccess Get ComUpdateString Of hoJson "order.shipping_lines[0].code" "Free Shipping" To iSuccess Get ComUpdateString Of hoJson "order.shipping_lines[0].price" "0.00" To iSuccess Get ComUpdateString Of hoJson "order.shipping_lines[0].title" "Free Shipping" To iSuccess Get ComUpdateNull Of hoJson "order.payment_details.avs_result_code" To iSuccess Get ComUpdateNull Of hoJson "order.payment_details.credit_card_bin" To iSuccess Get ComUpdateString Of hoJson "order.payment_details.credit_card_company" "Visa" To iSuccess Get ComUpdateString Of hoJson "order.payment_details.credit_card_number" "XXXX-XXXX-XXXX-4242" To iSuccess Get ComUpdateNull Of hoJson "order.payment_details.cvv_result_code" To iSuccess Get ComUpdateString Of hoJson "order.payment_details.authorization_id" "RK346IK124" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.address1" "Chestnut Street 92" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.address2" "" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.city" "Louisville" To iSuccess Get ComUpdateNull Of hoJson "order.billing_address.company" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.country" "United States" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.country_code" "US" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.first_name" "Bob" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.last_name" "Norman" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.name" "Bob Norman" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.phone" "555-625-1199" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.province" "Kentucky" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.province_code" "KY" To iSuccess Get ComUpdateString Of hoJson "order.billing_address.zip" "40202" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.address1" "Chestnut Street 92" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.address2" "" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.city" "Louisville" To iSuccess Get ComUpdateNull Of hoJson "order.shipping_address.company" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.country" "United States" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.country_code" "US" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.first_name" "Bob" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.last_name" "Norman" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.name" "Bob Norman" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.phone" "555-625-1199" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.province" "Kentucky" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.province_code" "KY" To iSuccess Get ComUpdateString Of hoJson "order.shipping_address.zip" "40202" To iSuccess Get ComUpdateString Of hoJson "order.customer.created_at" "2013-04-23T13:36:50-04:00" To iSuccess Get ComUpdateString Of hoJson "order.customer.email" "bob.norman@hostmail.com" To iSuccess Get ComUpdateString Of hoJson "order.customer.first_name" "Bob" To iSuccess Get ComUpdateNumber Of hoJson "order.customer.id" "207119551" To iSuccess Get ComUpdateString Of hoJson "order.customer.last_name" "Norman" To iSuccess Get ComUpdateNull Of hoJson "order.customer.note" To iSuccess Get ComUpdateNumber Of hoJson "order.customer.orders_count" "0" To iSuccess Get ComUpdateBool Of hoJson "order.customer.verified_email" True To iSuccess // Emit the JSON in compact format.. Set ComEmitCompact Of hoJson To True // Get the JSON that will be HMAC'd and will also be the contents of the HTTP request body. Get ComEmit Of hoJson To sJsonBody Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt If (Not(IsComObjectCreated(hoCrypt))) Begin Send CreateComObject of hoCrypt End Set ComEncodingMode Of hoCrypt To "hex" Set ComHashAlgorithm Of hoCrypt To "sha256" Set ComMacAlgorithm Of hoCrypt To "hmac" Get ComSetMacKeyString Of hoCrypt "55fe0f4d4023bbdfbc124cabd88bf9bb" To iSuccess Get ComMacStringENC Of hoCrypt sJsonBody To sHmacHexStr Get ComLastMethodSuccess Of hoCrypt To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoCrypt To sTemp1 Showln sTemp1 Procedure_Return End // We need a lowercase hmacHexStr... Get Create (RefClass(cComChilkatStringBuilder)) To hoSbHmacHex If (Not(IsComObjectCreated(hoSbHmacHex))) Begin Send CreateComObject of hoSbHmacHex End Get ComAppend Of hoSbHmacHex sHmacHexStr To iSuccess Get ComToLowercase Of hoSbHmacHex To iSuccess Get ComGetAsString Of hoSbHmacHex To sHmacHexStr Showln "The value of the X_RISKIFIED_HMAC_SHA256 should be: " sHmacHexStr // This example is only to show the HMAC SHA256 calculation. // See examples of sending REST requests to riskified.com at http://rest-examples.chilkat.io/riskified/default.cshtml // ---------------------------------------------- // This is the JSON created by the above code.. // { // "order": { // "cancel_reason": null, // "cancelled_at": null, // "cart_token": "68778783ad298f1c80c3bafcddeea02f", // "closed_at": null, // "created_at": "2008-01-10T11:00:00-05:00", // "currency": "USD", // "email": "bob.norman@hostmail.com", // "gateway": "authorize_net", // "id": 450789469, // "total_discounts": "0.00", // "total_price": "409.94", // "updated_at": "2008-01-10T11:00:00-05:00", // "note": "some note made by the shop’s stuff member", // "browser_ip": null, // "discount_codes": [ // { // "amount": "10.00", // "code": "TENOFF" // } // ], // "line_items": [ // { // "title": "IPod Nano - 8gb - green", // "price": 199.00, // "product_id": 632910392, // "quantity": 1, // "sku": "IPOD2008GREEN" // } // ], // "shipping_lines": [ // { // "code": "Free Shipping", // "price": "0.00", // "title": "Free Shipping" // } // ], // "payment_details": { // "avs_result_code": null, // "credit_card_bin": null, // "credit_card_company": "Visa", // "credit_card_number": "XXXX-XXXX-XXXX-4242", // "cvv_result_code": null, // "authorization_id": "RK346IK124" // }, // "billing_address": { // "address1": "Chestnut Street 92", // "address2": "", // "city": "Louisville", // "company": null, // "country": "United States", // "country_code": "US", // "first_name": "Bob", // "last_name": "Norman", // "name": "Bob Norman", // "phone": "555-625-1199", // "province": "Kentucky", // "province_code": "KY", // "zip": "40202" // }, // "shipping_address": { // "address1": "Chestnut Street 92", // "address2": "", // "city": "Louisville", // "company": null, // "country": "United States", // "country_code": "US", // "first_name": "Bob", // "last_name": "Norman", // "name": "Bob Norman", // "phone": "555-625-1199", // "province": "Kentucky", // "province_code": "KY", // "zip": "40202" // }, // "customer": { // "created_at": "2013-04-23T13:36:50-04:00", // "email": "bob.norman@hostmail.com", // "first_name": "Bob", // "id": 207119551, // "last_name": "Norman", // "note": null, // "orders_count": 0, // "verified_email": true // } // } // } End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.