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
(Tcl) 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.
load ./chilkat.dll # --------------------------------------------------------------------------------------------------------- # 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 set sbUrl [new_CkStringBuilder] set success [CkStringBuilder_Append $sbUrl "https://marketplace.walmartapis.com/v3/orders/{purchaseOrderId}/acknowledge"] set numReplaced [CkStringBuilder_Replace $sbUrl "{purchaseOrderId}" "1111691995111"] set 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. set authUtil [new_CkAuthUtil] set wmConsumerId "WALMART_CONSUMER_ID" set wmPrivateKey "WALMART_PRIVATE_KEY" set jsonStr [CkAuthUtil_walmartSignature $authUtil [CkStringBuilder_getAsString $sbUrl] $wmConsumerId $wmPrivateKey $requestMethod] if {[CkAuthUtil_get_LastMethodSuccess $authUtil] != 1} then { puts [CkAuthUtil_lastErrorText $authUtil] delete_CkStringBuilder $sbUrl delete_CkAuthUtil $authUtil exit } # 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 set json [new_CkJsonObject] CkJsonObject_Load $json $jsonStr set http [new_CkHttp] CkHttp_SetRequestHeader $http "WM_SVC.NAME" "Walmart Marketplace" CkHttp_SetRequestHeader $http "WM_QOS.CORRELATION_ID" [CkJsonObject_stringOf $json "correlation_id"] CkHttp_SetRequestHeader $http "WM_SEC.TIMESTAMP" [CkJsonObject_stringOf $json "timestamp"] CkHttp_SetRequestHeader $http "WM_SEC.AUTH_SIGNATURE" [CkJsonObject_stringOf $json "signature"] CkHttp_SetRequestHeader $http "WM_CONSUMER.ID" $wmConsumerId # Note: Make sure to replace "WALMART_CHANNEL_TYPE" with the actual value for your seller account... CkHttp_SetRequestHeader $http "WM_CONSUMER.CHANNEL.TYPE" "WALMART_CHANNEL_TYPE" CkHttp_put_Accept $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_SetRequestHeader $http "Accept" "application/json" # The body of this particular POST request contains just "{}". (The order ID is already in the URL path.) # resp is a CkHttpResponse set resp [CkHttp_PostJson2 $http [CkStringBuilder_getAsString $sbUrl] "application/json" "{}"] if {[CkHttp_get_LastMethodSuccess $http] != 1} then { puts [CkHttp_lastErrorText $http] delete_CkStringBuilder $sbUrl delete_CkAuthUtil $authUtil delete_CkJsonObject $json delete_CkHttp $http exit } # Get the JSON response body, which could contain an error, or if successful contains # the acknowledged order. set sbBody [new_CkStringBuilder] CkHttpResponse_GetBodySb $resp $sbBody # A successful response should have a 200 response status if {[CkHttpResponse_get_StatusCode $resp] != 200} then { puts [CkStringBuilder_getAsString $sbBody] puts "Response Status Code: [CkHttpResponse_get_StatusCode $resp]" puts "Failed." delete_CkHttpResponse $resp delete_CkStringBuilder $sbUrl delete_CkAuthUtil $authUtil delete_CkJsonObject $json delete_CkHttp $http delete_CkStringBuilder $sbBody exit } delete_CkHttpResponse $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_LoadSb $json $sbBody set orderPurchaseOrderId [CkJsonObject_stringOf $json "order.purchaseOrderId"] set orderCustomerOrderId [CkJsonObject_stringOf $json "order.customerOrderId"] set orderCustomerEmailId [CkJsonObject_stringOf $json "order.customerEmailId"] set orderOrderDate [CkJsonObject_IntOf $json "order.orderDate"] set orderShippingInfoPhone [CkJsonObject_stringOf $json "order.shippingInfo.phone"] set orderShippingInfoEstimatedDeliveryDate [CkJsonObject_IntOf $json "order.shippingInfo.estimatedDeliveryDate"] set orderShippingInfoEstimatedShipDate [CkJsonObject_IntOf $json "order.shippingInfo.estimatedShipDate"] set orderShippingInfoMethodCode [CkJsonObject_stringOf $json "order.shippingInfo.methodCode"] set orderShippingInfoPostalAddressName [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.name"] set orderShippingInfoPostalAddressAddress1 [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.address1"] set orderShippingInfoPostalAddressAddress2 [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.address2"] set orderShippingInfoPostalAddressCity [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.city"] set orderShippingInfoPostalAddressState [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.state"] set orderShippingInfoPostalAddressPostalCode [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.postalCode"] set orderShippingInfoPostalAddressCountry [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.country"] set orderShippingInfoPostalAddressAddressType [CkJsonObject_stringOf $json "order.shippingInfo.postalAddress.addressType"] set i 0 set count_i [CkJsonObject_SizeOfArray $json "order.orderLines.orderLine"] while {$i < $count_i} { CkJsonObject_put_I $json $i set lineNumber [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].lineNumber"] set itemProductName [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].item.productName"] set itemSku [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].item.sku"] set orderLineQuantityUnitOfMeasurement [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement"] set orderLineQuantityAmount [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineQuantity.amount"] set statusDate [CkJsonObject_IntOf $json "order.orderLines.orderLine[i].statusDate"] set refundRefundId [CkJsonObject_IsNullOf $json "order.orderLines.orderLine[i].refund.refundId"] set refundRefundComments [CkJsonObject_IsNullOf $json "order.orderLines.orderLine[i].refund.refundComments"] set j 0 set count_j [CkJsonObject_SizeOfArray $json "order.orderLines.orderLine[i].charges.charge"] while {$j < $count_j} { CkJsonObject_put_J $json $j set chargeType [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].charges.charge[j].chargeType"] set chargeName [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].charges.charge[j].chargeName"] set chargeAmountCurrency [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency"] set chargeAmountAmount [CkJsonObject_IntOf $json "order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount"] set taxTaxName [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].charges.charge[j].tax.taxName"] set taxTaxAmountCurrency [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency"] set taxTaxAmountAmount [CkJsonObject_IntOf $json "order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus"] while {$j < $count_j} { CkJsonObject_put_J $json $j set status [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status"] set statusQuantityUnitOfMeasurement [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement"] set statusQuantityAmount [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount"] set cancellationReason [CkJsonObject_IsNullOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].cancellationReason"] set trackingInfoShipDateTime [CkJsonObject_IntOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime"] set trackingInfoCarrierNameOtherCarrier [CkJsonObject_IsNullOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.otherCarrier"] set trackingInfoCarrierNameCarrier [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier"] set trackingInfoMethodCode [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode"] set trackingInfoTrackingNumber [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber"] set trackingInfoTrackingURL [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $json "order.orderLines.orderLine[i].refund.refundCharges.refundCharge"] while {$j < $count_j} { CkJsonObject_put_J $json $j set refundReason [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].refundReason"] set chargeChargeType [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeType"] set chargeChargeName [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeName"] set chargeChargeAmountCurrency [CkJsonObject_stringOf $json "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.currency"] set chargeChargeAmountAmount [CkJsonObject_IntOf $json "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.amount"] set chargeTax [CkJsonObject_IsNullOf $json "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.tax"] set j [expr $j + 1] } set i [expr $i + 1] } puts "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 # } # } # ] # } # } # } # ] # } # } # } delete_CkStringBuilder $sbUrl delete_CkAuthUtil $authUtil delete_CkJsonObject $json delete_CkHttp $http delete_CkStringBuilder $sbBody |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.