在亚马逊商城中更新商家订单ID

时间:2012-11-13 20:00:53

标签: c# asp.net amazon amazon-mws

我需要使用C#通过亚马逊MWS API更新Amazon Marketplace中的MerchantOrderID。

所以,首先我创建了XML文件,如:

<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>M_STORE_3918753</MerchantIdentifier>
  </Header>
  <MessageType>OrderAcknowledgement</MessageType>
  <Message>
    <MessageID>1</MessageID>
    <OrderAcknowledgement>
      <AmazonOrderID>104-9209939-0469021</AmazonOrderID>
      <MerchantOrderID>100828163</MerchantOrderID>
      <StatusCode>Success</StatusCode>
      <Item>
        <AmazonOrderItemCode>11111111111111</AmazonOrderItemCode>
        <MerchantOrderItemID>111111</MerchantOrderItemID>
        <AmazonOrderItemCode>22222222222222</AmazonOrderItemCode>
        <MerchantOrderItemID>222222222</MerchantOrderItemID>
      </Item>
    </OrderAcknowledgement>
  </Message>
</AmazonEnvelope>

然后我尝试致电亚马逊MWS SubmitFeed:

SubmitFeedRequest request = new SubmitFeedRequest();
        request.Merchant = merchantId;
        request.MarketplaceIdList = new IdList();
        request.MarketplaceIdList.Id = new List<string>(new string[] { marketplaceId });

        request.FeedContent = File.Open(path, FileMode.Open, FileAccess.Read);

        request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent);
        request.FeedContent.Position = 0;

        request.FeedType = "_POST_ORDER_ACKNOWLEDGEMENT_DATA_";

        MarketplaceWebService.MarketplaceWebService serviceFeed = new MarketplaceWebServiceClient(
                accessKeyId,
                secretAccessKey,
                applicationName,
                applicationVersion,
                configFeed);

        SubmitFeedResponse response = serviceFeed.SubmitFeed(request);

它成功提交,但当我在亚马逊(sellercentral.amazon.com)打开我的订单时,它说“没有保存”: 您的商家订单ID:#无保存

谁可以帮助我,有什么不对或我该怎么做?

谢谢!

2 个答案:

答案 0 :(得分:1)

这实际上是正确的代码。不知何故亚马逊没有标记某些特殊订单或稍后标记它们。

答案 1 :(得分:1)

对于那些想要一次更新多个订单中的商家订单ID的人,这里是示例(也适用于amazon mws暂存器):

<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>ALVH0CYWPBFNA</MerchantIdentifier>
  </Header>
  <MessageType>OrderAcknowledgement</MessageType>
    <Message>
        <MessageID>1</MessageID>
        <OrderAcknowledgement>
        <AmazonOrderID>000-0000000-0000000</AmazonOrderID>
        <MerchantOrderID>YOUR_MERCHANT_ORDER_ID</MerchantOrderID>
        <StatusCode>Success</StatusCode>
        </OrderAcknowledgement>
    </Message>
    <Message>
        <MessageID>2</MessageID>
        <OrderAcknowledgement>
        <AmazonOrderID>000-0000000-0000000</AmazonOrderID>
        <MerchantOrderID>YOUR_MERCHANT_ORDER_ID</MerchantOrderID>
        <StatusCode>Success</StatusCode>
        </OrderAcknowledgement>
    </Message>
</AmazonEnvelope>