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
(Objective-C) 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.
#import <CkoStringBuilder.h> #import <NSString.h> #import <CkoAuthUtil.h> #import <CkoJsonObject.h> #import <CkoHttp.h> #import <CkoHttpResponse.h> // --------------------------------------------------------------------------------------------------------- // 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 CkoStringBuilder *sbUrl = [[CkoStringBuilder alloc] init]; BOOL success = [sbUrl Append: @"https://marketplace.walmartapis.com/v3/orders/{purchaseOrderId}/acknowledge"]; int numReplaced = [[sbUrl Replace: @"{purchaseOrderId}" replacement: @"1111691995111"] intValue]; NSString *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. CkoAuthUtil *authUtil = [[CkoAuthUtil alloc] init]; NSString *wmConsumerId = @"WALMART_CONSUMER_ID"; NSString *wmPrivateKey = @"WALMART_PRIVATE_KEY"; NSString *jsonStr = [authUtil WalmartSignature: [sbUrl GetAsString] consumerId: wmConsumerId privateKey: wmPrivateKey requestMethod: requestMethod]; if (authUtil.LastMethodSuccess != YES) { NSLog(@"%@",authUtil.LastErrorText); return; } // 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 CkoJsonObject *json = [[CkoJsonObject alloc] init]; [json Load: jsonStr]; CkoHttp *http = [[CkoHttp alloc] init]; [http SetRequestHeader: @"WM_SVC.NAME" value: @"Walmart Marketplace"]; [http SetRequestHeader: @"WM_QOS.CORRELATION_ID" value: [json StringOf: @"correlation_id"]]; [http SetRequestHeader: @"WM_SEC.TIMESTAMP" value: [json StringOf: @"timestamp"]]; [http SetRequestHeader: @"WM_SEC.AUTH_SIGNATURE" value: [json StringOf: @"signature"]]; [http SetRequestHeader: @"WM_CONSUMER.ID" value: wmConsumerId]; // Note: Make sure to replace "WALMART_CHANNEL_TYPE" with the actual value for your seller account... [http SetRequestHeader: @"WM_CONSUMER.CHANNEL.TYPE" value: @"WALMART_CHANNEL_TYPE"]; 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.) [http SetRequestHeader: @"Accept" value: @"application/json"]; // The body of this particular POST request contains just "{}". (The order ID is already in the URL path.) CkoHttpResponse *resp = [http PostJson2: [sbUrl GetAsString] contentType: @"application/json" jsonText: @"{}"]; if (http.LastMethodSuccess != YES) { NSLog(@"%@",http.LastErrorText); return; } // Get the JSON response body, which could contain an error, or if successful contains // the acknowledged order. CkoStringBuilder *sbBody = [[CkoStringBuilder alloc] init]; [resp GetBodySb: sbBody]; // A successful response should have a 200 response status if ([resp.StatusCode intValue] != 200) { NSLog(@"%@",[sbBody GetAsString]); NSLog(@"%@%d",@"Response Status Code: ",[resp.StatusCode intValue]); NSLog(@"%@",@"Failed."); return; } // 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 [json LoadSb: sbBody]; NSString *orderPurchaseOrderId = 0; NSString *orderCustomerOrderId = 0; NSString *orderCustomerEmailId = 0; int orderOrderDate; NSString *orderShippingInfoPhone = 0; int orderShippingInfoEstimatedDeliveryDate; int orderShippingInfoEstimatedShipDate; NSString *orderShippingInfoMethodCode = 0; NSString *orderShippingInfoPostalAddressName = 0; NSString *orderShippingInfoPostalAddressAddress1 = 0; NSString *orderShippingInfoPostalAddressAddress2 = 0; NSString *orderShippingInfoPostalAddressCity = 0; NSString *orderShippingInfoPostalAddressState = 0; NSString *orderShippingInfoPostalAddressPostalCode = 0; NSString *orderShippingInfoPostalAddressCountry = 0; NSString *orderShippingInfoPostalAddressAddressType = 0; int i; int count_i; NSString *lineNumber = 0; NSString *itemProductName = 0; NSString *itemSku = 0; NSString *orderLineQuantityUnitOfMeasurement = 0; NSString *orderLineQuantityAmount = 0; int statusDate; BOOL refundRefundId; BOOL refundRefundComments; int j; int count_j; NSString *chargeType = 0; NSString *chargeName = 0; NSString *chargeAmountCurrency = 0; int chargeAmountAmount; NSString *taxTaxName = 0; NSString *taxTaxAmountCurrency = 0; int taxTaxAmountAmount; NSString *status = 0; NSString *statusQuantityUnitOfMeasurement = 0; NSString *statusQuantityAmount = 0; BOOL cancellationReason; int trackingInfoShipDateTime; BOOL trackingInfoCarrierNameOtherCarrier; NSString *trackingInfoCarrierNameCarrier = 0; NSString *trackingInfoMethodCode = 0; NSString *trackingInfoTrackingNumber = 0; NSString *trackingInfoTrackingURL = 0; NSString *refundReason = 0; NSString *chargeChargeType = 0; NSString *chargeChargeName = 0; NSString *chargeChargeAmountCurrency = 0; int chargeChargeAmountAmount; BOOL chargeTax; orderPurchaseOrderId = [json StringOf: @"order.purchaseOrderId"]; orderCustomerOrderId = [json StringOf: @"order.customerOrderId"]; orderCustomerEmailId = [json StringOf: @"order.customerEmailId"]; orderOrderDate = [[json IntOf: @"order.orderDate"] intValue]; orderShippingInfoPhone = [json StringOf: @"order.shippingInfo.phone"]; orderShippingInfoEstimatedDeliveryDate = [[json IntOf: @"order.shippingInfo.estimatedDeliveryDate"] intValue]; orderShippingInfoEstimatedShipDate = [[json IntOf: @"order.shippingInfo.estimatedShipDate"] intValue]; orderShippingInfoMethodCode = [json StringOf: @"order.shippingInfo.methodCode"]; orderShippingInfoPostalAddressName = [json StringOf: @"order.shippingInfo.postalAddress.name"]; orderShippingInfoPostalAddressAddress1 = [json StringOf: @"order.shippingInfo.postalAddress.address1"]; orderShippingInfoPostalAddressAddress2 = [json StringOf: @"order.shippingInfo.postalAddress.address2"]; orderShippingInfoPostalAddressCity = [json StringOf: @"order.shippingInfo.postalAddress.city"]; orderShippingInfoPostalAddressState = [json StringOf: @"order.shippingInfo.postalAddress.state"]; orderShippingInfoPostalAddressPostalCode = [json StringOf: @"order.shippingInfo.postalAddress.postalCode"]; orderShippingInfoPostalAddressCountry = [json StringOf: @"order.shippingInfo.postalAddress.country"]; orderShippingInfoPostalAddressAddressType = [json StringOf: @"order.shippingInfo.postalAddress.addressType"]; i = 0; count_i = [[json SizeOfArray: @"order.orderLines.orderLine"] intValue]; while (i < count_i) { json.I = [NSNumber numberWithInt: i]; lineNumber = [json StringOf: @"order.orderLines.orderLine[i].lineNumber"]; itemProductName = [json StringOf: @"order.orderLines.orderLine[i].item.productName"]; itemSku = [json StringOf: @"order.orderLines.orderLine[i].item.sku"]; orderLineQuantityUnitOfMeasurement = [json StringOf: @"order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement"]; orderLineQuantityAmount = [json StringOf: @"order.orderLines.orderLine[i].orderLineQuantity.amount"]; statusDate = [[json IntOf: @"order.orderLines.orderLine[i].statusDate"] intValue]; refundRefundId = [json IsNullOf: @"order.orderLines.orderLine[i].refund.refundId"]; refundRefundComments = [json IsNullOf: @"order.orderLines.orderLine[i].refund.refundComments"]; j = 0; count_j = [[json SizeOfArray: @"order.orderLines.orderLine[i].charges.charge"] intValue]; while (j < count_j) { json.J = [NSNumber numberWithInt: j]; chargeType = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeType"]; chargeName = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeName"]; chargeAmountCurrency = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency"]; chargeAmountAmount = [[json IntOf: @"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount"] intValue]; taxTaxName = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].tax.taxName"]; taxTaxAmountCurrency = [json StringOf: @"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency"]; taxTaxAmountAmount = [[json IntOf: @"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount"] intValue]; j = j + 1; } j = 0; count_j = [[json SizeOfArray: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus"] intValue]; while (j < count_j) { json.J = [NSNumber numberWithInt: j]; status = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status"]; statusQuantityUnitOfMeasurement = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement"]; statusQuantityAmount = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount"]; cancellationReason = [json IsNullOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].cancellationReason"]; trackingInfoShipDateTime = [[json IntOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime"] intValue]; trackingInfoCarrierNameOtherCarrier = [json IsNullOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.otherCarrier"]; trackingInfoCarrierNameCarrier = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier"]; trackingInfoMethodCode = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode"]; trackingInfoTrackingNumber = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber"]; trackingInfoTrackingURL = [json StringOf: @"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL"]; j = j + 1; } j = 0; count_j = [[json SizeOfArray: @"order.orderLines.orderLine[i].refund.refundCharges.refundCharge"] intValue]; while (j < count_j) { json.J = [NSNumber numberWithInt: j]; refundReason = [json StringOf: @"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].refundReason"]; chargeChargeType = [json StringOf: @"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeType"]; chargeChargeName = [json StringOf: @"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeName"]; chargeChargeAmountCurrency = [json StringOf: @"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.currency"]; chargeChargeAmountAmount = [[json IntOf: @"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.amount"] intValue]; chargeTax = [json IsNullOf: @"order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.tax"]; j = j + 1; } i = i + 1; } NSLog(@"%@",@"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 // } // } // ] // } // } // } // ] // } // } // } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.