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
(PowerBuilder) Amazon SP-API Get OrdersSee more Amazon SP-API ExamplesDemonstrates Amazon SP-API Sellers API -- get orders. Returns orders created or updated during the time frame indicated by the specified parameters. For more information, see https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference#getorders
integer li_rc oleobject loo_AuthAws oleobject loo_Rest integer li_BTls integer li_Port integer li_BAutoReconnect integer li_Success oleobject loo_JsonToken string ls_Rdt_token oleobject loo_SbResponse string ls_Uri integer li_StatusCode oleobject loo_Json string ls_AmazonOrderId string ls_PurchaseDate string ls_LastUpdateDate string ls_OrderStatus string ls_FulfillmentChannel string ls_SalesChannel string ls_ShipServiceLevel string ls_CurrencyCode string ls_Amount integer li_NumberOfItemsShipped integer li_NumberOfItemsUnshipped string ls_PaymentMethod integer li_IsReplacementOrder string ls_MarketplaceId string ls_ShipmentServiceLevelCategory string ls_OrderType string ls_EarliestShipDate string ls_LatestShipDate string ls_EarliestDeliveryDate string ls_LatestDeliveryDate integer li_IsBusinessOrder integer li_IsPrime integer li_IsGlobalExpressEnabled integer li_IsPremiumOrder integer li_IsSoldByAB integer li_IsIBA string ls_Name string ls_AddressLine1 string ls_City string ls_StateOrRegion string ls_PostalCode string ls_CountryCode string ls_Phone string ls_AddressType string ls_FulfillmentSupplySourceId integer li_IsISPU integer li_IsAccessPointOrder integer li_HasAutomatedShippingSettings string ls_EasyShipShipmentStatus string ls_ElectronicInvoiceStatus integer j integer li_Count_j string ls_StrVal string ls_CreatedBefore integer i integer li_Count_i // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // IMPORTANT: // You'll need to make changes to use values specific to your own region and account. // // Here is a list of values you'll need to change or provide: // // 1) The access key. Change AWS_ACCESS_KEY to your actual access key. // 2) The secret key. Change AWS_SECRET_KEY to your actual access key. // 3) Your region. Change "ew-west-1" to your region. // 4) The domain to which you connect. Change sandbox.sellingpartnerapi-eu.amazon.com to non-sandbox by removing the "sandbox." // and change the "-eu" part of the domain to your region. See https://developer-docs.amazon.com/sp-api/docs/sp-api-endpoints // 5) Use the restricted data token (RDT) obtained from your code that previously obtained the RDT. // If you saved the RDT to a file, update the relative file path "qa_data/tokens/sp_api_rdt_token.json" to your actual file path. // 6) Update your Marketplace ID(s), such as ATVPDKIKX0DER // 7) If using the non-sandbox, change the CreatedAfter from "TEST_CASE_200" to an actual date, such as "2022-12-25" loo_AuthAws = create oleobject // Use "Chilkat_9_5_0.AuthAws" for versions of Chilkat < 10.0.0 li_rc = loo_AuthAws.ConnectToNewObject("Chilkat.AuthAws") if li_rc < 0 then destroy loo_AuthAws MessageBox("Error","Connecting to COM object failed") return end if loo_AuthAws.AccessKey = "AWS_ACCESS_KEY" loo_AuthAws.SecretKey = "AWS_SECRET_KEY" loo_AuthAws.ServiceName = "execute-api" // Use the region that is correct for your needs. loo_AuthAws.Region = "eu-west-1" loo_Rest = create oleobject // Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0 li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest") li_BTls = 1 li_Port = 443 li_BAutoReconnect = 1 // Make sure to use the correct domain. // This example is using the sandbox li_Success = loo_Rest.Connect("sandbox.sellingpartnerapi-eu.amazon.com",li_Port,li_BTls,li_BAutoReconnect) if li_Success = 0 then Write-Debug loo_Rest.LastErrorText destroy loo_AuthAws destroy loo_Rest return end if li_Success = loo_Rest.SetAuthAws(loo_AuthAws) // Here's the example to get the RDT access token: Get SP-API Restricted Data Token // Load the previously obtained RDT access token. // See Fetch SP-API RDT Access Token loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/sp_api_rdt_token.json") if li_Success = 0 then Write-Debug "Failed to load RDT access token." destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken return end if // Add the x-amz-access-token request header. ls_Rdt_token = loo_JsonToken.StringOf("restrictedDataToken") loo_Rest.ClearAllHeaders() loo_Rest.AddHeader("x-amz-access-token",ls_Rdt_token) // Indicate the marketplace IDs. Use the marketplace ID for your needs. See https://developer-docs.amazon.com/sp-api/docs/marketplace-ids loo_Rest.ClearAllQueryParams() // When using the sandbox, use these params literally and exactly has shown here: loo_Rest.AddQueryParam("MarketplaceIds","ATVPDKIKX0DER") loo_Rest.AddQueryParam("CreatedAfter","TEST_CASE_200") loo_SbResponse = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponse.ConnectToNewObject("Chilkat.StringBuilder") ls_Uri = "/orders/v0/orders" li_Success = loo_Rest.FullRequestNoBodySb("GET",ls_Uri,loo_SbResponse) if li_Success = 0 then Write-Debug loo_Rest.LastErrorText destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken destroy loo_SbResponse return end if // Examine the response status. li_StatusCode = loo_Rest.ResponseStatusCode if li_StatusCode <> 200 then Write-Debug "Response status text: " + loo_Rest.ResponseStatusText Write-Debug "Response body: " Write-Debug loo_SbResponse.GetAsString() Write-Debug "Failed." destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken destroy loo_SbResponse return end if Write-Debug loo_SbResponse.GetAsString() // If successful, gets a JSON response such as the following: // { // "payload": { // "CreatedBefore": "1.569521782042E9", // "Orders": [ // { // "AmazonOrderId": "902-1845936-5435065", // "PurchaseDate": "1970-01-19T03:58:30Z", // "LastUpdateDate": "1970-01-19T03:58:32Z", // "OrderStatus": "Unshipped", // "FulfillmentChannel": "MFN", // "SalesChannel": "Amazon.com", // "ShipServiceLevel": "Std US D2D Dom", // "OrderTotal": { // "CurrencyCode": "USD", // "Amount": "11.01" // }, // "NumberOfItemsShipped": 0, // "NumberOfItemsUnshipped": 1, // "PaymentMethod": "Other", // "PaymentMethodDetails": [ // "Standard" // ], // "IsReplacementOrder": false, // "MarketplaceId": "ATVPDKIKX0DER", // "ShipmentServiceLevelCategory": "Standard", // "OrderType": "StandardOrder", // "EarliestShipDate": "1970-01-19T03:59:27Z", // "LatestShipDate": "1970-01-19T04:05:13Z", // "EarliestDeliveryDate": "1970-01-19T04:06:39Z", // "LatestDeliveryDate": "1970-01-19T04:15:17Z", // "IsBusinessOrder": false, // "IsPrime": false, // "IsGlobalExpressEnabled": false, // "IsPremiumOrder": false, // "IsSoldByAB": false, // "IsIBA": false, // "DefaultShipFromLocationAddress": { // "Name": "MFNIntegrationTestMerchant", // "AddressLine1": "2201 WESTLAKE AVE", // "City": "SEATTLE", // "StateOrRegion": "WA", // "PostalCode": "98121-2778", // "CountryCode": "US", // "Phone": "+1 480-386-0930 ext. 73824", // "AddressType": "Commercial" // }, // "FulfillmentInstruction": { // "FulfillmentSupplySourceId": "sampleSupplySourceId" // }, // "IsISPU": false, // "IsAccessPointOrder": false, // "AutomatedShippingSettings": { // "HasAutomatedShippingSettings": false // }, // "EasyShipShipmentStatus": "PendingPickUp", // "ElectronicInvoiceStatus": "NotRequired" // }, // { // "AmazonOrderId": "902-8745147-1934268", // "PurchaseDate": "1970-01-19T03:58:30Z", // "LastUpdateDate": "1970-01-19T03:58:32Z", // "OrderStatus": "Unshipped", // "FulfillmentChannel": "MFN", // "SalesChannel": "Amazon.com", // "ShipServiceLevel": "Std US D2D Dom", // "OrderTotal": { // "CurrencyCode": "USD", // "Amount": "11.01" // }, // "NumberOfItemsShipped": 0, // "NumberOfItemsUnshipped": 1, // "PaymentMethod": "Other", // "PaymentMethodDetails": [ // "Standard" // ], // "IsReplacementOrder": false, // "MarketplaceId": "ATVPDKIKX0DER", // "ShipmentServiceLevelCategory": "Standard", // "OrderType": "StandardOrder", // "EarliestShipDate": "1970-01-19T03:59:27Z", // "LatestShipDate": "1970-01-19T04:05:13Z", // "EarliestDeliveryDate": "1970-01-19T04:06:39Z", // "LatestDeliveryDate": "1970-01-19T04:15:17Z", // "IsBusinessOrder": false, // "IsPrime": false, // "IsAccessPointOrder": false, // "IsGlobalExpressEnabled": false, // "IsPremiumOrder": false, // "IsSoldByAB": false, // "IsIBA": false, // "EasyShipShipmentStatus": "PendingPickUp", // "ElectronicInvoiceStatus": "NotRequired" // } // ] // } // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.LoadSb(loo_SbResponse) ls_CreatedBefore = loo_Json.StringOf("payload.CreatedBefore") i = 0 li_Count_i = loo_Json.SizeOfArray("payload.Orders") do while i < li_Count_i loo_Json.I = i ls_AmazonOrderId = loo_Json.StringOf("payload.Orders[i].AmazonOrderId") ls_PurchaseDate = loo_Json.StringOf("payload.Orders[i].PurchaseDate") ls_LastUpdateDate = loo_Json.StringOf("payload.Orders[i].LastUpdateDate") ls_OrderStatus = loo_Json.StringOf("payload.Orders[i].OrderStatus") ls_FulfillmentChannel = loo_Json.StringOf("payload.Orders[i].FulfillmentChannel") ls_SalesChannel = loo_Json.StringOf("payload.Orders[i].SalesChannel") ls_ShipServiceLevel = loo_Json.StringOf("payload.Orders[i].ShipServiceLevel") ls_CurrencyCode = loo_Json.StringOf("payload.Orders[i].OrderTotal.CurrencyCode") ls_Amount = loo_Json.StringOf("payload.Orders[i].OrderTotal.Amount") li_NumberOfItemsShipped = loo_Json.IntOf("payload.Orders[i].NumberOfItemsShipped") li_NumberOfItemsUnshipped = loo_Json.IntOf("payload.Orders[i].NumberOfItemsUnshipped") ls_PaymentMethod = loo_Json.StringOf("payload.Orders[i].PaymentMethod") li_IsReplacementOrder = loo_Json.BoolOf("payload.Orders[i].IsReplacementOrder") ls_MarketplaceId = loo_Json.StringOf("payload.Orders[i].MarketplaceId") ls_ShipmentServiceLevelCategory = loo_Json.StringOf("payload.Orders[i].ShipmentServiceLevelCategory") ls_OrderType = loo_Json.StringOf("payload.Orders[i].OrderType") ls_EarliestShipDate = loo_Json.StringOf("payload.Orders[i].EarliestShipDate") ls_LatestShipDate = loo_Json.StringOf("payload.Orders[i].LatestShipDate") ls_EarliestDeliveryDate = loo_Json.StringOf("payload.Orders[i].EarliestDeliveryDate") ls_LatestDeliveryDate = loo_Json.StringOf("payload.Orders[i].LatestDeliveryDate") li_IsBusinessOrder = loo_Json.BoolOf("payload.Orders[i].IsBusinessOrder") li_IsPrime = loo_Json.BoolOf("payload.Orders[i].IsPrime") li_IsGlobalExpressEnabled = loo_Json.BoolOf("payload.Orders[i].IsGlobalExpressEnabled") li_IsPremiumOrder = loo_Json.BoolOf("payload.Orders[i].IsPremiumOrder") li_IsSoldByAB = loo_Json.BoolOf("payload.Orders[i].IsSoldByAB") li_IsIBA = loo_Json.BoolOf("payload.Orders[i].IsIBA") ls_Name = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.Name") ls_AddressLine1 = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.AddressLine1") ls_City = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.City") ls_StateOrRegion = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.StateOrRegion") ls_PostalCode = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.PostalCode") ls_CountryCode = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.CountryCode") ls_Phone = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.Phone") ls_AddressType = loo_Json.StringOf("payload.Orders[i].DefaultShipFromLocationAddress.AddressType") ls_FulfillmentSupplySourceId = loo_Json.StringOf("payload.Orders[i].FulfillmentInstruction.FulfillmentSupplySourceId") li_IsISPU = loo_Json.BoolOf("payload.Orders[i].IsISPU") li_IsAccessPointOrder = loo_Json.BoolOf("payload.Orders[i].IsAccessPointOrder") li_HasAutomatedShippingSettings = loo_Json.BoolOf("payload.Orders[i].AutomatedShippingSettings.HasAutomatedShippingSettings") ls_EasyShipShipmentStatus = loo_Json.StringOf("payload.Orders[i].EasyShipShipmentStatus") ls_ElectronicInvoiceStatus = loo_Json.StringOf("payload.Orders[i].ElectronicInvoiceStatus") j = 0 li_Count_j = loo_Json.SizeOfArray("payload.Orders[i].PaymentMethodDetails") do while j < li_Count_j loo_Json.J = j ls_StrVal = loo_Json.StringOf("payload.Orders[i].PaymentMethodDetails[j]") j = j + 1 loop i = i + 1 loop Write-Debug "Success!" destroy loo_AuthAws destroy loo_Rest destroy loo_JsonToken destroy loo_SbResponse destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.