Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Ecwid - Create Order

See more Ecwid Examples

Create 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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

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.