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
(Android™) Walmart v3 Ship Order LinesSee more Walmart v3 ExamplesUpdates the status of order lines to Shipped and trigger the charge to the customer. The response to a successful call contains the order with the shipped line items. For more information, see https://developer.walmart.com/api/us/mp/orders#operation/shippingUpdates
// Important: Don't forget to include the call to System.loadLibrary // as shown at the bottom of this code sample. package com.test; import android.app.Activity; import com.chilkatsoft.*; import android.widget.TextView; import android.os.Bundle; public class SimpleActivity extends Activity { private static final String TAG = "Chilkat"; // Called when the activity is first created. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http = new CkHttp(); boolean success; http.SetRequestHeader("WM_QOS.CORRELATION_ID","b3261d2d-028a-4ef7-8602-633c23200af6"); http.SetRequestHeader("WM_SEC.ACCESS_TOKEN","eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM....."); http.SetRequestHeader("Accept","application/json"); http.SetRequestHeader("WM_SVC.NAME","Walmart Marketplace"); // Send the following in the request body: // { // "orderShipment": { // "orderLines": { // "orderLine": [ // { // "lineNumber": "1", // "intentToCancelOverride": false, // "sellerOrderId": "92344", // "orderLineStatuses": { // "orderLineStatus": [ // { // "status": "Shipped", // "statusQuantity": { // "unitOfMeasurement": "EACH", // "amount": "1" // }, // "trackingInfo": { // "shipDateTime": 1580821866000, // "carrierName": { // "carrier": "UPS" // }, // "methodCode": "Standard", // "trackingNumber": "22344", // "trackingURL": "http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345" // }, // "returnCenterAddress": { // "name": "walmart", // "address1": "walmart store 2", // "city": "Huntsville", // "state": "AL", // "postalCode": "35805", // "country": "USA", // "dayPhone": "12344", // "emailId": "walmart@walmart.com" // } // } // ] // } // }, // { // "lineNumber": "2", // "sellerOrderId": "92344", // "orderLineStatuses": { // "orderLineStatus": [ // { // "status": "Shipped", // "statusQuantity": { // "unitOfMeasurement": "EACH", // "amount": "1" // }, // "trackingInfo": { // "shipDateTime": 1580821866000, // "carrierName": { // "carrier": "FedEx" // }, // "methodCode": "Express", // "trackingNumber": "22344", // "trackingURL": "http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344" // }, // "returnCenterAddress": { // "name": "walmart", // "address1": "walmart store 2", // "city": "Huntsville", // "state": "AL", // "postalCode": "35805", // "country": "USA", // "dayPhone": "12344", // "emailId": "walmart@walmart.com" // } // } // ] // } // } // ] // } // } // } CkJsonObject json = new CkJsonObject(); int orderLineIndex = 0; int statusIndex = 0; json.put_I(orderLineIndex); json.put_J(statusIndex); json.UpdateString("orderShipment.orderLines.orderLine[i].lineNumber","1"); json.UpdateBool("orderShipment.orderLines.orderLine[i].intentToCancelOverride",false); json.UpdateString("orderShipment.orderLines.orderLine[i].sellerOrderId","92344"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1"); json.UpdateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","UPS"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Standard"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL","http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com"); orderLineIndex = orderLineIndex + 1; statusIndex = 0; json.put_I(orderLineIndex); json.put_J(statusIndex); json.UpdateString("orderShipment.orderLines.orderLine[i].lineNumber","2"); json.UpdateString("orderShipment.orderLines.orderLine[i].sellerOrderId","92344"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1"); json.UpdateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","FedEx"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Express"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL","http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344"); json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com"); CkHttpResponse resp = http.PostJson3("https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping","application/json",json); if (http.get_LastMethodSuccess() == false) { Log.i(TAG, http.lastErrorText()); return; } Log.i(TAG, "Response status code: " + String.valueOf(resp.get_StatusCode())); resp.GetBodyJson(json); // A sample JSON response: // { // "order": { // "purchaseOrderId": "1234567891234", // "customerOrderId": "9876543212345", // "sellerOrderId": "13233454564657", // "customerEmailId": "customer@walmartlabs.com", // "orderDate": 1478284060000, // "shippingInfo": { // "phone": "6501234567", // "estimatedDeliveryDate": 1479798000000, // "estimatedShipDate": 1478674800000, // "methodCode": "Value", // "postalAddress": { // "name": "Jane Doe", // "address1": "123 Main street", // "city": "Sunnyvale", // "state": "CA", // "postalCode": "94086", // "country": "USA", // "addressType": "OFFICE" // } // }, // "orderLines": { // "orderLine": [ // { // "lineNumber": "1", // "item": { // "productName": "Kenmore CF-1 or 20-86883 Canister Secondary Filter Generic 2 Pack", // "sku": "wei-ASSET-675gku675" // }, // "charges": { // "charge": [ // { // "chargeType": "PRODUCT", // "chargeName": "ItemPrice", // "chargeAmount": { // "currency": "USD", // "amount": 555 // }, // "tax": { // "taxName": "Tax1", // "taxAmount": { // "currency": "USD", // "amount": 48.56 // } // } // } // ] // }, // "orderLineQuantity": { // "unitOfMeasurement": "EACH", // "amount": "1" // }, // "statusDate": 1478297929000, // "orderLineStatuses": { // "orderLineStatus": [ // { // "status": "Shipped", // "statusQuantity": { // "unitOfMeasurement": "EACH", // "amount": "1" // }, // "trackingInfo": { // "shipDateTime": 1438163400000, // "carrierName": { // "carrier": "FedEx" // }, // "methodCode": "Value", // "trackingNumber": "911001572321619861", // "trackingURL": "http://www.fedex.com/Tracking?action=track=english=us=x=911001572321619861" // }, // "returnCenterAddress": { // "name": "ABC", // "address1": "123 Bridge street", // "city": "Huntsville", // "state": "AL", // "postalCode": "35805", // "country": "USA", // "dayPhone": "6501234567", // "emailId": "RCemailaddress@company.com" // } // } // ] // } // } // ] // } // } // } json.put_EmitCompact(false); Log.i(TAG, "Response JSON:"); Log.i(TAG, json.emit()); // Insert code here to load the above JSON into the json object. String lineNumber; String ProductName; String Sku; String UnitOfMeasurement; String Amount; int statusDate; int count_j; String chargeType; String chargeName; String v_Currency; int chargeAmountAmount; String TaxName; String TaxAmountCurrency; String TaxAmountAmount; String status; String statusQuantityUnitOfMeasurement; String statusQuantityAmount; int ShipDateTime; String Carrier; String trackingInfoMethodCode; String TrackingNumber; String TrackingURL; String returnCenterAddressName; String returnCenterAddressAddress1; String returnCenterAddressCity; String returnCenterAddressState; String returnCenterAddressPostalCode; String returnCenterAddressCountry; String DayPhone; String EmailId; String PurchaseOrderId = json.stringOf("order.purchaseOrderId"); String CustomerOrderId = json.stringOf("order.customerOrderId"); String SellerOrderId = json.stringOf("order.sellerOrderId"); String CustomerEmailId = json.stringOf("order.customerEmailId"); int OrderDate = json.IntOf("order.orderDate"); String Phone = json.stringOf("order.shippingInfo.phone"); int EstimatedDeliveryDate = json.IntOf("order.shippingInfo.estimatedDeliveryDate"); int EstimatedShipDate = json.IntOf("order.shippingInfo.estimatedShipDate"); String MethodCode = json.stringOf("order.shippingInfo.methodCode"); String Name = json.stringOf("order.shippingInfo.postalAddress.name"); String Address1 = json.stringOf("order.shippingInfo.postalAddress.address1"); String City = json.stringOf("order.shippingInfo.postalAddress.city"); String State = json.stringOf("order.shippingInfo.postalAddress.state"); String PostalCode = json.stringOf("order.shippingInfo.postalAddress.postalCode"); String Country = json.stringOf("order.shippingInfo.postalAddress.country"); String AddressType = json.stringOf("order.shippingInfo.postalAddress.addressType"); int i = 0; int j = 0; int count_i = json.SizeOfArray("order.orderLines.orderLine"); while (i < count_i) { json.put_I(i); lineNumber = json.stringOf("order.orderLines.orderLine[i].lineNumber"); ProductName = json.stringOf("order.orderLines.orderLine[i].item.productName"); Sku = json.stringOf("order.orderLines.orderLine[i].item.sku"); UnitOfMeasurement = json.stringOf("order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement"); Amount = json.stringOf("order.orderLines.orderLine[i].orderLineQuantity.amount"); statusDate = json.IntOf("order.orderLines.orderLine[i].statusDate"); j = 0; count_j = json.SizeOfArray("order.orderLines.orderLine[i].charges.charge"); while (j < count_j) { json.put_J(j); chargeType = json.stringOf("order.orderLines.orderLine[i].charges.charge[j].chargeType"); chargeName = json.stringOf("order.orderLines.orderLine[i].charges.charge[j].chargeName"); v_Currency = json.stringOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency"); chargeAmountAmount = json.IntOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount"); TaxName = json.stringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxName"); TaxAmountCurrency = json.stringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency"); TaxAmountAmount = json.stringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount"); j = j + 1; } j = 0; count_j = json.SizeOfArray("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus"); while (j < count_j) { json.put_J(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"); ShipDateTime = json.IntOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime"); Carrier = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier"); trackingInfoMethodCode = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode"); TrackingNumber = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber"); TrackingURL = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL"); returnCenterAddressName = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name"); returnCenterAddressAddress1 = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1"); returnCenterAddressCity = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city"); returnCenterAddressState = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state"); returnCenterAddressPostalCode = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode"); returnCenterAddressCountry = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country"); DayPhone = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone"); EmailId = json.stringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId"); j = j + 1; } i = i + 1; } } static { System.loadLibrary("chilkat"); // Note: If the incorrect library name is passed to System.loadLibrary, // then you will see the following error message at application startup: //"The application <your-application-name> has stopped unexpectedly. Please try again." } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.