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

PowerBuilder 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
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

 

 

 

(PowerBuilder) 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

integer li_rc
integer li_Success
oleobject loo_Json
string ls_StoreApiKey
string ls_ApiKey
string ls_ApiSecret
oleobject loo_SbSigStr
oleobject loo_Dt
oleobject loo_Crypt
oleobject loo_SbSignature
oleobject loo_SbUrl
oleobject loo_Http
oleobject loo_Resp

// 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.
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
    destroy loo_Json
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Json.UpdateString("order.external_order_identifier","ABC-100")
loo_Json.UpdateString("order.ordered_at","2014-01-16 14:37:56 -0600")
loo_Json.UpdateString("order.order_status","awaiting_shipment")
loo_Json.UpdateString("order.subtotal_including_tax","10.00")
loo_Json.UpdateString("order.total_including_tax","10.00")
loo_Json.UpdateString("order.total_excluding_tax","10.00")
loo_Json.UpdateString("order.discount_amount","0.00")
loo_Json.UpdateString("order.coupon_discount","1.00")
loo_Json.UpdateString("order.subtotal_including_tax","0.00")
loo_Json.UpdateString("order.subtotal_excluding_tax","0.00")
loo_Json.UpdateString("order.subtotal_excluding_tax","0.00")
loo_Json.UpdateString("order.subtotal_tax","0.00")
loo_Json.UpdateString("order.total_tax","0")
loo_Json.UpdateString("order.base_shipping_cost","0.00")
loo_Json.UpdateString("order.shipping_cost_including_tax","0.00")
loo_Json.UpdateString("order.shipping_cost_excluding_tax","0.00")
loo_Json.UpdateString("order.shipping_cost_tax","0.00")
loo_Json.UpdateString("order.base_handling_cost","0.00")
loo_Json.UpdateString("order.handling_cost_excluding_tax","0.00")
loo_Json.UpdateString("order.handling_cost_including_tax","0.00")
loo_Json.UpdateString("order.handling_cost_tax","0.00")
loo_Json.UpdateString("order.base_wrapping_cost","0.00")
loo_Json.UpdateString("order.wrapping_cost_excluding_tax","0.00")
loo_Json.UpdateString("order.wrapping_cost_including_tax","0.00")
loo_Json.UpdateString("order.wrapping_cost_tax","0.00")
loo_Json.UpdateString("order.notes","Please send promptly.")
loo_Json.UpdateString("order.billing_company","Acme Inc.")
loo_Json.UpdateString("order.billing_first_name","Fred")
loo_Json.UpdateString("order.billing_last_name","Jones")
loo_Json.UpdateString("order.billing_address","1234 Street")
loo_Json.UpdateString("order.billing_address2","Suite 100")
loo_Json.UpdateString("order.billing_city","Austin")
loo_Json.UpdateString("order.billing_state","TX")
loo_Json.UpdateString("order.billing_postal_code","78701")
loo_Json.UpdateString("order.billing_country","USA")
loo_Json.UpdateString("order.billing_phone_number","512-123-1234")
loo_Json.UpdateString("order.billing_email","test@test.com")
loo_Json.UpdateString("order.recipients[0].first_name","Colin")
loo_Json.UpdateString("order.recipients[0].last_name","Homenick")
loo_Json.UpdateString("order.recipients[0].company","Wintheiser-Hickle")
loo_Json.UpdateString("order.recipients[0].email","charles.crona@okeefe.org")
loo_Json.UpdateString("order.recipients[0].phone_number","637-481-6505")
loo_Json.UpdateString("order.recipients[0].residential","true")
loo_Json.UpdateString("order.recipients[0].address","21937 Adelbert Springs")
loo_Json.UpdateString("order.recipients[0].address2","")
loo_Json.UpdateString("order.recipients[0].province","")
loo_Json.UpdateString("order.recipients[0].state","CT")
loo_Json.UpdateString("order.recipients[0].city","Terryfurt")
loo_Json.UpdateString("order.recipients[0].postal_code","93322")
loo_Json.UpdateString("order.recipients[0].postal_code_plus_4","1234")
loo_Json.UpdateString("order.recipients[0].country","Andorra")
loo_Json.UpdateString("order.recipients[0].shipping_method","Ground")
loo_Json.UpdateString("order.recipients[0].base_cost","10.00")
loo_Json.UpdateString("order.recipients[0].cost_excluding_tax","10.00")
loo_Json.UpdateString("order.recipients[0].cost_tax","0.00")
loo_Json.UpdateString("order.recipients[0].base_handling_cost","0.00")
loo_Json.UpdateString("order.recipients[0].handling_cost_excluding_tax","0.00")
loo_Json.UpdateString("order.recipients[0].handling_cost_including_tax","0.00")
loo_Json.UpdateString("order.recipients[0].handling_cost_tax","0.00")
loo_Json.UpdateString("order.recipients[0].shipping_zone_id","123")
loo_Json.UpdateString("order.recipients[0].shipping_zone_name","XYZ")
loo_Json.UpdateString("order.recipients[0].items_total","1")
loo_Json.UpdateString("order.recipients[0].items_shipped","0")
loo_Json.UpdateString("order.recipients[0].line_items[0].item_name","Pencil Holder")
loo_Json.UpdateString("order.recipients[0].line_items[0].sku","9876543")
loo_Json.UpdateString("order.recipients[0].line_items[0].bin_picking_number","7")
loo_Json.UpdateString("order.recipients[0].line_items[0].unit_price","1.30")
loo_Json.UpdateString("order.recipients[0].line_items[0].total_excluding_tax","1.30")
loo_Json.UpdateString("order.recipients[0].line_items[0].weight_in_ounces","10")
loo_Json.UpdateString("order.recipients[0].line_items[0].product_options.pa_size","large")
loo_Json.UpdateString("order.recipients[0].line_items[0].product_options.Colour","Blue")
loo_Json.UpdateString("order.recipients[0].line_items[0].quantity","1")

