Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Json
integer li_OrderLineIndex
integer li_StatusIndex
oleobject loo_Resp
string ls_LineNumber
string ls_ProductName
string ls_Sku
string ls_UnitOfMeasurement
string ls_Amount
integer li_StatusDate
integer li_Count_j
string ls_ChargeType
string ls_ChargeName
string ls_V_Currency
integer li_ChargeAmountAmount
string ls_TaxName
string ls_TaxAmountCurrency
string ls_TaxAmountAmount
string ls_Status
string ls_StatusQuantityUnitOfMeasurement
string ls_StatusQuantityAmount
integer li_ShipDateTime
string ls_Carrier
string ls_TrackingInfoMethodCode
string ls_TrackingNumber
string ls_TrackingURL
string ls_ReturnCenterAddressName
string ls_ReturnCenterAddressAddress1
string ls_ReturnCenterAddressCity
string ls_ReturnCenterAddressState
string ls_ReturnCenterAddressPostalCode
string ls_ReturnCenterAddressCountry
string ls_DayPhone
string ls_EmailId
string ls_PurchaseOrderId
string ls_CustomerOrderId
string ls_SellerOrderId
string ls_CustomerEmailId
integer li_OrderDate
string ls_Phone
integer li_EstimatedDeliveryDate
integer li_EstimatedShipDate
string ls_MethodCode
string ls_Name
string ls_Address1
string ls_City
string ls_State
string ls_PostalCode
string ls_Country
string ls_AddressType
integer i
integer j
integer li_Count_i

li_Success = 0

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.SetRequestHeader("WM_QOS.CORRELATION_ID","b3261d2d-028a-4ef7-8602-633c23200af6")
loo_Http.SetRequestHeader("WM_SEC.ACCESS_TOKEN","eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....")
loo_Http.SetRequestHeader("Accept","application/json")
loo_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"
//                 }
//               }
//             ]
//           }
//         }
//       ]
//     }
//   }
// }

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

li_OrderLineIndex = 0
li_StatusIndex = 0
loo_Json.I = li_OrderLineIndex
loo_Json.J = li_StatusIndex
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].lineNumber","1")
loo_Json.UpdateBool("orderShipment.orderLines.orderLine[i].intentToCancelOverride",0)
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].sellerOrderId","92344")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1")
loo_Json.UpdateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123)
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","UPS")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Standard")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344")
loo_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")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com")

li_OrderLineIndex = li_OrderLineIndex + 1
li_StatusIndex = 0
loo_Json.I = li_OrderLineIndex
loo_Json.J = li_StatusIndex
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].lineNumber","2")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].sellerOrderId","92344")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status","Shipped")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement","EACH")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount","1")
loo_Json.UpdateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime",123)
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier","FedEx")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode","Express")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber","22344")
loo_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")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name","walmart")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1","walmart store 2")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city","Huntsville")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state","AL")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode","35805")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country","USA")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone","12344")
loo_Json.UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId","walmart@walmart.com")

loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Success = loo_Http.HttpJson("POST","https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping",loo_Json,"application/json",loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    destroy loo_Resp
    return
end if

Write-Debug "Response status code: " + string(loo_Resp.StatusCode)

loo_Resp.GetBodyJson(loo_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"
//                 }
//               }
//             ]
//           }
//         }
//       ]
//     }
//   }
// }

loo_Json.EmitCompact = 0
Write-Debug "Response JSON:"
Write-Debug loo_Json.Emit()

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

ls_PurchaseOrderId = loo_Json.StringOf("order.purchaseOrderId")
ls_CustomerOrderId = loo_Json.StringOf("order.customerOrderId")
ls_SellerOrderId = loo_Json.StringOf("order.sellerOrderId")
ls_CustomerEmailId = loo_Json.StringOf("order.customerEmailId")
li_OrderDate = loo_Json.IntOf("order.orderDate")
ls_Phone = loo_Json.StringOf("order.shippingInfo.phone")
li_EstimatedDeliveryDate = loo_Json.IntOf("order.shippingInfo.estimatedDeliveryDate")
li_EstimatedShipDate = loo_Json.IntOf("order.shippingInfo.estimatedShipDate")
ls_MethodCode = loo_Json.StringOf("order.shippingInfo.methodCode")
ls_Name = loo_Json.StringOf("order.shippingInfo.postalAddress.name")
ls_Address1 = loo_Json.StringOf("order.shippingInfo.postalAddress.address1")
ls_City = loo_Json.StringOf("order.shippingInfo.postalAddress.city")
ls_State = loo_Json.StringOf("order.shippingInfo.postalAddress.state")
ls_PostalCode = loo_Json.StringOf("order.shippingInfo.postalAddress.postalCode")
ls_Country = loo_Json.StringOf("order.shippingInfo.postalAddress.country")
ls_AddressType = loo_Json.StringOf("order.shippingInfo.postalAddress.addressType")
i = 0
j = 0
li_Count_i = loo_Json.SizeOfArray("order.orderLines.orderLine")
do while i < li_Count_i
    loo_Json.I = i
    ls_LineNumber = loo_Json.StringOf("order.orderLines.orderLine[i].lineNumber")
    ls_ProductName = loo_Json.StringOf("order.orderLines.orderLine[i].item.productName")
    ls_Sku = loo_Json.StringOf("order.orderLines.orderLine[i].item.sku")
    ls_UnitOfMeasurement = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement")
    ls_Amount = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineQuantity.amount")
    li_StatusDate = loo_Json.IntOf("order.orderLines.orderLine[i].statusDate")
    j = 0
    li_Count_j = loo_Json.SizeOfArray("order.orderLines.orderLine[i].charges.charge")
    do while j < li_Count_j
        loo_Json.J = j
        ls_ChargeType = loo_Json.StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeType")
        ls_ChargeName = loo_Json.StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeName")
        ls_V_Currency = loo_Json.StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency")
        li_ChargeAmountAmount = loo_Json.IntOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount")
        ls_TaxName = loo_Json.StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxName")
        ls_TaxAmountCurrency = loo_Json.StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency")
        ls_TaxAmountAmount = loo_Json.StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_Json.SizeOfArray("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus")
    do while j < li_Count_j
        loo_Json.J = j
        ls_Status = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status")
        ls_StatusQuantityUnitOfMeasurement = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement")
        ls_StatusQuantityAmount = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount")
        li_ShipDateTime = loo_Json.IntOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime")
        ls_Carrier = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier")
        ls_TrackingInfoMethodCode = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode")
        ls_TrackingNumber = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber")
        ls_TrackingURL = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL")
        ls_ReturnCenterAddressName = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name")
        ls_ReturnCenterAddressAddress1 = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1")
        ls_ReturnCenterAddressCity = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city")
        ls_ReturnCenterAddressState = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state")
        ls_ReturnCenterAddressPostalCode = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode")
        ls_ReturnCenterAddressCountry = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country")
        ls_DayPhone = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone")
        ls_EmailId = loo_Json.StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_Json
destroy loo_Resp