amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
612 stars 736 forks source link

Missing CompanyName in /orders/v0/orders #4315

Open psg1 opened 2 days ago

psg1 commented 2 days ago

https://github.com/amzn/selling-partner-api-models/blob/1c23aa95cf8ca6c418e2bceaaef693c665b05900/models/orders-api-model/ordersV0.json#L3876

According to the API documentation here https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference#address, the Address object should include the CompanyName field. However, when I make an API call to the endpoint /orders/v0/orders, the company name is not being returned. Could you clarify why the company name is missing in the reports segment OrderReport\FulfillmentData\Address?

The required data set is available by calling /orders/v0/orders/{$orderId}/address. However, this would require us to make unnecessary calls.

jawheral commented 2 days ago

Hi @psg1,

To have the Buyer company name returned in order reports, please note that the seller has to activate the attribute in the column picker.

The company name is an optional field in Orders API so it is not returned for every order and is only returned when it was provided by the buyer. Is it for the same order that the CompanyName is not returned in Address but only returned using /orders/v0/orders/{$orderId}/address? And on which attribute exactly do you get the company name from the getOrderAddress operation response, is it the BuyerCompanyName or ShippingAddress. CompanyName?

Best, Jawher Selling Partner Developer Services

psg1 commented 2 days ago

Hi @jawheral,

The column picker only seems to apply to https://sellercentral.amazon.de/order-reports-and-feeds/reports/allOrders - the report that we receive via the API call is in XML format.

It's about CompanyName- which can sometimes be important for shipping. The delivery address is displayed correctly in Seller Central, but the CompanyName is also missing on the Amazon generated invoice under delivery address.

I don't know if it is allowed to specify an order number or a report ID here, which serves as an example.

We know that this field is optional.

For the same order we receive in the /orders/v0/orders report:

<Message>
    <MessageID>4</MessageID>
    <OrderReport>
        <AmazonOrderID>303-7563330-...</AmazonOrderID>
        <AmazonSessionID>303-7563330-...</</AmazonSessionID>
        <OrderDate>2024-10-31T10:37:32+00:00</OrderDate>
        <OrderPostedDate>2024-10-31T10:37:32+00:00</OrderPostedDate>
        <MarketplaceName>Amazon.de</MarketplaceName>
        <BillingData>
            <BuyerEmailAddress>...</BuyerEmailAddress>
            <BuyerName>...</BuyerName>
            <BuyerPhoneNumber>...</BuyerPhoneNumber>
            <Address>
                <Name>...</Name>
                <AddressFieldOne>...</AddressFieldOne>
                <City>...</City>
                <PostalCode>...</PostalCode>
                <CountryCode>...</CountryCode>
            </Address>
        </BillingData>
        <FulfillmentData>
            <FulfillmentMethod>Ship</FulfillmentMethod>
            <FulfillmentServiceLevel>Standard</FulfillmentServiceLevel>
            <Address>
########## CompanyName is expected here ##########
                <Name>...</Name>
                <AddressFieldOne>...</AddressFieldOne>
                <City>...</City>
                <PostalCode>...</PostalCode>
                <CountryCode>...</CountryCode>
                <PhoneNumber>...</PhoneNumber>
            </Address>
        </FulfillmentData>
        <IsBusinessOrder>true</IsBusinessOrder>
....

And with the call /orders/v0/orders/303-7563330-.../address

  ["payload"]=>
  array(4) {
    ...
    ["AmazonOrderId"]=>
    string(19) "303-7563330-..."
    ["ShippingAddress"]=>
    array(7) {
########## This Part is needed ##########
      ["CompanyName"]=>
      string(29) "..."
#########################################
      ["AddressLine1"]=>
      string(27) "..."
      ["PostalCode"]=>
      string(5) "..."
      ["City"]=>
      string(13) "..."
      ["CountryCode"]=>
      string(2) "..."
      ["AddressType"]=>
      string(10) "..."
      ["Name"]=>
      string(13) "..."
    }
    ["BuyerCompanyName"]=>
    string(10) "..."
  }
}
jawheral commented 1 day ago

Hi @psg1,

Thank you for the additional details. Regarding Orders API when getting orders /orders/v0/orders, are you making sure that you are getting and using an RDT (Restricted Data Token) from Tokens API when calling the operation? When doing so, the full shippingAddress including the companyName should be returned. Could you please verify this? In order to get an RDT you can run the following request using the createRestrictedToken /tokens/2021-03-01/restrictedDataToken operation

{
  "restrictedResources": [
    {
      "method": "GET",
      "path": "/orders/v0/orders",
      "dataElements": ["shippingAddress"]
    }]
}

Please follow this use case guide for the Tokens API usage.

Regarding reports, please make sure the column is active and try whether other order reports return the company name, such as GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING I assume you are already using an RDT for the XML report but it might be that the companyName isn't returned in that report.

Best, Jawher Selling Partner Developer Services

psg1 commented 1 day ago

Hi @jawheral,

we used a self-authorize private application. We use /auth/o2/token

In the GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING there is also no company name included - but according to the documentation it shouldn't be.

jawheral commented 1 day ago

Hi @psg1,

For you to retrieve all the details when using /orders/v0/orders, you still need to create an RDT (check the Tokens API use case guide in my previous comment). This might help you avoid the additional call to /orders/v0/orders/{$orderId}/address. Feel free to try it and let me know if this works for you.

With GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING, if you activate the Buyer Company Name from the oder column picker, it should be included in the report.

Best, Jawher Selling Partner Developer Services