davestacey
11/20/2015 - 7:03 PM

mws-sdk-promises SubmitFeed() - _POST_ORDER_ACKNOWLEDGEMENT_DATA

mws-sdk-promises SubmitFeed() - _POST_ORDER_ACKNOWLEDGEMENT_DATA

  var feedContent =
    '<?xml version="1.0" encoding="UTF-8"?>'+
    '<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">' +

      '<Header>'+
      ' <DocumentVersion>1.01</DocumentVersion>' +
      ' <MerchantIdentifier>A00000000000</MerchantIdentifier>'+
      '</Header>'+

      '<MessageType>OrderAcknowledgement</MessageType>'+
        '<Message>'+
          '<MessageID>1</MessageID>'+
          '<OrderAcknowledgement>'+
            '<AmazonOrderID>700-8630000-50000000</AmazonOrderID>'+
            '<MerchantOrderID>7777777</MerchantOrderID>'+
            '<StatusCode>Success</StatusCode>'+
          '</OrderAcknowledgement>'+
        '</Message>'+
    '</AmazonEnvelope>'
    ;
  function sendSellerOrderId(amazonOrderId, merchantOrderId, store ){
     return getMwsClient(store)
    .then(function(mwsClient){
      submitFeedMws(mwsClient, {
        FeedContents: feedContent,
        FeedType: '_POST_ORDER_ACKNOWLEDGEMENT_DATA_',
        MarketplaceIds: '', //required: false
        PurgeAndReplace: '', // required: false
      })
      .then(function(ret){
        console.log('_POST_ORDER_ACKNOWLEDGEMENT_DATA_ ret ', ret);
        return ret;
      });
  }
function submitFeedMws(mwsClient, args) {
  console.log('args', args);
  try {
    var req = MWS.Feeds.requests.SubmitFeed();
    req.set('FeedContents', args.FeedContents);
    req.set('FeedType', args.FeedType);
    // req.set('MarketplaceIds', args.MarketplaceIds);
    // req.set('PurgeAndReplace', args.PurgeAndReplace);
    return mwsClient.invoke(req);
  } catch (e) {
    console.log('ISSUE with submitFeedMws '+ e);
  }
}