Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) 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.
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkAuthUtil.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; --------------------------------------------------------------------------------------------------------- ; 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 sbUrl.i = CkStringBuilder::ckCreate() If sbUrl.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkStringBuilder::ckAppend(sbUrl,"https://marketplace.walmartapis.com/v3/orders/{purchaseOrderId}/acknowledge") numReplaced.i = CkStringBuilder::ckReplace(sbUrl,"{purchaseOrderId}","1111691995111") requestMethod.s = "POST" ; First we need to generate a signature for our request. ; The signature needs to be re-generated for each new Walmart HTTP request. authUtil.i = CkAuthUtil::ckCreate() If authUtil.i = 0 Debug "Failed to create object." ProcedureReturn EndIf wmConsumerId.s = "WALMART_CONSUMER_ID" wmPrivateKey.s = "WALMART_PRIVATE_KEY" jsonStr.s = CkAuthUtil::ckWalmartSignature(authUtil,CkStringBuilder::ckGetAsString(sbUrl),wmConsumerId,wmPrivateKey,requestMethod) If CkAuthUtil::ckLastMethodSuccess(authUtil) <> 1 Debug CkAuthUtil::ckLastErrorText(authUtil) CkStringBuilder::ckDispose(sbUrl) CkAuthUtil::ckDispose(authUtil) ProcedureReturn 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 json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(json,jsonStr) http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttp::ckSetRequestHeader(http,"WM_SVC.NAME","Walmart Marketplace") CkHttp::ckSetRequestHeader(http,"WM_QOS.CORRELATION_ID",CkJsonObject::ckStringOf(json,"correlation_id")) CkHttp::ckSetRequestHeader(http,"WM_SEC.TIMESTAMP",CkJsonObject::ckStringOf(json,"timestamp")) CkHttp::ckSetRequestHeader(http,"WM_SEC.AUTH_SIGNATURE",CkJsonObject::ckStringOf(json,"signature")) CkHttp::ckSetRequestHeader(http,"WM_CONSUMER.ID",wmConsumerId) ; Note: Make sure to replace "WALMART_CHANNEL_TYPE" with the actual value for your seller account... CkHttp::ckSetRequestHeader(http,"WM_CONSUMER.CHANNEL.TYPE","WALMART_CHANNEL_TYPE") CkHttp::setCkAccept(http, "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.) CkHttp::ckSetRequestHeader(http,"Accept","application/json") ; The body of this particular POST request contains just "{}". (The order ID is already in the URL path.) resp.i = CkHttp::ckPostJson2(http,CkStringBuilder::ckGetAsString(sbUrl),"application/json","{}") If CkHttp::ckLastMethodSuccess(http) <> 1 Debug CkHttp::ckLastErrorText(http) CkStringBuilder::ckDispose(sbUrl) CkAuthUtil::ckDispose(authUtil) CkJsonObject::ckDispose(json) CkHttp::ckDispose(http) ProcedureReturn EndIf ; Get the JSON response body, which could contain an error, or if successful contains ; the acknowledged order. sbBody.i = CkStringBuilder::ckCreate() If sbBody.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttpResponse::ckGetBodySb(resp,sbBody) ; A successful response should have a 200 response status If CkHttpResponse::ckStatusCode(resp) <> 200 Debug CkStringBuilder::ckGetAsString(sbBody) Debug "Response Status Code: " + Str(CkHttpResponse::ckStatusCode(resp)) Debug "Failed." CkHttpResponse::ckDispose(resp) CkStringBuilder::ckDispose(sbUrl) CkAuthUtil::ckDispose(authUtil) CkJsonObject::ckDispose(json) CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbBody) ProcedureReturn EndIf CkHttpResponse::ckDispose(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 CkJsonObject::ckLoadSb(json,sbBody) orderPurchaseOrderId.s orderCustomerOrderId.s orderCustomerEmailId.s orderOrderDate.i orderShippingInfoPhone.s orderShippingInfoEstimatedDeliveryDate.i orderShippingInfoEstimatedShipDate.i orderShippingInfoMethodCode.s orderShippingInfoPostalAddressName.s orderShippingInfoPostalAddressAddress1.s orderShippingInfoPostalAddressAddress2.s orderShippingInfoPostalAddressCity.s orderShippingInfoPostalAddressState.s orderShippingInfoPostalAddressPostalCode.s orderShippingInfoPostalAddressCountry.s orderShippingInfoPostalAddressAddressType.s i.i count_i.i lineNumber.s itemProductName.s itemSku.s orderLineQuantityUnitOfMeasurement.s orderLineQuantityAmount.s statusDate.i refundRefundId.i refundRefundComments.i j.i count_j.i chargeType.s chargeName.s chargeAmountCurrency.s chargeAmountAmount.i taxTaxName.s taxTaxAmountCurrency.s taxTaxAmountAmount.i status.s statusQuantityUnitOfMeasurement.s statusQuantityAmount.s cancellationReason.i trackingInfoShipDateTime.i trackingInfoCarrierNameOtherCarrier.i trackingInfoCarrierNameCarrier.s trackingInfoMethodCode.s trackingInfoTrackingNumber.s trackingInfoTrackingURL.s refundReason.s chargeChargeType.s chargeChargeName.s chargeChargeAmountCurrency.s chargeChargeAmountAmount.i chargeTax.i orderPurchaseOrderId = CkJsonObject::ckStringOf(json,"order.purchaseOrderId") orderCustomerOrderId = CkJsonObject::ckStringOf(json,"order.customerOrderId") orderCustomerEmailId = CkJsonObject::ckStringOf(json,"order.customerEmailId") orderOrderDate = CkJsonObject::ckIntOf(json,"order.orderDate") orderShippingInfoPhone = CkJsonObject::ckStringOf(json,"order.shippingInfo.phone") orderShippingInfoEstimatedDeliveryDate = CkJsonObject::ckIntOf(json,"order.shippingInfo.estimatedDeliveryDate") orderShippingInfoEstimatedShipDate = CkJsonObject::ckIntOf(json,"order.shippingInfo.estimatedShipDate") orderShippingInfoMethodCode = CkJsonObject::ckStringOf(json,"order.shippingInfo.methodCode") orderShippingInfoPostalAddressName = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.name") orderShippingInfoPostalAddressAddress1 = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.address1") orderShippingInfoPostalAddressAddress2 = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.address2") orderShippingInfoPostalAddressCity = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.city") orderShippingInfoPostalAddressState = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.state") orderShippingInfoPostalAddressPostalCode = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.postalCode") orderShippingInfoPostalAddressCountry = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.country") orderShippingInfoPostalAddressAddressType = CkJsonObject::ckStringOf(json,"order.shippingInfo.postalAddress.addressType") i = 0 count_i = CkJsonObject::ckSizeOfArray(json,"order.orderLines.orderLine") While i < count_i CkJsonObject::setCkI(json, i) lineNumber = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].lineNumber") itemProductName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].item.productName") itemSku = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].item.sku") orderLineQuantityUnitOfMeasurement = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement") orderLineQuantityAmount = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineQuantity.amount") statusDate = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].statusDate") refundRefundId = CkJsonObject::ckIsNullOf(json,"order.orderLines.orderLine[i].refund.refundId") refundRefundComments = CkJsonObject::ckIsNullOf(json,"order.orderLines.orderLine[i].refund.refundComments") j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"order.orderLines.orderLine[i].charges.charge") While j < count_j CkJsonObject::setCkJ(json, j) chargeType = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeType") chargeName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeName") chargeAmountCurrency = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency") chargeAmountAmount = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount") taxTaxName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxName") taxTaxAmountCurrency = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency") taxTaxAmountAmount = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount") j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus") While j < count_j CkJsonObject::setCkJ(json, j) status = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status") statusQuantityUnitOfMeasurement = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement") statusQuantityAmount = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount") cancellationReason = CkJsonObject::ckIsNullOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].cancellationReason") trackingInfoShipDateTime = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime") trackingInfoCarrierNameOtherCarrier = CkJsonObject::ckIsNullOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.otherCarrier") trackingInfoCarrierNameCarrier = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier") trackingInfoMethodCode = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode") trackingInfoTrackingNumber = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber") trackingInfoTrackingURL = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL") j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"order.orderLines.orderLine[i].refund.refundCharges.refundCharge") While j < count_j CkJsonObject::setCkJ(json, j) refundReason = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].refundReason") chargeChargeType = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeType") chargeChargeName = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeName") chargeChargeAmountCurrency = CkJsonObject::ckStringOf(json,"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.currency") chargeChargeAmountAmount = CkJsonObject::ckIntOf(json,"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.amount") chargeTax = CkJsonObject::ckIsNullOf(json,"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.tax") j = j + 1 Wend i = i + 1 Wend Debug "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 ; } ; } ; ] ; } ; } ; } ; ] ; } ; } ; } CkStringBuilder::ckDispose(sbUrl) CkAuthUtil::ckDispose(authUtil) CkJsonObject::ckDispose(json) CkHttp::ckDispose(http) CkStringBuilder::ckDispose(sbBody) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.