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) 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
Use ChilkatAx-win32.pkg Procedure Test Handle hoJsonToken Boolean iSuccess Handle hoSbUrl Handle hoHttp Variant vJson Handle hoJson Variant vResp Handle hoResp Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iId String sOrderid String sTemp1 Integer iTemp1 Boolean bTemp1 // 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 Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken If (Not(IsComObjectCreated(hoJsonToken))) Begin Send CreateComObject of hoJsonToken End Get ComLoadFile Of hoJsonToken "qa_data/tokens/ecwid.json" To iSuccess Get Create (RefClass(cComChilkatStringBuilder)) To hoSbUrl If (Not(IsComObjectCreated(hoSbUrl))) Begin Send CreateComObject of hoSbUrl End Get ComAppend Of hoSbUrl "https://app.ecwid.com/api/v3/4870020/orders?token=" To iSuccess Get ComStringOf Of hoJsonToken "access_token" To sTemp1 Get ComAppend Of hoSbUrl sTemp1 To iSuccess // 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 // } Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Send ComSetRequestHeader To hoHttp "Cache-Control" "no-cache" Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateInt Of hoJson "subtotal" 30 To iSuccess Get ComUpdateInt Of hoJson "total" 40 To iSuccess Get ComUpdateString Of hoJson "email" "example@example.com" To iSuccess Get ComUpdateString Of hoJson "paymentMethod" "Phone order" To iSuccess Get ComUpdateInt Of hoJson "tax" 0 To iSuccess Get ComUpdateString Of hoJson "paymentStatus" "PAID" To iSuccess Get ComUpdateBool Of hoJson "customerTaxExempt" False To iSuccess Get ComUpdateString Of hoJson "customerTaxId" "" To iSuccess Get ComUpdateBool Of hoJson "customerTaxIdValid" False To iSuccess Get ComUpdateBool Of hoJson "reversedTaxApplied" False To iSuccess Get ComUpdateString Of hoJson "fulfillmentStatus" "AWAITING_PROCESSING" To iSuccess Get ComUpdateString Of hoJson "createDate" "2015-09-20 19:59:43 +0000" To iSuccess Get ComUpdateInt Of hoJson "items[0].price" 15 To iSuccess Get ComUpdateNumber Of hoJson "items[0].weight" "0.32" To iSuccess Get ComUpdateString Of hoJson "items[0].sku" "00004" To iSuccess Get ComUpdateInt Of hoJson "items[0].quantity" 2 To iSuccess Get ComUpdateString Of hoJson "items[0].name" "Cherry" To iSuccess Get ComUpdateString Of hoJson "billingPerson.name" "Eugene K" To iSuccess Get ComUpdateString Of hoJson "billingPerson.companyName" "Hedgehog and Bucket" To iSuccess Get ComUpdateString Of hoJson "billingPerson.street" "My Street" To iSuccess Get ComUpdateString Of hoJson "billingPerson.city" "San Diego" To iSuccess Get ComUpdateString Of hoJson "billingPerson.countryCode" "US" To iSuccess Get ComUpdateString Of hoJson "billingPerson.postalCode" "90002" To iSuccess Get ComUpdateString Of hoJson "billingPerson.stateOrProvinceCode" "CA" To iSuccess Get ComUpdateString Of hoJson "billingPerson.phone" "123141321" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.name" "Eugene K" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.companyName" "Hedgehog and Bucket" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.street" "My Street" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.city" "San Diego" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.countryCode" "US" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.postalCode" "90002" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.stateOrProvinceCode" "CA" To iSuccess Get ComUpdateString Of hoJson "shippingPerson.phone" "123141321" To iSuccess Get ComUpdateString Of hoJson "shippingOption.shippingMethodName" "Fast Delivery" To iSuccess Get ComUpdateInt Of hoJson "shippingOption.shippingRate" 10 To iSuccess Get ComUpdateBool Of hoJson "shippingOption.isPickup" False To iSuccess Get ComUpdateString Of hoJson "shippingOption.fulfilmentType" "DELIVERY" To iSuccess Get ComUpdateBool Of hoJson "hidden" False To iSuccess Get ComUpdateString Of hoJson "privateAdminNotes" "Must be delivered till Sunday." To iSuccess Get ComUpdateBool Of hoJson "acceptMarketing" False To iSuccess Get ComUpdateBool Of hoJson "disableAllCustomerNotifications" True To iSuccess Get ComUpdateBool Of hoJson "externalFulfillment" True To iSuccess Get ComUpdateString Of hoJson "externalOrderId" "2" To iSuccess Get ComUpdateBool Of hoJson "pricesIncludeTax" False To iSuccess Get ComGetAsString Of hoSbUrl To sTemp1 Get pvComObject of hoJson to vJson Get ComPostJson3 Of hoHttp sTemp1 "application/json" vJson To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComStatusCode Of hoResp To iTemp1 Showln "Response status code = " iTemp1 Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess Get Create (RefClass(cComChilkatJsonObject)) To hoJResp If (Not(IsComObjectCreated(hoJResp))) Begin Send CreateComObject of hoJResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess Set ComEmitCompact Of hoJResp To False Showln "Response Body:" Get ComEmit Of hoJResp To sTemp1 Showln sTemp1 // 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 Get ComIntOf Of hoJResp "id" To iId Get ComStringOf Of hoJResp "orderid" To sOrderid Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.