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
(AutoIt) 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.
; --------------------------------------------------------------------------------------------------------- ; 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 $oSbUrl = ObjCreate("Chilkat_9_5_0.StringBuilder") Local $bSuccess = $oSbUrl.Append("https://marketplace.walmartapis.com/v3/orders/{purchaseOrderId}/acknowledge") Local $iNumReplaced = $oSbUrl.Replace("{purchaseOrderId}","1111691995111") Local $sRequestMethod = "POST" ; First we need to generate a signature for our request. ; The signature needs to be re-generated for each new Walmart HTTP request. $oAuthUtil = ObjCreate("Chilkat_9_5_0.AuthUtil") Local $sWmConsumerId = "WALMART_CONSUMER_ID" Local $sWmPrivateKey = "WALMART_PRIVATE_KEY" Local $sJsonStr = $oAuthUtil.WalmartSignature($oSbUrl.GetAsString(),$sWmConsumerId,$sWmPrivateKey,$sRequestMethod) If ($oAuthUtil.LastMethodSuccess <> True) Then ConsoleWrite($oAuthUtil.LastErrorText & @CRLF) Exit EndIf ; 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 $oJson = ObjCreate("Chilkat_9_5_0.JsonObject") $oJson.Load($sJsonStr) $oHttp = ObjCreate("Chilkat_9_5_0.Http") $oHttp.SetRequestHeader "WM_SVC.NAME","Walmart Marketplace" $oHttp.SetRequestHeader "WM_QOS.CORRELATION_ID",$oJson.StringOf("correlation_id") $oHttp.SetRequestHeader "WM_SEC.TIMESTAMP",$oJson.StringOf("timestamp") $oHttp.SetRequestHeader "WM_SEC.AUTH_SIGNATURE",$oJson.StringOf("signature") $oHttp.SetRequestHeader "WM_CONSUMER.ID",$sWmConsumerId ; Note: Make sure to replace "WALMART_CHANNEL_TYPE" with the actual value for your seller account... $oHttp.SetRequestHeader "WM_CONSUMER.CHANNEL.TYPE","WALMART_CHANNEL_TYPE" $oHttp.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.) $oHttp.SetRequestHeader "Accept","application/json" ; The body of this particular POST request contains just "{}". (The order ID is already in the URL path.) Local $oResp = $oHttp.PostJson2($oSbUrl.GetAsString(),"application/json","{}") If ($oHttp.LastMethodSuccess <> True) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf ; Get the JSON response body, which could contain an error, or if successful contains ; the acknowledged order. $oSbBody = ObjCreate("Chilkat_9_5_0.StringBuilder") $oResp.GetBodySb($oSbBody) ; A successful response should have a 200 response status If ($oResp.StatusCode <> 200) Then ConsoleWrite($oSbBody.GetAsString() & @CRLF) ConsoleWrite("Response Status Code: " & $oResp.StatusCode & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf ; 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 $oJson.LoadSb($oSbBody) Local $sOrderPurchaseOrderId Local $sOrderCustomerOrderId Local $sOrderCustomerEmailId Local $iOrderOrderDate Local $sOrderShippingInfoPhone Local $iOrderShippingInfoEstimatedDeliveryDate Local $iOrderShippingInfoEstimatedShipDate Local $sOrderShippingInfoMethodCode Local $sOrderShippingInfoPostalAddressName Local $sOrderShippingInfoPostalAddressAddress1 Local $sOrderShippingInfoPostalAddressAddress2 Local $sOrderShippingInfoPostalAddressCity Local $sOrderShippingInfoPostalAddressState Local $sOrderShippingInfoPostalAddressPostalCode Local $sOrderShippingInfoPostalAddressCountry Local $sOrderShippingInfoPostalAddressAddressType Local $i Local $iCount_i Local $sLineNumber Local $sItemProductName Local $sItemSku Local $sOrderLineQuantityUnitOfMeasurement Local $sOrderLineQuantityAmount Local $iStatusDate Local $bRefundRefundId Local $bRefundRefundComments Local $iJ Local $iCount_j Local $sChargeType Local $sChargeName Local $sChargeAmountCurrency Local $iChargeAmountAmount Local $sTaxTaxName Local $sTaxTaxAmountCurrency Local $iTaxTaxAmountAmount Local $status Local $statusQuantityUnitOfMeasurement Local $statusQuantityAmount Local $bCancellationReason Local $iTrackingInfoShipDateTime Local $bTrackingInfoCarrierNameOtherCarrier Local $sTrackingInfoCarrierNameCarrier Local $sTrackingInfoMethodCode Local $sTrackingInfoTrackingNumber Local $sTrackingInfoTrackingURL Local $sRefundReason Local $sChargeChargeType Local $sChargeChargeName Local $sChargeChargeAmountCurrency Local $iChargeChargeAmountAmount Local $bChargeTax $sOrderPurchaseOrderId = $oJson.StringOf("order.purchaseOrderId") $sOrderCustomerOrderId = $oJson.StringOf("order.customerOrderId") $sOrderCustomerEmailId = $oJson.StringOf("order.customerEmailId") $iOrderOrderDate = $oJson.IntOf("order.orderDate") $sOrderShippingInfoPhone = $oJson.StringOf("order.shippingInfo.phone") $iOrderShippingInfoEstimatedDeliveryDate = $oJson.IntOf("order.shippingInfo.estimatedDeliveryDate") $iOrderShippingInfoEstimatedShipDate = $oJson.IntOf("order.shippingInfo.estimatedShipDate") $sOrderShippingInfoMethodCode = $oJson.StringOf("order.shippingInfo.methodCode") $sOrderShippingInfoPostalAddressName = $oJson.StringOf("order.shippingInfo.postalAddress.name") $sOrderShippingInfoPostalAddressAddress1 = $oJson.StringOf("order.shippingInfo.postalAddress.address1") $sOrderShippingInfoPostalAddressAddress2 = $oJson.StringOf("order.shippingInfo.postalAddress.address2") $sOrderShippingInfoPostalAddressCity = $oJson.StringOf("order.shippingInfo.postalAddress.city") $sOrderShippingInfoPostalAddressState = $oJson.StringOf("order.shippingInfo.postalAddress.state") $sOrderShippingInfoPostalAddressPostalCode = $oJson.StringOf("order.shippingInfo.postalAddress.postalCode") $sOrderShippingInfoPostalAddressCountry = $oJson.StringOf("order.shippingInfo.postalAddress.country") $sOrderShippingInfoPostalAddressAddressType = $oJson.StringOf("order.shippingInfo.postalAddress.addressType") $i = 0 $iCount_i = $oJson.SizeOfArray("order.orderLines.orderLine") While $i < $iCount_i $oJson.I = $i $sLineNumber = $oJson.StringOf("order.orderLines.orderLine[i].lineNumber") $sItemProductName = $oJson.StringOf("order.orderLines.orderLine[i].item.productName") $sItemSku = $oJson.StringOf("order.orderLines.orderLine[i].item.sku") $sOrderLineQuantityUnitOfMeasurement = $oJson.StringOf("order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement") $sOrderLineQuantityAmount = $oJson.StringOf("order.orderLines.orderLine[i].orderLineQuantity.amount") $iStatusDate = $oJson.IntOf("order.orderLines.orderLine[i].statusDate") $bRefundRefundId = $oJson.IsNullOf("order.orderLines.orderLine[i].refund.refundId") $bRefundRefundComments = $oJson.IsNullOf("order.orderLines.orderLine[i].refund.refundComments") $iJ = 0 $iCount_j = $oJson.SizeOfArray("order.orderLines.orderLine[i].charges.charge") While $iJ < $iCount_j $oJson.J = $iJ $sChargeType = $oJson.StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeType") $sChargeName = $oJson.StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeName") $sChargeAmountCurrency = $oJson.StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency") $iChargeAmountAmount = $oJson.IntOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount") $sTaxTaxName = $oJson.StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxName") $sTaxTaxAmountCurrency = $oJson.StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency") $iTaxTaxAmountAmount = $oJson.IntOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount") $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJson.SizeOfArray("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus") While $iJ < $iCount_j $oJson.J = $iJ $status = $oJson.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status") $statusQuantityUnitOfMeasurement = $oJson.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement") $statusQuantityAmount = $oJson.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount") $bCancellationReason = $oJson.IsNullOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].cancellationReason") $iTrackingInfoShipDateTime = $oJson.IntOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime") $bTrackingInfoCarrierNameOtherCarrier = $oJson.IsNullOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.otherCarrier") $sTrackingInfoCarrierNameCarrier = $oJson.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier") $sTrackingInfoMethodCode = $oJson.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode") $sTrackingInfoTrackingNumber = $oJson.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber") $sTrackingInfoTrackingURL = $oJson.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL") $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJson.SizeOfArray("order.orderLines.orderLine[i].refund.refundCharges.refundCharge") While $iJ < $iCount_j $oJson.J = $iJ $sRefundReason = $oJson.StringOf("order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].refundReason") $sChargeChargeType = $oJson.StringOf("order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeType") $sChargeChargeName = $oJson.StringOf("order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeName") $sChargeChargeAmountCurrency = $oJson.StringOf("order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.currency") $iChargeChargeAmountAmount = $oJson.IntOf("order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.amount") $bChargeTax = $oJson.IsNullOf("order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.tax") $iJ = $iJ + 1 Wend $i = $i + 1 Wend ConsoleWrite("Success!" & @CRLF) ; 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 ; } ; } ; ] ; } ; } ; } ; ] ; } ; } ; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.