Sample code for 30+ languages & platforms
Unicode C

Walmart v3 Ship Order Lines

See more Walmart v3 Examples

Updates 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.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttpW http;
    HCkJsonObjectW json;
    int orderLineIndex;
    int statusIndex;
    HCkHttpResponseW resp;
    const wchar_t *lineNumber;
    const wchar_t *ProductName;
    const wchar_t *Sku;
    const wchar_t *UnitOfMeasurement;
    const wchar_t *Amount;
    int statusDate;
    int count_j;
    const wchar_t *chargeType;
    const wchar_t *chargeName;
    const wchar_t *v_Currency;
    int chargeAmountAmount;
    const wchar_t *TaxName;
    const wchar_t *TaxAmountCurrency;
    const wchar_t *TaxAmountAmount;
    const wchar_t *status;
    const wchar_t *statusQuantityUnitOfMeasurement;
    const wchar_t *statusQuantityAmount;
    int ShipDateTime;
    const wchar_t *Carrier;
    const wchar_t *trackingInfoMethodCode;
    const wchar_t *TrackingNumber;
    const wchar_t *TrackingURL;
    const wchar_t *returnCenterAddressName;
    const wchar_t *returnCenterAddressAddress1;
    const wchar_t *returnCenterAddressCity;
    const wchar_t *returnCenterAddressState;
    const wchar_t *returnCenterAddressPostalCode;
    const wchar_t *returnCenterAddressCountry;
    const wchar_t *DayPhone;
    const wchar_t *EmailId;
    const wchar_t *PurchaseOrderId;
    const wchar_t *CustomerOrderId;
    const wchar_t *SellerOrderId;
    const wchar_t *CustomerEmailId;
    int OrderDate;
    const wchar_t *Phone;
    int EstimatedDeliveryDate;
    int EstimatedShipDate;
    const wchar_t *MethodCode;
    const wchar_t *Name;
    const wchar_t *Address1;
    const wchar_t *City;
    const wchar_t *State;
    const wchar_t *PostalCode;
    const wchar_t *Country;
    const wchar_t *AddressType;
    int i;
    int j;
    int count_i;

    success = FALSE;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    CkHttpW_SetRequestHeader(http,L"WM_QOS.CORRELATION_ID",L"b3261d2d-028a-4ef7-8602-633c23200af6");
    CkHttpW_SetRequestHeader(http,L"WM_SEC.ACCESS_TOKEN",L"eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....");
    CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");
    CkHttpW_SetRequestHeader(http,L"WM_SVC.NAME",L"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"
    //                 }
    //               }
    //             ]
    //           }
    //         }
    //       ]
    //     }
    //   }
    // }

    json = CkJsonObjectW_Create();
    orderLineIndex = 0;
    statusIndex = 0;
    CkJsonObjectW_putI(json,orderLineIndex);
    CkJsonObjectW_putJ(json,statusIndex);
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].lineNumber",L"1");
    CkJsonObjectW_UpdateBool(json,L"orderShipment.orderLines.orderLine[i].intentToCancelOverride",FALSE);
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].sellerOrderId",L"92344");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status",L"Shipped");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement",L"EACH");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount",L"1");
    CkJsonObjectW_UpdateInt(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123);
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier",L"UPS");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode",L"Standard");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber",L"22344");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL",L"http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name",L"walmart");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1",L"walmart store 2");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city",L"Huntsville");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state",L"AL");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode",L"35805");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country",L"USA");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone",L"12344");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId",L"walmart@walmart.com");

    orderLineIndex = orderLineIndex + 1;
    statusIndex = 0;
    CkJsonObjectW_putI(json,orderLineIndex);
    CkJsonObjectW_putJ(json,statusIndex);
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].lineNumber",L"2");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].sellerOrderId",L"92344");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status",L"Shipped");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement",L"EACH");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount",L"1");
    CkJsonObjectW_UpdateInt(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123);
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier",L"FedEx");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode",L"Express");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber",L"22344");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL",L"http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name",L"walmart");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1",L"walmart store 2");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city",L"Huntsville");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state",L"AL");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode",L"35805");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country",L"USA");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone",L"12344");
    CkJsonObjectW_UpdateString(json,L"orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId",L"walmart@walmart.com");

    resp = CkHttpResponseW_Create();
    success = CkHttpW_HttpJson(http,L"POST",L"https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping",json,L"application/json",resp);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkHttpResponseW_Dispose(resp);
        return;
    }

    wprintf(L"Response status code: %d\n",CkHttpResponseW_getStatusCode(resp));

    CkHttpResponseW_GetBodyJson(resp,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"
    //                 }
    //               }
    //             ]
    //           }
    //         }
    //       ]
    //     }
    //   }
    // }

    CkJsonObjectW_putEmitCompact(json,FALSE);
    wprintf(L"Response JSON:\n");
    wprintf(L"%s\n",CkJsonObjectW_emit(json));

    // Insert code here to load the above JSON into the json object.

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    PurchaseOrderId = CkJsonObjectW_stringOf(json,L"order.purchaseOrderId");
    CustomerOrderId = CkJsonObjectW_stringOf(json,L"order.customerOrderId");
    SellerOrderId = CkJsonObjectW_stringOf(json,L"order.sellerOrderId");
    CustomerEmailId = CkJsonObjectW_stringOf(json,L"order.customerEmailId");
    OrderDate = CkJsonObjectW_IntOf(json,L"order.orderDate");
    Phone = CkJsonObjectW_stringOf(json,L"order.shippingInfo.phone");
    EstimatedDeliveryDate = CkJsonObjectW_IntOf(json,L"order.shippingInfo.estimatedDeliveryDate");
    EstimatedShipDate = CkJsonObjectW_IntOf(json,L"order.shippingInfo.estimatedShipDate");
    MethodCode = CkJsonObjectW_stringOf(json,L"order.shippingInfo.methodCode");
    Name = CkJsonObjectW_stringOf(json,L"order.shippingInfo.postalAddress.name");
    Address1 = CkJsonObjectW_stringOf(json,L"order.shippingInfo.postalAddress.address1");
    City = CkJsonObjectW_stringOf(json,L"order.shippingInfo.postalAddress.city");
    State = CkJsonObjectW_stringOf(json,L"order.shippingInfo.postalAddress.state");
    PostalCode = CkJsonObjectW_stringOf(json,L"order.shippingInfo.postalAddress.postalCode");
    Country = CkJsonObjectW_stringOf(json,L"order.shippingInfo.postalAddress.country");
    AddressType = CkJsonObjectW_stringOf(json,L"order.shippingInfo.postalAddress.addressType");
    i = 0;
    j = 0;
    count_i = CkJsonObjectW_SizeOfArray(json,L"order.orderLines.orderLine");
    while (i < count_i) {
        CkJsonObjectW_putI(json,i);
        lineNumber = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].lineNumber");
        ProductName = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].item.productName");
        Sku = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].item.sku");
        UnitOfMeasurement = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement");
        Amount = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineQuantity.amount");
        statusDate = CkJsonObjectW_IntOf(json,L"order.orderLines.orderLine[i].statusDate");
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(json,L"order.orderLines.orderLine[i].charges.charge");
        while (j < count_j) {
            CkJsonObjectW_putJ(json,j);
            chargeType = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].charges.charge[j].chargeType");
            chargeName = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].charges.charge[j].chargeName");
            v_Currency = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency");
            chargeAmountAmount = CkJsonObjectW_IntOf(json,L"order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount");
            TaxName = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].charges.charge[j].tax.taxName");
            TaxAmountCurrency = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency");
            TaxAmountAmount = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus");
        while (j < count_j) {
            CkJsonObjectW_putJ(json,j);
            status = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status");
            statusQuantityUnitOfMeasurement = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement");
            statusQuantityAmount = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount");
            ShipDateTime = CkJsonObjectW_IntOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime");
            Carrier = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier");
            trackingInfoMethodCode = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode");
            TrackingNumber = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber");
            TrackingURL = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL");
            returnCenterAddressName = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name");
            returnCenterAddressAddress1 = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1");
            returnCenterAddressCity = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city");
            returnCenterAddressState = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state");
            returnCenterAddressPostalCode = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode");
            returnCenterAddressCountry = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country");
            DayPhone = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone");
            EmailId = CkJsonObjectW_stringOf(json,L"order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId");
            j = j + 1;
        }

        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkHttpResponseW_Dispose(resp);

    }