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
 
      (Excel) Ecwid - Create OrderSee more Ecwid ExamplesCreate a new order in an Ecwid store. This can be useful for storefronts with a custom checkout process or manually creating orders for sales made earlier. For more information, see https://api-docs.ecwid.com/reference/orders#create-an-order 
 ' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. ' Create and send the following HTTP request: ' Load the access token previously obtained in Ecwid Get Access Token Dim jsonToken As Chilkat.JsonObject Set jsonToken = Chilkat.NewJsonObject Dim success As Boolean success = jsonToken.LoadFile("qa_data/tokens/ecwid.json") Dim sbUrl As Chilkat.StringBuilder Set sbUrl = Chilkat.NewStringBuilder success = sbUrl.Append("https://app.ecwid.com/api/v3/4870020/orders?token=") success = sbUrl.Append(jsonToken.StringOf("access_token")) ' POST /api/v3/4870020/orders?token=1234567890qwqeertt HTTP/1.1 ' Host: app.ecwid.com ' Content-Type: application/json;charset=utf-8 ' Cache-Control: no-cache ' ' { ' "subtotal": 30, ' "total": 40, ' "email": "example@example.com", ' "paymentMethod": "Phone order", ' "tax": 0, ' "paymentStatus": "PAID", ' "customerTaxExempt": false, ' "customerTaxId": "", ' "customerTaxIdValid": false, ' "reversedTaxApplied": false, ' "fulfillmentStatus": "AWAITING_PROCESSING", ' "createDate": "2015-09-20 19:59:43 +0000", ' "items": [ ' { ' "price": 15, ' "weight": 0.32, ' "sku": "00004", ' "quantity": 2, ' "name": "Cherry" ' } ' ], ' "billingPerson": { ' "name": "Eugene K", ' "companyName": "Hedgehog and Bucket", ' "street": "My Street", ' "city": "San Diego", ' "countryCode": "US", ' "postalCode": "90002", ' "stateOrProvinceCode": "CA", ' "phone": "123141321" ' }, ' "shippingPerson": { ' "name": "Eugene K", ' "companyName": "Hedgehog and Bucket", ' "street": "My Street", ' "city": "San Diego", ' "countryCode": "US", ' "postalCode": "90002", ' "stateOrProvinceCode": "CA", ' "phone": "123141321" ' }, ' "shippingOption": { ' "shippingMethodName": "Fast Delivery", ' "shippingRate": 10, ' "isPickup": false, ' "fulfilmentType": "DELIVERY" ' }, ' "hidden": false, ' "privateAdminNotes": "Must be delivered till Sunday.", ' "acceptMarketing": false, ' "disableAllCustomerNotifications": true, ' "externalFulfillment": true, ' "externalOrderId": "2", ' "pricesIncludeTax": false ' } Dim http As Chilkat.Http Set http = Chilkat.NewHttp http.SetRequestHeader "Cache-Control","no-cache" Dim json As Chilkat.JsonObject Set json = Chilkat.NewJsonObject success = json.UpdateInt("subtotal",30) success = json.UpdateInt("total",40) success = json.UpdateString("email","example@example.com") success = json.UpdateString("paymentMethod","Phone order") success = json.UpdateInt("tax",0) success = json.UpdateString("paymentStatus","PAID") success = json.UpdateBool("customerTaxExempt",False) success = json.UpdateString("customerTaxId","") success = json.UpdateBool("customerTaxIdValid",False) success = json.UpdateBool("reversedTaxApplied",False) success = json.UpdateString("fulfillmentStatus","AWAITING_PROCESSING") success = json.UpdateString("createDate","2015-09-20 19:59:43 +0000") success = json.UpdateInt("items[0].price",15) success = json.UpdateNumber("items[0].weight","0.32") success = json.UpdateString("items[0].sku","00004") success = json.UpdateInt("items[0].quantity",2) success = json.UpdateString("items[0].name","Cherry") success = json.UpdateString("billingPerson.name","Eugene K") success = json.UpdateString("billingPerson.companyName","Hedgehog and Bucket") success = json.UpdateString("billingPerson.street","My Street") success = json.UpdateString("billingPerson.city","San Diego") success = json.UpdateString("billingPerson.countryCode","US") success = json.UpdateString("billingPerson.postalCode","90002") success = json.UpdateString("billingPerson.stateOrProvinceCode","CA") success = json.UpdateString("billingPerson.phone","123141321") success = json.UpdateString("shippingPerson.name","Eugene K") success = json.UpdateString("shippingPerson.companyName","Hedgehog and Bucket") success = json.UpdateString("shippingPerson.street","My Street") success = json.UpdateString("shippingPerson.city","San Diego") success = json.UpdateString("shippingPerson.countryCode","US") success = json.UpdateString("shippingPerson.postalCode","90002") success = json.UpdateString("shippingPerson.stateOrProvinceCode","CA") success = json.UpdateString("shippingPerson.phone","123141321") success = json.UpdateString("shippingOption.shippingMethodName","Fast Delivery") success = json.UpdateInt("shippingOption.shippingRate",10) success = json.UpdateBool("shippingOption.isPickup",False) success = json.UpdateString("shippingOption.fulfilmentType","DELIVERY") success = json.UpdateBool("hidden",False) success = json.UpdateString("privateAdminNotes","Must be delivered till Sunday.") success = json.UpdateBool("acceptMarketing",False) success = json.UpdateBool("disableAllCustomerNotifications",True) success = json.UpdateBool("externalFulfillment",True) success = json.UpdateString("externalOrderId","2") success = json.UpdateBool("pricesIncludeTax",False) Set resp = http.PostJson3(sbUrl.GetAsString(),"application/json",json) If (http.LastMethodSuccess <> True) Then Debug.Print http.LastErrorText Exit Sub End If Debug.Print "Response status code = "; resp.StatusCode Dim sbResponseBody As Chilkat.StringBuilder Set sbResponseBody = Chilkat.NewStringBuilder success = resp.GetBodySb(sbResponseBody) Dim jResp As Chilkat.JsonObject Set jResp = Chilkat.NewJsonObject success = jResp.LoadSb(sbResponseBody) jResp.EmitCompact = False Debug.Print "Response Body:" Debug.Print jResp.Emit() ' Sample JSON response: ' (Sample code for parsing the JSON response is shown below) ' { ' "id": 20, ' "orderid": "XJ12H" ' } ' Sample code for parsing the JSON response... ' Use the following online tool to generate parsing code from sample JSON: ' Generate Parsing Code from JSON id = jResp.IntOf("id") orderid = jResp.StringOf("orderid")  | 
  ||||
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.