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

VBScript Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(VBScript) Add order to a ShippingEasy account

Adds an order to a ShippingEasy account (calls the ShippingEasy REST API).

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

' This requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

' First create the JSON for the order.
' See https://shippingeasy.readme.io/v1.0/docs/creating-a-signature
' for sample JSON.  
' You may use the online tool at https://tools.chilkat.io/Default.cshtml to 
' generate the following code by pasting sample JSON into the tool.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set json = CreateObject("Chilkat.JsonObject")
success = json.UpdateString("order.external_order_identifier","ABC-100")
success = json.UpdateString("order.ordered_at","2014-01-16 14:37:56 -0600")
success = json.UpdateString("order.order_status","awaiting_shipment")
success = json.UpdateString("order.subtotal_including_tax","10.00")
success = json.UpdateString("order.total_including_tax","10.00")
success = json.UpdateString("order.total_excluding_tax","10.00")
success = json.UpdateString("order.discount_amount","0.00")
success = json.UpdateString("order.coupon_discount","1.00")
success = json.UpdateString("order.subtotal_including_tax","0.00")
success = json.UpdateString("order.subtotal_excluding_tax","0.00")
success = json.UpdateString("order.subtotal_excluding_tax","0.00")
success = json.UpdateString("order.subtotal_tax","0.00")
success = json.UpdateString("order.total_tax","0")
success = json.UpdateString("order.base_shipping_cost","0.00")
success = json.UpdateString("order.shipping_cost_including_tax","0.00")
success = json.UpdateString("order.shipping_cost_excluding_tax","0.00")
success = json.UpdateString("order.shipping_cost_tax","0.00")
success = json.UpdateString("order.base_handling_cost","0.00")
success = json.UpdateString("order.handling_cost_excluding_tax","0.00")
success = json.UpdateString("order.handling_cost_including_tax","0.00")
success = json.UpdateString("order.handling_cost_tax","0.00")
success = json.UpdateString("order.base_wrapping_cost","0.00")
success = json.UpdateString("order.wrapping_cost_excluding_tax","0.00")
success = json.UpdateString("order.wrapping_cost_including_tax","0.00")
success = json.UpdateString("order.wrapping_cost_tax","0.00")
success = json.UpdateString("order.notes","Please send promptly.")
success = json.UpdateString("order.billing_company","Acme Inc.")
success = json.UpdateString("order.billing_first_name","Fred")
success = json.UpdateString("order.billing_last_name","Jones")
success = json.UpdateString("order.billing_address","1234 Street")
success = json.UpdateString("order.billing_address2","Suite 100")
success = json.UpdateString("order.billing_city","Austin")
success = json.UpdateString("order.billing_state","TX")
success = json.UpdateString("order.billing_postal_code","78701")
success = json.UpdateString("order.billing_country","USA")
success = json.UpdateString("order.billing_phone_number","512-123-1234")
success = json.UpdateString("order.billing_email","test@test.com")
success = json.UpdateString("order.recipients[0].first_name","Colin")
success = json.UpdateString("order.recipients[0].last_name","Homenick")
success = json.UpdateString("order.recipients[0].company","Wintheiser-Hickle")
success = json.UpdateString("order.recipients[0].email","charles.crona@okeefe.org")
success = json.UpdateString("order.recipients[0].phone_number","637-481-6505")
success = json.UpdateString("order.recipients[0].residential","true")
success = json.UpdateString("order.recipients[0].address","21937 Adelbert Springs")
success = json.UpdateString("order.recipients[0].address2","")
success = json.UpdateString("order.recipients[0].province","")
success = json.UpdateString("order.recipients[0].state","CT")
success = json.UpdateString("order.recipients[0].city","Terryfurt")
success = json.UpdateString("order.recipients[0].postal_code","93322")
success = json.UpdateString("order.recipients[0].postal_code_plus_4","1234")
success = json.UpdateString("order.recipients[0].country","Andorra")
success = json.UpdateString("order.recipients[0].shipping_method","Ground")
success = json.UpdateString("order.recipients[0].base_cost","10.00")
success = json.UpdateString("order.recipients[0].cost_excluding_tax","10.00")
success = json.UpdateString("order.recipients[0].cost_tax","0.00")
success = json.UpdateString("order.recipients[0].base_handling_cost","0.00")
success = json.UpdateString("order.recipients[0].handling_cost_excluding_tax","0.00")
success = json.UpdateString("order.recipients[0].handling_cost_including_tax","0.00")
success = json.UpdateString("order.recipients[0].handling_cost_tax","0.00")
success = json.UpdateString("order.recipients[0].shipping_zone_id","123")
success = json.UpdateString("order.recipients[0].shipping_zone_name","XYZ")
success = json.UpdateString("order.recipients[0].items_total","1")
success = json.UpdateString("order.recipients[0].items_shipped","0")
success = json.UpdateString("order.recipients[0].line_items[0].item_name","Pencil Holder")
success = json.UpdateString("order.recipients[0].line_items[0].sku","9876543")
success = json.UpdateString("order.recipients[0].line_items[0].bin_picking_number","7")
success = json.UpdateString("order.recipients[0].line_items[0].unit_price","1.30")
success = json.UpdateString("order.recipients[0].line_items[0].total_excluding_tax","1.30")
success = json.UpdateString("order.recipients[0].line_items[0].weight_in_ounces","10")
success = json.UpdateString("order.recipients[0].line_items[0].product_options.pa_size","large")
success = json.UpdateString("order.recipients[0].line_items[0].product_options.Colour","Blue")
success = json.UpdateString("order.recipients[0].line_items[0].quantity","1")

