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
(Classic ASP) Amazon MWS Upload InvoiceDemonstrates 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
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% ' This example requires the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Rest") set rest = Server.CreateObject("Chilkat.Rest") ' 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 bTls = 1 port = 443 bAutoReconnect = 1 success = rest.Connect("mws.amazonservices.com",port,bTls,bAutoReconnect) rest.Host = "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. success = rest.AddQueryParam("FeedOptions","metadata:orderid=206-2341234-3455465;metadata:invoicenumber=INT-3431-XJE3;metadata:documenttype=Invoice") ' Load the PDF invoice file that is to be the body of the HTTP POST request. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData") set pdfData = Server.CreateObject("Chilkat.BinData") success = pdfData.LoadFile("qa_data/pdf/sample.pdf") ' Get the MD5 hash of the PDF data. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Crypt2") set crypt = Server.CreateObject("Chilkat.Crypt2") crypt.HashAlgorithm = "md5" crypt.EncodingMode = "base64" md5Hash = crypt.HashBdENC(pdfData) success = rest.AddQueryParam("AWSAccessKeyId","0PB842ExampleN4ZTR2") success = rest.AddQueryParam("Action","SubmitFeed") success = rest.AddQueryParam("FeedType","_UPLOAD_VAT_INVOICE_") success = rest.AddQueryParam("MWSAuthToken","EXAMPLE-amzn.mws.4ea38b7b-f563-7709-4bae-87aea-EXAMPLE") success = rest.AddQueryParam("MarketplaceIdList.Id.1","ATVExampleDER") success = rest.AddQueryParam("SellerId","A1XExample5E6") success = rest.AddQueryParam("ContentMD5Value",md5Hash) success = rest.AddQueryParam("SignatureMethod","HmacSHA256") success = rest.AddQueryParam("SignatureVersion","2") success = rest.AddQueryParam("Version","2009-01-01") ' Add the MWS Signature param. (Also adds the Timestamp parameter using the curent system date/time.) success = rest.AddMwsSignature("POST","/Feeds/2009-01-01","mws.amazonservices.com","YOUR_MWS_SECRET_ACCESS_KEY_ID") success = rest.AddHeader("Content-Type","application/octet-stream") ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder") set sbResponseBody = Server.CreateObject("Chilkat.StringBuilder") success = rest.FullRequestBd("POST","/Feeds/2009-01-01",pdfData,sbResponseBody) If (rest.LastMethodSuccess <> 1) Then Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>" Response.End End If If (rest.ResponseStatusCode <> 200) Then ' Examine the request/response to see what happened. Response.Write "<pre>" & Server.HTMLEncode( "response status code = " & rest.ResponseStatusCode) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "response status text = " & rest.ResponseStatusText) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "response header: " & rest.ResponseHeader) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "response body: " & sbResponseBody.GetAsString()) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "---") & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "LastRequestStartLine: " & rest.LastRequestStartLine) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "LastRequestHeader: " & rest.LastRequestHeader) & "</pre>" End If ' Examine the XML returned in the response body. Response.Write "<pre>" & Server.HTMLEncode( sbResponseBody.GetAsString()) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "----") & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "Success.") & "</pre>" %> </body> </html> |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.