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) Amazon MWS Upload Invoice

Demonstrates how to upload an invoice using _UPLOAD_VAT_INVOICE_FeedType to submit an invoice for an order.

For more information, see https://m.media-amazon.com/images/G/03/B2B/invoice-uploader-developer-documentation.pdf

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoRest
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Variant vPdfData
    Handle hoPdfData
    Handle hoCrypt
    String sMd5Hash
    Variant vSbResponseBody
    Handle hoSbResponseBody
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    // Connect to the Amazon MWS REST server.
    // 
    // Make sure to connect to the correct Amazon MWS Endpoint, otherwise
    // you'll get an HTTP 401 response code.
    // 
    // See Amazon MWS endpoints and MarketplaceId values

    Move True To iBTls
    Move 443 To iPort
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "mws.amazonservices.com" iPort iBTls iBAutoReconnect To iSuccess

    Set ComHost Of hoRest To "mws.amazonservices.com"

    // MarketplaceList.Id parameter �This should be the marketplace in which the order was placed. Only one marketplace must be used per order.T
    // Here are the marketplace ID's
    // Spain: A1RKKUPIHCS9HS
    // UK: A1F83G8C2ARO7P
    // France: A13V1IB3VIYZZH
    // Germany: A1PA6795UKMFR9
    // Italy: APJ6JRA9NG5V4
    // ...
    // (See https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html)

    // FeedOptions parameter � Seller can input key value pairs to give important metadata along with the PDF invoice.
    Get ComAddQueryParam Of hoRest "FeedOptions" "metadata:orderid=206-2341234-3455465;metadata:invoicenumber=INT-3431-XJE3;metadata:documenttype=Invoice" To iSuccess

    // Load the PDF invoice file that is to be the body of the HTTP POST request.
    Get Create (RefClass(cComChilkatBinData)) To hoPdfData
    If (Not(IsComObjectCreated(hoPdfData))) Begin
        Send CreateComObject of hoPdfData
    End
    Get ComLoadFile Of hoPdfData "qa_data/pdf/sample.pdf" To iSuccess

    // Get the MD5 hash of the PDF data.
    Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
    If (Not(IsComObjectCreated(hoCrypt))) Begin
        Send CreateComObject of hoCrypt
    End
    Set ComHashAlgorithm Of hoCrypt To "md5"
    Set ComEncodingMode Of hoCrypt To "base64"
    Get pvComObject of hoPdfData to vPdfData
    Get ComHashBdENC Of hoCrypt vPdfData To sMd5Hash

    Get ComAddQueryParam Of hoRest "AWSAccessKeyId" "0PB842ExampleN4ZTR2" To iSuccess
    Get ComAddQueryParam Of hoRest "Action" "SubmitFeed" To iSuccess
    Get ComAddQueryParam Of hoRest "FeedType" "_UPLOAD_VAT_INVOICE_" To iSuccess
    Get ComAddQueryParam Of hoRest "MWSAuthToken" "EXAMPLE-amzn.mws.4ea38b7b-f563-7709-4bae-87aea-EXAMPLE" To iSuccess

    Get ComAddQueryParam Of hoRest "MarketplaceIdList.Id.1" "ATVExampleDER" To iSuccess
    Get ComAddQueryParam Of hoRest "SellerId" "A1XExample5E6" To iSuccess
    Get ComAddQueryParam Of hoRest "ContentMD5Value" sMd5Hash To iSuccess
    Get ComAddQueryParam Of hoRest "SignatureMethod" "HmacSHA256" To iSuccess
    Get ComAddQueryParam Of hoRest "SignatureVersion" "2" To iSuccess
    Get ComAddQueryParam Of hoRest "Version" "2009-01-01" To iSuccess

    // Add the MWS Signature param.  (Also adds the Timestamp parameter using the curent system date/time.)
    Get ComAddMwsSignature Of hoRest "POST" "/Feeds/2009-01-01" "mws.amazonservices.com" "YOUR_MWS_SECRET_ACCESS_KEY_ID" To iSuccess

    Get ComAddHeader Of hoRest "Content-Type" "application/octet-stream" To iSuccess
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoPdfData to vPdfData
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestBd Of hoRest "POST" "/Feeds/2009-01-01" vPdfData vSbResponseBody To iSuccess
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 200) Begin
        // Examine the request/response to see what happened.
        Get ComResponseStatusCode Of hoRest To iTemp1
        Showln "response status code = " iTemp1
        Get ComResponseStatusText Of hoRest To sTemp1
        Showln "response status text = " sTemp1
        Get ComResponseHeader Of hoRest To sTemp1
        Showln "response header: " sTemp1
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln "response body: " sTemp1
        Showln "---"
        Get ComLastRequestStartLine Of hoRest To sTemp1
        Showln "LastRequestStartLine: " sTemp1
        Get ComLastRequestHeader Of hoRest To sTemp1
        Showln "LastRequestHeader: " sTemp1
    End

    // Examine the XML returned in the response body.
    Get ComGetAsString Of hoSbResponseBody To sTemp1
    Showln sTemp1
    Showln "----"
    Showln "Success."


End_Procedure

 

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