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
(PowerBuilder) 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
integer li_rc oleobject loo_JsonToken oleobject loo_SbUrl oleobject loo_Http oleobject loo_Json oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_Id string ls_Orderid // 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 loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") if li_rc < 0 then destroy loo_JsonToken MessageBox("Error","Connecting to COM object failed") return end if loo_JsonToken.LoadFile("qa_data/tokens/ecwid.json") loo_SbUrl = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbUrl.ConnectToNewObject("Chilkat.StringBuilder") loo_SbUrl.Append("https://app.ecwid.com/api/v3/4870020/orders?token=") loo_SbUrl.Append(loo_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 // } loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") loo_Http.SetRequestHeader("Cache-Control","no-cache") loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateInt("subtotal",30) loo_Json.UpdateInt("total",40) loo_Json.UpdateString("email","example@example.com") loo_Json.UpdateString("paymentMethod","Phone order") loo_Json.UpdateInt("tax",0) loo_Json.UpdateString("paymentStatus","PAID") loo_Json.UpdateBool("customerTaxExempt",0) loo_Json.UpdateString("customerTaxId","") loo_Json.UpdateBool("customerTaxIdValid",0) loo_Json.UpdateBool("reversedTaxApplied",0) loo_Json.UpdateString("fulfillmentStatus","AWAITING_PROCESSING") loo_Json.UpdateString("createDate","2015-09-20 19:59:43 +0000") loo_Json.UpdateInt("items[0].price",15) loo_Json.UpdateNumber("items[0].weight","0.32") loo_Json.UpdateString("items[0].sku","00004") loo_Json.UpdateInt("items[0].quantity",2) loo_Json.UpdateString("items[0].name","Cherry") loo_Json.UpdateString("billingPerson.name","Eugene K") loo_Json.UpdateString("billingPerson.companyName","Hedgehog and Bucket") loo_Json.UpdateString("billingPerson.street","My Street") loo_Json.UpdateString("billingPerson.city","San Diego") loo_Json.UpdateString("billingPerson.countryCode","US") loo_Json.UpdateString("billingPerson.postalCode","90002") loo_Json.UpdateString("billingPerson.stateOrProvinceCode","CA") loo_Json.UpdateString("billingPerson.phone","123141321") loo_Json.UpdateString("shippingPerson.name","Eugene K") loo_Json.UpdateString("shippingPerson.companyName","Hedgehog and Bucket") loo_Json.UpdateString("shippingPerson.street","My Street") loo_Json.UpdateString("shippingPerson.city","San Diego") loo_Json.UpdateString("shippingPerson.countryCode","US") loo_Json.UpdateString("shippingPerson.postalCode","90002") loo_Json.UpdateString("shippingPerson.stateOrProvinceCode","CA") loo_Json.UpdateString("shippingPerson.phone","123141321") loo_Json.UpdateString("shippingOption.shippingMethodName","Fast Delivery") loo_Json.UpdateInt("shippingOption.shippingRate",10) loo_Json.UpdateBool("shippingOption.isPickup",0) loo_Json.UpdateString("shippingOption.fulfilmentType","DELIVERY") loo_Json.UpdateBool("hidden",0) loo_Json.UpdateString("privateAdminNotes","Must be delivered till Sunday.") loo_Json.UpdateBool("acceptMarketing",0) loo_Json.UpdateBool("disableAllCustomerNotifications",1) loo_Json.UpdateBool("externalFulfillment",1) loo_Json.UpdateString("externalOrderId","2") loo_Json.UpdateBool("pricesIncludeTax",0) loo_Resp = loo_Http.PostJson3(loo_SbUrl.GetAsString(),"application/json",loo_Json) if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_JsonToken destroy loo_SbUrl destroy loo_Http destroy loo_Json return end if Write-Debug "Response status code = " + string(loo_Resp.StatusCode) loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_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 li_Id = loo_JResp.IntOf("id") ls_Orderid = loo_JResp.StringOf("orderid") destroy loo_Resp destroy loo_JsonToken destroy loo_SbUrl destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.