// Replace these values with your actual apiKey and apiSecret.
// (These are not valid values..)
ls_StoreApiKey = "569dc30d267f2c4d1f85f9920b2bf9f4"
ls_ApiKey = "f9a7c8ebdfd34beaf260d9b0296c7059"
ls_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
loo_SbSigStr = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbSigStr.ConnectToNewObject("Chilkat.StringBuilder")

loo_SbSigStr.Append("POST&/api/stores/")
loo_SbSigStr.Append(ls_StoreApiKey)
loo_SbSigStr.Append("/orders&")
loo_SbSigStr.Append("api_key=")
loo_SbSigStr.Append(ls_ApiKey)
loo_SbSigStr.Append("&api_timestamp=")

loo_Dt = create oleobject
// Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0
li_rc = loo_Dt.ConnectToNewObject("Chilkat.CkDateTime")

loo_Dt.SetFromCurrentSystemTime()
loo_SbSigStr.Append(loo_Dt.GetAsUnixTimeStr(0))
loo_SbSigStr.Append("&")

loo_Json.EmitCompact = 1
loo_Json.EmitSb(loo_SbSigStr)

// Calculate the HMAC-SHA256 of the API Signature String using the API Secret as the HMAC key.
loo_Crypt = create oleobject
// Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")

loo_Crypt.MacAlgorithm = "hmac"
loo_Crypt.EncodingMode = "hex"
loo_Crypt.SetMacKeyString(ls_ApiSecret)
loo_Crypt.HashAlgorithm = "sha256"

loo_SbSignature = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbSignature.ConnectToNewObject("Chilkat.StringBuilder")

loo_SbSignature.Append(loo_Crypt.MacStringENC(loo_SbSigStr.GetAsString()))
loo_SbSignature.ToLowercase()

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.shippingeasy.com/api/stores/")
loo_SbUrl.Append(ls_StoreApiKey)
loo_SbUrl.Append("/orders?")
loo_SbUrl.Append("api_key=")
loo_SbUrl.Append(ls_ApiKey)
loo_SbUrl.Append("&api_timestamp=")
loo_SbUrl.Append(loo_Dt.GetAsUnixTimeStr(0))
loo_SbUrl.Append("&api_signature=")
loo_SbUrl.Append(loo_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"

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.SessionLogFilename = "qa_output/shippingEasy.txt"
loo_Resp = loo_Http.PostJson2(loo_SbUrl.GetAsString(),"application/json",loo_Json.Emit())
if loo_Http.LastMethodSuccess <> 1 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Json
    destroy loo_SbSigStr
    destroy loo_Dt
    destroy loo_Crypt
    destroy loo_SbSignature
    destroy loo_SbUrl
    destroy loo_Http
    return
end if

Write-Debug "response status code = " + string(loo_Resp.StatusCode)
Write-Debug "response body:"
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Json
destroy loo_SbSigStr
destroy loo_Dt
destroy loo_Crypt
destroy loo_SbSignature
destroy loo_SbUrl
destroy loo_Http

 

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