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
(SQL Server) Walmart - Acknowledge OrderSee Acknowledge Orders for more information about this call. Acknowledges an entire order, including all of its order lines. Walmart requires a seller to acknowledge orders within four hours of receipt of the order, except in extenuating circumstances. The response to a successful call contains the acknowledged order. In general, only orders that are in a “Created” state should be acknowledged. As a good practice, acknowledge your orders to avoid underselling. Orders that are in an “Acknowledged” state can be re-acknowledged, possibly in response to an error response from an earlier call to acknowledge order. Orders with line items that are shipped or canceled should not be re-acknowledged.
// Important: See this note about string length limitations for strings returned by sp_OAMethod calls. // CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int DECLARE @sTmp0 nvarchar(4000) -- --------------------------------------------------------------------------------------------------------- -- Note: This example is deprecated. The Walmart API no longer uses the Signature method of authenticating. -- Walmart now uses OAuth2. -- --------------------------------------------------------------------------------------------------------- -- This example requires the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. -- Sends the following POST request: -- POST https://marketplace.walmartapis.com/v3/orders/{purchaseOrderId}/acknowledge DECLARE @sbUrl int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbUrl OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @sbUrl, 'Append', @success OUT, 'https://marketplace.walmartapis.com/v3/orders/{purchaseOrderId}/acknowledge' DECLARE @numReplaced int EXEC sp_OAMethod @sbUrl, 'Replace', @numReplaced OUT, '{purchaseOrderId}', '1111691995111' DECLARE @requestMethod nvarchar(4000) SELECT @requestMethod = 'POST' -- First we need to generate a signature for our request. -- The signature needs to be re-generated for each new Walmart HTTP request. DECLARE @authUtil int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.AuthUtil', @authUtil OUT DECLARE @wmConsumerId nvarchar(4000) SELECT @wmConsumerId = 'WALMART_CONSUMER_ID' DECLARE @wmPrivateKey nvarchar(4000) SELECT @wmPrivateKey = 'WALMART_PRIVATE_KEY' DECLARE @jsonStr nvarchar(4000) EXEC sp_OAMethod @sbUrl, 'GetAsString', @sTmp0 OUT EXEC sp_OAMethod @authUtil, 'WalmartSignature', @jsonStr OUT, @sTmp0, @wmConsumerId, @wmPrivateKey, @requestMethod EXEC sp_OAGetProperty @authUtil, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 <> 1 BEGIN EXEC sp_OAGetProperty @authUtil, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @sbUrl EXEC @hr = sp_OADestroy @authUtil RETURN END -- The JSON returned by WalmartSignature contains the values to be used in the following -- header fields: WM_SEC.AUTH_SIGNATURE, WM_SEC.TIMESTAMP, and WM_QOS.CORRELATION_ID DECLARE @json int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT EXEC sp_OAMethod @json, 'Load', @success OUT, @jsonStr DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_SVC.NAME', 'Walmart Marketplace' EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'correlation_id' EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_QOS.CORRELATION_ID', @sTmp0 EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'timestamp' EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_SEC.TIMESTAMP', @sTmp0 EXEC sp_OAMethod @json, 'StringOf', @sTmp0 OUT, 'signature' EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_SEC.AUTH_SIGNATURE', @sTmp0 EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_CONSUMER.ID', @wmConsumerId -- Note: Make sure to replace "WALMART_CHANNEL_TYPE" with the actual value for your seller account... EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'WM_CONSUMER.CHANNEL.TYPE', 'WALMART_CHANNEL_TYPE' EXEC sp_OASetProperty @http, 'Accept', 'application/xml' -- Note: Do not explicitly set the "Host" header. Chilkat will set it automatically. -- Walmart provides the option to send/receive JSON or XML. This example will use JSON. -- Note: Please see the online JSON/XML code generation tools at https://tools.chilkat.io/ -- The online tools generate code to create/parse XML or JSON. (You copy sample JSON/XML into the online format, -- and generate code in your selected programming language. It's a big time saver.) EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json' -- The body of this particular POST request contains just "{}". (The order ID is already in the URL path.) DECLARE @resp int EXEC sp_OAMethod @sbUrl, 'GetAsString', @sTmp0 OUT EXEC sp_OAMethod @http, 'PostJson2', @resp OUT, @sTmp0, 'application/json', '{}' EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 <> 1 BEGIN EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @sbUrl EXEC @hr = sp_OADestroy @authUtil EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @http RETURN END -- Get the JSON response body, which could contain an error, or if successful contains -- the acknowledged order. DECLARE @sbBody int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbBody OUT EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbBody -- A successful response should have a 200 response status EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT IF @iTmp0 <> 200 BEGIN EXEC sp_OAMethod @sbBody, 'GetAsString', @sTmp0 OUT PRINT @sTmp0 EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT PRINT 'Response Status Code: ' + @iTmp0 PRINT 'Failed.' EXEC @hr = sp_OADestroy @resp EXEC @hr = sp_OADestroy @sbUrl EXEC @hr = sp_OADestroy @authUtil EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sbBody RETURN END EXEC @hr = sp_OADestroy @resp -- Parse the JSON response. -- A sample response is shown below this code. (The online tools at https://tools.chilkat.io were used to generate the -- fragment of code below using the sample response data at -- https://developer.walmart.com/#/apicenter/marketPlace/latest?country=us#acknowledgingOrders EXEC sp_OAMethod @json, 'LoadSb', @success OUT, @sbBody DECLARE @orderPurchaseOrderId nvarchar(4000) DECLARE @orderCustomerOrderId nvarchar(4000) DECLARE @orderCustomerEmailId nvarchar(4000) DECLARE @orderOrderDate int DECLARE @orderShippingInfoPhone nvarchar(4000) DECLARE @orderShippingInfoEstimatedDeliveryDate int DECLARE @orderShippingInfoEstimatedShipDate int DECLARE @orderShippingInfoMethodCode nvarchar(4000) DECLARE @orderShippingInfoPostalAddressName nvarchar(4000) DECLARE @orderShippingInfoPostalAddressAddress1 nvarchar(4000) DECLARE @orderShippingInfoPostalAddressAddress2 nvarchar(4000) DECLARE @orderShippingInfoPostalAddressCity nvarchar(4000) DECLARE @orderShippingInfoPostalAddressState nvarchar(4000) DECLARE @orderShippingInfoPostalAddressPostalCode nvarchar(4000) DECLARE @orderShippingInfoPostalAddressCountry nvarchar(4000) DECLARE @orderShippingInfoPostalAddressAddressType nvarchar(4000) DECLARE @i int DECLARE @count_i int DECLARE @lineNumber nvarchar(4000) DECLARE @itemProductName nvarchar(4000) DECLARE @itemSku nvarchar(4000) DECLARE @orderLineQuantityUnitOfMeasurement nvarchar(4000) DECLARE @orderLineQuantityAmount nvarchar(4000) DECLARE @statusDate int DECLARE @refundRefundId int DECLARE @refundRefundComments int DECLARE @j int DECLARE @count_j int DECLARE @chargeType nvarchar(4000) DECLARE @chargeName nvarchar(4000) DECLARE @chargeAmountCurrency nvarchar(4000) DECLARE @chargeAmountAmount int DECLARE @taxTaxName nvarchar(4000) DECLARE @taxTaxAmountCurrency nvarchar(4000) DECLARE @taxTaxAmountAmount int DECLARE @status nvarchar(4000) DECLARE @statusQuantityUnitOfMeasurement nvarchar(4000) DECLARE @statusQuantityAmount nvarchar(4000) DECLARE @cancellationReason int DECLARE @trackingInfoShipDateTime int DECLARE @trackingInfoCarrierNameOtherCarrier int DECLARE @trackingInfoCarrierNameCarrier nvarchar(4000) DECLARE @trackingInfoMethodCode nvarchar(4000) DECLARE @trackingInfoTrackingNumber nvarchar(4000) DECLARE @trackingInfoTrackingURL nvarchar(4000) DECLARE @refundReason nvarchar(4000) DECLARE @chargeChargeType nvarchar(4000) DECLARE @chargeChargeName nvarchar(4000) DECLARE @chargeChargeAmountCurrency nvarchar(4000) DECLARE @chargeChargeAmountAmount int DECLARE @chargeTax int EXEC sp_OAMethod @json, 'StringOf', @orderPurchaseOrderId OUT, 'order.purchaseOrderId' EXEC sp_OAMethod @json, 'StringOf', @orderCustomerOrderId OUT, 'order.customerOrderId' EXEC sp_OAMethod @json, 'StringOf', @orderCustomerEmailId OUT, 'order.customerEmailId' EXEC sp_OAMethod @json, 'IntOf', @orderOrderDate OUT, 'order.orderDate' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPhone OUT, 'order.shippingInfo.phone' EXEC sp_OAMethod @json, 'IntOf', @orderShippingInfoEstimatedDeliveryDate OUT, 'order.shippingInfo.estimatedDeliveryDate' EXEC sp_OAMethod @json, 'IntOf', @orderShippingInfoEstimatedShipDate OUT, 'order.shippingInfo.estimatedShipDate' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoMethodCode OUT, 'order.shippingInfo.methodCode' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressName OUT, 'order.shippingInfo.postalAddress.name' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressAddress1 OUT, 'order.shippingInfo.postalAddress.address1' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressAddress2 OUT, 'order.shippingInfo.postalAddress.address2' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressCity OUT, 'order.shippingInfo.postalAddress.city' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressState OUT, 'order.shippingInfo.postalAddress.state' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressPostalCode OUT, 'order.shippingInfo.postalAddress.postalCode' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressCountry OUT, 'order.shippingInfo.postalAddress.country' EXEC sp_OAMethod @json, 'StringOf', @orderShippingInfoPostalAddressAddressType OUT, 'order.shippingInfo.postalAddress.addressType' SELECT @i = 0 EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'order.orderLines.orderLine' WHILE @i < @count_i BEGIN EXEC sp_OASetProperty @json, 'I', @i EXEC sp_OAMethod @json, 'StringOf', @lineNumber OUT, 'order.orderLines.orderLine[i].lineNumber' EXEC sp_OAMethod @json, 'StringOf', @itemProductName OUT, 'order.orderLines.orderLine[i].item.productName' EXEC sp_OAMethod @json, 'StringOf', @itemSku OUT, 'order.orderLines.orderLine[i].item.sku' EXEC sp_OAMethod @json, 'StringOf', @orderLineQuantityUnitOfMeasurement OUT, 'order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement' EXEC sp_OAMethod @json, 'StringOf', @orderLineQuantityAmount OUT, 'order.orderLines.orderLine[i].orderLineQuantity.amount' EXEC sp_OAMethod @json, 'IntOf', @statusDate OUT, 'order.orderLines.orderLine[i].statusDate' EXEC sp_OAMethod @json, 'IsNullOf', @refundRefundId OUT, 'order.orderLines.orderLine[i].refund.refundId' EXEC sp_OAMethod @json, 'IsNullOf', @refundRefundComments OUT, 'order.orderLines.orderLine[i].refund.refundComments' SELECT @j = 0 EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'order.orderLines.orderLine[i].charges.charge' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @json, 'J', @j EXEC sp_OAMethod @json, 'StringOf', @chargeType OUT, 'order.orderLines.orderLine[i].charges.charge[j].chargeType' EXEC sp_OAMethod @json, 'StringOf', @chargeName OUT, 'order.orderLines.orderLine[i].charges.charge[j].chargeName' EXEC sp_OAMethod @json, 'StringOf', @chargeAmountCurrency OUT, 'order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency' EXEC sp_OAMethod @json, 'IntOf', @chargeAmountAmount OUT, 'order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount' EXEC sp_OAMethod @json, 'StringOf', @taxTaxName OUT, 'order.orderLines.orderLine[i].charges.charge[j].tax.taxName' EXEC sp_OAMethod @json, 'StringOf', @taxTaxAmountCurrency OUT, 'order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency' EXEC sp_OAMethod @json, 'IntOf', @taxTaxAmountAmount OUT, 'order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount' SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @json, 'J', @j EXEC sp_OAMethod @json, 'StringOf', @status OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status' EXEC sp_OAMethod @json, 'StringOf', @statusQuantityUnitOfMeasurement OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement' EXEC sp_OAMethod @json, 'StringOf', @statusQuantityAmount OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount' EXEC sp_OAMethod @json, 'IsNullOf', @cancellationReason OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].cancellationReason' EXEC sp_OAMethod @json, 'IntOf', @trackingInfoShipDateTime OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime' EXEC sp_OAMethod @json, 'IsNullOf', @trackingInfoCarrierNameOtherCarrier OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.otherCarrier' EXEC sp_OAMethod @json, 'StringOf', @trackingInfoCarrierNameCarrier OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier' EXEC sp_OAMethod @json, 'StringOf', @trackingInfoMethodCode OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode' EXEC sp_OAMethod @json, 'StringOf', @trackingInfoTrackingNumber OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber' EXEC sp_OAMethod @json, 'StringOf', @trackingInfoTrackingURL OUT, 'order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL' SELECT @j = @j + 1 END SELECT @j = 0 EXEC sp_OAMethod @json, 'SizeOfArray', @count_j OUT, 'order.orderLines.orderLine[i].refund.refundCharges.refundCharge' WHILE @j < @count_j BEGIN EXEC sp_OASetProperty @json, 'J', @j EXEC sp_OAMethod @json, 'StringOf', @refundReason OUT, 'order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].refundReason' EXEC sp_OAMethod @json, 'StringOf', @chargeChargeType OUT, 'order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeType' EXEC sp_OAMethod @json, 'StringOf', @chargeChargeName OUT, 'order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeName' EXEC sp_OAMethod @json, 'StringOf', @chargeChargeAmountCurrency OUT, 'order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.currency' EXEC sp_OAMethod @json, 'IntOf', @chargeChargeAmountAmount OUT, 'order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.amount' EXEC sp_OAMethod @json, 'IsNullOf', @chargeTax OUT, 'order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.tax' SELECT @j = @j + 1 END SELECT @i = @i + 1 END PRINT 'Success!' -- Sample Walmart Order Acknowledge Response: -- { -- "order": { -- "purchaseOrderId": "1577684050862", -- "customerOrderId": "2861700797280", -- "customerEmailId": "jsanthanam@walmartlabs.com", -- "orderDate": 1484458949000, -- "shippingInfo": { -- "phone": "4151234567", -- "estimatedDeliveryDate": 1485586800000, -- "estimatedShipDate": 1484636400000, -- "methodCode": "Value", -- "postalAddress": { -- "name": "Asha Chakre", -- "address1": "860 W California ave", -- "address2": null, -- "city": "Sunnyvale", -- "state": "CA", -- "postalCode": "94086", -- "country": "USA", -- "addressType": "RESIDENTIAL" -- } -- }, -- "orderLines": { -- "orderLine": [ -- { -- "lineNumber": "1", -- "item": { -- "productName": "Kellogg's Rice Krispies Cereal, 24 oz", -- "sku": "MGR_07_21_00100123" -- }, -- "charges": { -- "charge": [ -- { -- "chargeType": "PRODUCT", -- "chargeName": "ItemPrice", -- "chargeAmount": { -- "currency": "USD", -- "amount": 19.99 -- }, -- "tax": { -- "taxName": "Tax1", -- "taxAmount": { -- "currency": "USD", -- "amount": 1.7 -- } -- } -- } -- ] -- }, -- "orderLineQuantity": { -- "unitOfMeasurement": "EACH", -- "amount": "1" -- }, -- "statusDate": 1487888747000, -- "orderLineStatuses": { -- "orderLineStatus": [ -- { -- "status": "Shipped", -- "statusQuantity": { -- "unitOfMeasurement": "EACH", -- "amount": "1" -- }, -- "cancellationReason": null, -- "trackingInfo": { -- "shipDateTime": 1485549015000, -- "carrierName": { -- "otherCarrier": null, -- "carrier": "FedEx" -- }, -- "methodCode": "Value", -- "trackingNumber": "3445435443441221", -- "trackingURL": "http://walmart.narvar.com/walmart/tracking/Fedex?&type=MP&seller_id=801&promise_date=01/28/2017&dzip=94086&tracking_numbers=3445435443441221" -- } -- } -- ] -- }, -- "refund": { -- "refundId": null, -- "refundComments": null, -- "refundCharges": { -- "refundCharge": [ -- { -- "refundReason": "ItemNotReceivedByCustomer", -- "charge": { -- "chargeType": "PRODUCT", -- "chargeName": "Lost in Transit", -- "chargeAmount": { -- "currency": "USD", -- "amount": -0.01 -- }, -- "tax": null -- } -- } -- ] -- } -- } -- } -- ] -- } -- } -- } EXEC @hr = sp_OADestroy @sbUrl EXEC @hr = sp_OADestroy @authUtil EXEC @hr = sp_OADestroy @json EXEC @hr = sp_OADestroy @http EXEC @hr = sp_OADestroy @sbBody END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.