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
(Visual FoxPro) Add order to a ShippingEasy accountAdds an order to a ShippingEasy account (calls the ShippingEasy REST API).
LOCAL lnSuccess LOCAL loJson LOCAL lcStoreApiKey LOCAL lcApiKey LOCAL lcApiSecret LOCAL loSbSigStr LOCAL loDt LOCAL loCrypt LOCAL loSbSignature LOCAL loSbUrl LOCAL loHttp LOCAL loResp * This requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * First create the JSON for the order. * See https://shippingeasy.readme.io/v1.0/docs/creating-a-signature * for sample JSON. * You may use the online tool at https://tools.chilkat.io/Default.cshtml to * generate the following code by pasting sample JSON into the tool. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.UpdateString("order.external_order_identifier","ABC-100") loJson.UpdateString("order.ordered_at","2014-01-16 14:37:56 -0600") loJson.UpdateString("order.order_status","awaiting_shipment") loJson.UpdateString("order.subtotal_including_tax","10.00") loJson.UpdateString("order.total_including_tax","10.00") loJson.UpdateString("order.total_excluding_tax","10.00") loJson.UpdateString("order.discount_amount","0.00") loJson.UpdateString("order.coupon_discount","1.00") loJson.UpdateString("order.subtotal_including_tax","0.00") loJson.UpdateString("order.subtotal_excluding_tax","0.00") loJson.UpdateString("order.subtotal_excluding_tax","0.00") loJson.UpdateString("order.subtotal_tax","0.00") loJson.UpdateString("order.total_tax","0") loJson.UpdateString("order.base_shipping_cost","0.00") loJson.UpdateString("order.shipping_cost_including_tax","0.00") loJson.UpdateString("order.shipping_cost_excluding_tax","0.00") loJson.UpdateString("order.shipping_cost_tax","0.00") loJson.UpdateString("order.base_handling_cost","0.00") loJson.UpdateString("order.handling_cost_excluding_tax","0.00") loJson.UpdateString("order.handling_cost_including_tax","0.00") loJson.UpdateString("order.handling_cost_tax","0.00") loJson.UpdateString("order.base_wrapping_cost","0.00") loJson.UpdateString("order.wrapping_cost_excluding_tax","0.00") loJson.UpdateString("order.wrapping_cost_including_tax","0.00") loJson.UpdateString("order.wrapping_cost_tax","0.00") loJson.UpdateString("order.notes","Please send promptly.") loJson.UpdateString("order.billing_company","Acme Inc.") loJson.UpdateString("order.billing_first_name","Fred") loJson.UpdateString("order.billing_last_name","Jones") loJson.UpdateString("order.billing_address","1234 Street") loJson.UpdateString("order.billing_address2","Suite 100") loJson.UpdateString("order.billing_city","Austin") loJson.UpdateString("order.billing_state","TX") loJson.UpdateString("order.billing_postal_code","78701") loJson.UpdateString("order.billing_country","USA") loJson.UpdateString("order.billing_phone_number","512-123-1234") loJson.UpdateString("order.billing_email","test@test.com") loJson.UpdateString("order.recipients[0].first_name","Colin") loJson.UpdateString("order.recipients[0].last_name","Homenick") loJson.UpdateString("order.recipients[0].company","Wintheiser-Hickle") loJson.UpdateString("order.recipients[0].email","charles.crona@okeefe.org") loJson.UpdateString("order.recipients[0].phone_number","637-481-6505") loJson.UpdateString("order.recipients[0].residential","true") loJson.UpdateString("order.recipients[0].address","21937 Adelbert Springs") loJson.UpdateString("order.recipients[0].address2","") loJson.UpdateString("order.recipients[0].province","") loJson.UpdateString("order.recipients[0].state","CT") loJson.UpdateString("order.recipients[0].city","Terryfurt") loJson.UpdateString("order.recipients[0].postal_code","93322") loJson.UpdateString("order.recipients[0].postal_code_plus_4","1234") loJson.UpdateString("order.recipients[0].country","Andorra") loJson.UpdateString("order.recipients[0].shipping_method","Ground") loJson.UpdateString("order.recipients[0].base_cost","10.00") loJson.UpdateString("order.recipients[0].cost_excluding_tax","10.00") loJson.UpdateString("order.recipients[0].cost_tax","0.00") loJson.UpdateString("order.recipients[0].base_handling_cost","0.00") loJson.UpdateString("order.recipients[0].handling_cost_excluding_tax","0.00") loJson.UpdateString("order.recipients[0].handling_cost_including_tax","0.00") loJson.UpdateString("order.recipients[0].handling_cost_tax","0.00") loJson.UpdateString("order.recipients[0].shipping_zone_id","123") loJson.UpdateString("order.recipients[0].shipping_zone_name","XYZ") loJson.UpdateString("order.recipients[0].items_total","1") loJson.UpdateString("order.recipients[0].items_shipped","0") loJson.UpdateString("order.recipients[0].line_items[0].item_name","Pencil Holder") loJson.UpdateString("order.recipients[0].line_items[0].sku","9876543") loJson.UpdateString("order.recipients[0].line_items[0].bin_picking_number","7") loJson.UpdateString("order.recipients[0].line_items[0].unit_price","1.30") loJson.UpdateString("order.recipients[0].line_items[0].total_excluding_tax","1.30") loJson.UpdateString("order.recipients[0].line_items[0].weight_in_ounces","10") loJson.UpdateString("order.recipients[0].line_items[0].product_options.pa_size","large") loJson.UpdateString("order.recipients[0].line_items[0].product_options.Colour","Blue") loJson.UpdateString("order.recipients[0].line_items[0].quantity","1") * Replace these values with your actual apiKey and apiSecret. * (These are not valid values..) lcStoreApiKey = "569dc30d267f2c4d1f85f9920b2bf9f4" lcApiKey = "f9a7c8ebdfd34beaf260d9b0296c7059" lcApiSecret = "d3e9f8737d7196b1271a725f89e2156672bc1d900a25e6e0c1364e2f7a20f605" * Our request will be sent to: * https://app.shippingeasy.com/api/stores/:store_api_key/orders * The path part of this request is: /api/stores/:store_api_key/orders * See https://shippingeasy.readme.io/v1.0/docs/authentication-signing-requests * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbSigStr = CreateObject('Chilkat.StringBuilder') loSbSigStr.Append("POST&/api/stores/") loSbSigStr.Append(lcStoreApiKey) loSbSigStr.Append("/orders&") loSbSigStr.Append("api_key=") loSbSigStr.Append(lcApiKey) loSbSigStr.Append("&api_timestamp=") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.CkDateTime') loDt = CreateObject('Chilkat.CkDateTime') loDt.SetFromCurrentSystemTime() loSbSigStr.Append(loDt.GetAsUnixTimeStr(0)) loSbSigStr.Append("&") loJson.EmitCompact = 1 loJson.EmitSb(loSbSigStr) * Calculate the HMAC-SHA256 of the API Signature String using the API Secret as the HMAC key. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Crypt2') loCrypt = CreateObject('Chilkat.Crypt2') loCrypt.MacAlgorithm = "hmac" loCrypt.EncodingMode = "hex" loCrypt.SetMacKeyString(lcApiSecret) loCrypt.HashAlgorithm = "sha256" * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbSignature = CreateObject('Chilkat.StringBuilder') loSbSignature.Append(loCrypt.MacStringENC(loSbSigStr.GetAsString())) loSbSignature.ToLowercase() * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbUrl = CreateObject('Chilkat.StringBuilder') loSbUrl.Append("https://app.shippingeasy.com/api/stores/") loSbUrl.Append(lcStoreApiKey) loSbUrl.Append("/orders?") loSbUrl.Append("api_key=") loSbUrl.Append(lcApiKey) loSbUrl.Append("&api_timestamp=") loSbUrl.Append(loDt.GetAsUnixTimeStr(0)) loSbUrl.Append("&api_signature=") loSbUrl.Append(loSbSignature.GetAsString()) * Send a POST equivalent the following curl request: * curl -H "Content-Type: application/json" --data @body.json "https://app.shippingeasy.com/api/stores/27aa472e16faa83dd13b7758d31974ed/orders? * api_key=f9a7c8ebdfd34beaf260d9b0296c7059& * api_timestamp=1401803554& * api_signature=c65f43beed46e581939898a78acd10064cfa146845e97885ec02124d7ad648e4" * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') loHttp.SessionLogFilename = "qa_output/shippingEasy.txt" loResp = loHttp.PostJson2(loSbUrl.GetAsString(),"application/json",loJson.Emit()) IF (loHttp.LastMethodSuccess <> 1) THEN ? loHttp.LastErrorText RELEASE loJson RELEASE loSbSigStr RELEASE loDt RELEASE loCrypt RELEASE loSbSignature RELEASE loSbUrl RELEASE loHttp CANCEL ENDIF ? "response status code = " + STR(loResp.StatusCode) ? "response body:" ? loResp.BodyStr RELEASE loResp RELEASE loJson RELEASE loSbSigStr RELEASE loDt RELEASE loCrypt RELEASE loSbSignature RELEASE loSbUrl RELEASE loHttp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.