Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Walmart - Acknowledge Order

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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoSbUrl
    Boolean iSuccess
    Integer iNumReplaced
    String sRequestMethod
    Handle hoAuthUtil
    String sWmConsumerId
    String sWmPrivateKey
    String sJsonStr
    Handle hoJson
    Handle hoHttp
    Variant vResp
    Handle hoResp
    Variant vSbBody
    Handle hoSbBody
    String sOrderPurchaseOrderId
    String sOrderCustomerOrderId
    String sOrderCustomerEmailId
    Integer iOrderOrderDate
    String sOrderShippingInfoPhone
    Integer iOrderShippingInfoEstimatedDeliveryDate
    Integer iOrderShippingInfoEstimatedShipDate
    String sOrderShippingInfoMethodCode
    String sOrderShippingInfoPostalAddressName
    String sOrderShippingInfoPostalAddressAddress1
    String sOrderShippingInfoPostalAddressAddress2
    String sOrderShippingInfoPostalAddressCity
    String sOrderShippingInfoPostalAddressState
    String sOrderShippingInfoPostalAddressPostalCode
    String sOrderShippingInfoPostalAddressCountry
    String sOrderShippingInfoPostalAddressAddressType
    Integer i
    Integer iCount_i
    String sLineNumber
    String sItemProductName
    String sItemSku
    String sOrderLineQuantityUnitOfMeasurement
    String sOrderLineQuantityAmount
    Integer iStatusDate
    Boolean iRefundRefundId
    Boolean iRefundRefundComments
    Integer j
    Integer iCount_j
    String sChargeType
    String sChargeName
    String sChargeAmountCurrency
    Integer iChargeAmountAmount
    String sTaxTaxName
    String sTaxTaxAmountCurrency
    Integer iTaxTaxAmountAmount
    String sStatus
    String sStatusQuantityUnitOfMeasurement
    String sStatusQuantityAmount
    Boolean iCancellationReason
    Integer iTrackingInfoShipDateTime
    Boolean iTrackingInfoCarrierNameOtherCarrier
    String sTrackingInfoCarrierNameCarrier
    String sTrackingInfoMethodCode
    String sTrackingInfoTrackingNumber
    String sTrackingInfoTrackingURL
    String sRefundReason
    String sChargeChargeType
    String sChargeChargeName
    String sChargeChargeAmountCurrency
    Integer iChargeChargeAmountAmount
    Boolean iChargeTax
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // ---------------------------------------------------------------------------------------------------------
    // 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

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbUrl
    If (Not(IsComObjectCreated(hoSbUrl))) Begin
        Send CreateComObject of hoSbUrl
    End
    Get ComAppend Of hoSbUrl "https://marketplace.walmartapis.com/v3/orders/{purchaseOrderId}/acknowledge" To iSuccess
    Get ComReplace Of hoSbUrl "{purchaseOrderId}" "1111691995111" To iNumReplaced

    Move "POST" To sRequestMethod

    // First we need to generate a signature for our request.
    // The signature needs to be re-generated for each new Walmart HTTP request.
    Get Create (RefClass(cComChilkatAuthUtil)) To hoAuthUtil
    If (Not(IsComObjectCreated(hoAuthUtil))) Begin
        Send CreateComObject of hoAuthUtil
    End

    Move "WALMART_CONSUMER_ID" To sWmConsumerId
    Move "WALMART_PRIVATE_KEY" To sWmPrivateKey
    Get ComGetAsString Of hoSbUrl To sTemp1
    Get ComWalmartSignature Of hoAuthUtil sTemp1 sWmConsumerId sWmPrivateKey sRequestMethod To sJsonStr
    Get ComLastMethodSuccess Of hoAuthUtil To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoAuthUtil To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // 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
    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComLoad Of hoJson sJsonStr To iSuccess

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End
    Send ComSetRequestHeader To hoHttp "WM_SVC.NAME" "Walmart Marketplace"
    Get ComStringOf Of hoJson "correlation_id" To sTemp1
    Send ComSetRequestHeader To hoHttp "WM_QOS.CORRELATION_ID" sTemp1
    Get ComStringOf Of hoJson "timestamp" To sTemp1
    Send ComSetRequestHeader To hoHttp "WM_SEC.TIMESTAMP" sTemp1
    Get ComStringOf Of hoJson "signature" To sTemp1
    Send ComSetRequestHeader To hoHttp "WM_SEC.AUTH_SIGNATURE" sTemp1
    Send ComSetRequestHeader To hoHttp "WM_CONSUMER.ID" sWmConsumerId
    // Note: Make sure to replace "WALMART_CHANNEL_TYPE" with the actual value for your seller account...
    Send ComSetRequestHeader To hoHttp "WM_CONSUMER.CHANNEL.TYPE" "WALMART_CHANNEL_TYPE"
    Set ComAccept Of hoHttp To "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.)

    Send ComSetRequestHeader To hoHttp "Accept" "application/json"
    // The body of this particular POST request contains just "{}". (The order ID is already in the URL path.)
    Get ComGetAsString Of hoSbUrl To sTemp1
    Get ComPostJson2 Of hoHttp sTemp1 "application/json" "{}" To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Get the JSON response body, which could contain an error, or if successful contains
    // the acknowledged order.
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbBody
    If (Not(IsComObjectCreated(hoSbBody))) Begin
        Send CreateComObject of hoSbBody
    End
    Get pvComObject of hoSbBody to vSbBody
    Get ComGetBodySb Of hoResp vSbBody To iSuccess

    // A successful response should have a 200 response status
    Get ComStatusCode Of hoResp To iTemp1
    If (iTemp1 <> 200) Begin
        Get ComGetAsString Of hoSbBody To sTemp1
        Showln sTemp1
        Get ComStatusCode Of hoResp To iTemp1
        Showln "Response Status Code: " iTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    // 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

    Get pvComObject of hoSbBody to vSbBody
    Get ComLoadSb Of hoJson vSbBody To iSuccess

    Get ComStringOf Of hoJson "order.purchaseOrderId" To sOrderPurchaseOrderId
    Get ComStringOf Of hoJson "order.customerOrderId" To sOrderCustomerOrderId
    Get ComStringOf Of hoJson "order.customerEmailId" To sOrderCustomerEmailId
    Get ComIntOf Of hoJson "order.orderDate" To iOrderOrderDate
    Get ComStringOf Of hoJson "order.shippingInfo.phone" To sOrderShippingInfoPhone
    Get ComIntOf Of hoJson "order.shippingInfo.estimatedDeliveryDate" To iOrderShippingInfoEstimatedDeliveryDate
    Get ComIntOf Of hoJson "order.shippingInfo.estimatedShipDate" To iOrderShippingInfoEstimatedShipDate
    Get ComStringOf Of hoJson "order.shippingInfo.methodCode" To sOrderShippingInfoMethodCode
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.name" To sOrderShippingInfoPostalAddressName
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.address1" To sOrderShippingInfoPostalAddressAddress1
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.address2" To sOrderShippingInfoPostalAddressAddress2
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.city" To sOrderShippingInfoPostalAddressCity
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.state" To sOrderShippingInfoPostalAddressState
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.postalCode" To sOrderShippingInfoPostalAddressPostalCode
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.country" To sOrderShippingInfoPostalAddressCountry
    Get ComStringOf Of hoJson "order.shippingInfo.postalAddress.addressType" To sOrderShippingInfoPostalAddressAddressType
    Move 0 To i
    Get ComSizeOfArray Of hoJson "order.orderLines.orderLine" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "order.orderLines.orderLine[i].lineNumber" To sLineNumber
        Get ComStringOf Of hoJson "order.orderLines.orderLine[i].item.productName" To sItemProductName
        Get ComStringOf Of hoJson "order.orderLines.orderLine[i].item.sku" To sItemSku
        Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement" To sOrderLineQuantityUnitOfMeasurement
        Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineQuantity.amount" To sOrderLineQuantityAmount
        Get ComIntOf Of hoJson "order.orderLines.orderLine[i].statusDate" To iStatusDate
        Get ComIsNullOf Of hoJson "order.orderLines.orderLine[i].refund.refundId" To iRefundRefundId
        Get ComIsNullOf Of hoJson "order.orderLines.orderLine[i].refund.refundComments" To iRefundRefundComments
        Move 0 To j
        Get ComSizeOfArray Of hoJson "order.orderLines.orderLine[i].charges.charge" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].charges.charge[j].chargeType" To sChargeType
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].charges.charge[j].chargeName" To sChargeName
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency" To sChargeAmountCurrency
            Get ComIntOf Of hoJson "order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount" To iChargeAmountAmount
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].charges.charge[j].tax.taxName" To sTaxTaxName
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency" To sTaxTaxAmountCurrency
            Get ComIntOf Of hoJson "order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount" To iTaxTaxAmountAmount
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status" To sStatus
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement" To sStatusQuantityUnitOfMeasurement
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount" To sStatusQuantityAmount
            Get ComIsNullOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].cancellationReason" To iCancellationReason
            Get ComIntOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime" To iTrackingInfoShipDateTime
            Get ComIsNullOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.otherCarrier" To iTrackingInfoCarrierNameOtherCarrier
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier" To sTrackingInfoCarrierNameCarrier
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode" To sTrackingInfoMethodCode
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber" To sTrackingInfoTrackingNumber
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL" To sTrackingInfoTrackingURL
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "order.orderLines.orderLine[i].refund.refundCharges.refundCharge" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].refundReason" To sRefundReason
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeType" To sChargeChargeType
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeName" To sChargeChargeName
            Get ComStringOf Of hoJson "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.currency" To sChargeChargeAmountCurrency
            Get ComIntOf Of hoJson "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.chargeAmount.amount" To iChargeChargeAmountAmount
            Get ComIsNullOf Of hoJson "order.orderLines.orderLine[i].refund.refundCharges.refundCharge[j].charge.tax" To iChargeTax
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Showln "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
    //                   }
    //                 }
    //               ]
    //             }
    //           }
    //         }
    //       ]
    //     }
    //   }
    // }


End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.