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) 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
LOCAL loJsonToken LOCAL loSbUrl LOCAL loHttp LOCAL loJson LOCAL loResp LOCAL loSbResponseBody LOCAL loJResp LOCAL lnId LOCAL lcOrderid * 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 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonToken = CreateObject('Chilkat.JsonObject') loJsonToken.LoadFile("qa_data/tokens/ecwid.json") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbUrl = CreateObject('Chilkat.StringBuilder') loSbUrl.Append("https://app.ecwid.com/api/v3/4870020/orders?token=") loSbUrl.Append(loJsonToken.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 * } * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') loHttp.SetRequestHeader("Cache-Control","no-cache") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.UpdateInt("subtotal",30) loJson.UpdateInt("total",40) loJson.UpdateString("email","example@example.com") loJson.UpdateString("paymentMethod","Phone order") loJson.UpdateInt("tax",0) loJson.UpdateString("paymentStatus","PAID") loJson.UpdateBool("customerTaxExempt",0) loJson.UpdateString("customerTaxId","") loJson.UpdateBool("customerTaxIdValid",0) loJson.UpdateBool("reversedTaxApplied",0) loJson.UpdateString("fulfillmentStatus","AWAITING_PROCESSING") loJson.UpdateString("createDate","2015-09-20 19:59:43 +0000") loJson.UpdateInt("items[0].price",15) loJson.UpdateNumber("items[0].weight","0.32") loJson.UpdateString("items[0].sku","00004") loJson.UpdateInt("items[0].quantity",2) loJson.UpdateString("items[0].name","Cherry") loJson.UpdateString("billingPerson.name","Eugene K") loJson.UpdateString("billingPerson.companyName","Hedgehog and Bucket") loJson.UpdateString("billingPerson.street","My Street") loJson.UpdateString("billingPerson.city","San Diego") loJson.UpdateString("billingPerson.countryCode","US") loJson.UpdateString("billingPerson.postalCode","90002") loJson.UpdateString("billingPerson.stateOrProvinceCode","CA") loJson.UpdateString("billingPerson.phone","123141321") loJson.UpdateString("shippingPerson.name","Eugene K") loJson.UpdateString("shippingPerson.companyName","Hedgehog and Bucket") loJson.UpdateString("shippingPerson.street","My Street") loJson.UpdateString("shippingPerson.city","San Diego") loJson.UpdateString("shippingPerson.countryCode","US") loJson.UpdateString("shippingPerson.postalCode","90002") loJson.UpdateString("shippingPerson.stateOrProvinceCode","CA") loJson.UpdateString("shippingPerson.phone","123141321") loJson.UpdateString("shippingOption.shippingMethodName","Fast Delivery") loJson.UpdateInt("shippingOption.shippingRate",10) loJson.UpdateBool("shippingOption.isPickup",0) loJson.UpdateString("shippingOption.fulfilmentType","DELIVERY") loJson.UpdateBool("hidden",0) loJson.UpdateString("privateAdminNotes","Must be delivered till Sunday.") loJson.UpdateBool("acceptMarketing",0) loJson.UpdateBool("disableAllCustomerNotifications",1) loJson.UpdateBool("externalFulfillment",1) loJson.UpdateString("externalOrderId","2") loJson.UpdateBool("pricesIncludeTax",0) loResp = loHttp.PostJson3(loSbUrl.GetAsString(),"application/json",loJson) IF (loHttp.LastMethodSuccess <> 1) THEN ? loHttp.LastErrorText RELEASE loJsonToken RELEASE loSbUrl RELEASE loHttp RELEASE loJson CANCEL ENDIF ? "Response status code = " + STR(loResp.StatusCode) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') loResp.GetBodySb(loSbResponseBody) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.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 lnId = loJResp.IntOf("id") lcOrderid = loJResp.StringOf("orderid") RELEASE loResp RELEASE loJsonToken RELEASE loSbUrl RELEASE loHttp RELEASE loJson RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.