' Replace these values with your actual apiKey and apiSecret.
' (These are not valid values..)
storeApiKey = "569dc30d267f2c4d1f85f9920b2bf9f4"
apiKey = "f9a7c8ebdfd34beaf260d9b0296c7059"
apiSecret = "d3e9f8737d7196b1271a725f89e2156672bc1d900a25e6e0c1364e2f7a20f605"

' Our request will be sent to:
' https://app.shippingeasy.com/api/stores/:store_api_key/orders
' The path part of this request is: /api/stores/:store_api_key/orders

' See https://shippingeasy.readme.io/v1.0/docs/authentication-signing-requests
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbSigStr = CreateObject("Chilkat.StringBuilder")
success = sbSigStr.Append("POST&/api/stores/")
success = sbSigStr.Append(storeApiKey)
success = sbSigStr.Append("/orders&")
success = sbSigStr.Append("api_key=")
success = sbSigStr.Append(apiKey)
success = sbSigStr.Append("&api_timestamp=")

' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.CkDateTime")
set dt = CreateObject("Chilkat.CkDateTime")
success = dt.SetFromCurrentSystemTime()
success = sbSigStr.Append(dt.GetAsUnixTimeStr(0))
success = sbSigStr.Append("&")

json.EmitCompact = 1
success = json.EmitSb(sbSigStr)

' Calculate the HMAC-SHA256 of the API Signature String using the API Secret as the HMAC key.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Crypt2")
set crypt = CreateObject("Chilkat.Crypt2")
crypt.MacAlgorithm = "hmac"
crypt.EncodingMode = "hex"
success = crypt.SetMacKeyString(apiSecret)
crypt.HashAlgorithm = "sha256"

' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbSignature = CreateObject("Chilkat.StringBuilder")
success = sbSignature.Append(crypt.MacStringENC(sbSigStr.GetAsString()))
success = sbSignature.ToLowercase()

' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbUrl = CreateObject("Chilkat.StringBuilder")
success = sbUrl.Append("https://app.shippingeasy.com/api/stores/")
success = sbUrl.Append(storeApiKey)
success = sbUrl.Append("/orders?")
success = sbUrl.Append("api_key=")
success = sbUrl.Append(apiKey)
success = sbUrl.Append("&api_timestamp=")
success = sbUrl.Append(dt.GetAsUnixTimeStr(0))
success = sbUrl.Append("&api_signature=")
success = sbUrl.Append(sbSignature.GetAsString())

' Send a POST equivalent the following curl request:
' 	curl -H "Content-Type: application/json" --data @body.json "https://app.shippingeasy.com/api/stores/27aa472e16faa83dd13b7758d31974ed/orders?
' 	api_key=f9a7c8ebdfd34beaf260d9b0296c7059&
' 	api_timestamp=1401803554&
' 	api_signature=c65f43beed46e581939898a78acd10064cfa146845e97885ec02124d7ad648e4"

' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = CreateObject("Chilkat.Http")
http.SessionLogFilename = "qa_output/shippingEasy.txt"
' resp is a Chilkat.HttpResponse
Set resp = http.PostJson2(sbUrl.GetAsString(),"application/json",json.Emit())
If (http.LastMethodSuccess <> 1) Then
    outFile.WriteLine(http.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine("response status code = " & resp.StatusCode)
outFile.WriteLine("response body:")
outFile.WriteLine(resp.BodyStr)


outFile.Close

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.