abuzuhri / Amazon-SP-API-CSharp

.Net C# library for the new Amazon Selling Partner API
MIT License
215 stars 191 forks source link

Order -> BuyerInfo -> BuyertaxInfo is null #74

Closed kevinvenclovas closed 2 years ago

kevinvenclovas commented 2 years ago

maybe someone can help me.

How can i get the buyer tax informations?

Here is my code. The object is every time null:

AmazonConnection amazonConnection = new AmazonContext().GetConnection();

            ParameterOrderList serachOrderList = new ParameterOrderList();
            serachOrderList.MarketplaceIds = new List<string> { MarketPlace.Germany.ID };
            serachOrderList.AmazonOrderIds = new List<string>();
            serachOrderList.AmazonOrderIds.Add("XXXXX");

            var restrictedResource = new RestrictedResource();
            restrictedResource.method = Method.GET.ToString();
            restrictedResource.path = ApiUrls.OrdersApiUrls.Orders;
            restrictedResource.dataElements = new List<string> { "buyerInfo", "shippingAddress" };

            var createRDT = new CreateRestrictedDataTokenRequest()
            {
                restrictedResources = new List<RestrictedResource> { restrictedResource }
            };
            serachOrderList.RestrictedDataTokenRequest = createRDT;
            serachOrderList.IsNeedRestrictedDataToken = true;

            var orders = amazonConnection.Orders.GetOrders(serachOrderList);

Is ther a other function to get the tex informations?

abuzuhri commented 2 years ago

Hello @kevinvenclovas ,

Is your account approved for PII?

If yes and want to get buyer info

you need to check sample in order , there is another follow if you need to get buyer info .

abuzuhri commented 2 years ago

Hi @kevinvenclovas

Can you confirm that you have PPI permission approved ?

kevinvenclovas commented 2 years ago

Hi, yes we habe the PPI permission. On the MWS api this works very well

abuzuhri commented 2 years ago

The best way to download the source code and check if the application generate RDT Token or not , from my side my application not approve to see PII but i got help from some developer they have the test that part and work with them .

fist you can try download the source code and debug and if you need any help I'm ready

abuzuhri commented 2 years ago

@gcuadrado Can you confirm this part work with you ?

gcuadrado commented 2 years ago

@abuzuhri for me is working well with buyer info like adress, name etc... but I don't have tax permission from Amazon, only direct shipping

kevinvenclovas commented 2 years ago

Hi, short update. I'm waiting for the amazon answer for this issue

abuzuhri commented 2 years ago

Hello @kevinvenclovas

do you get update from Amazon on this ?

kevinvenclovas commented 2 years ago

No, but I found something. my access is currently restricted i updated my developer profile and waiting for an answer

image

abuzuhri commented 2 years ago

Any Update here ? do you get it work ?

kevinvenclovas commented 2 years ago

Hi, no still waiting for answer :/

owenashurst commented 2 years ago

Interestingly, I'm trying to do the same thing, but I get the error

{"Application does not have access to one or more requested data elements: [buyerInfo, shippingAddress]"}

Also, is there any way to get shippinginfo and buyerInfo from the call since you don't know what the AmazonOrderIds are until you've made the call... or are you expected to make two calls? One for the OrderId's and one to get the restricted info? Surely not...

abuzuhri commented 2 years ago

The error you get is clear you don't have access to PII data

You need to request access for this form developer screen I think the name is direct ship

owenashurst commented 2 years ago

@abuzuhri Thank you. I'm presuming you meant Direct-To-Consumer Delivery?

Here is what my permissions look like: image

abuzuhri commented 2 years ago

Check this file

https://github.com/abuzuhri/Amazon-SP-API-CSharp/blob/main/Source/FikaAmazonAPI.SampleCode/OrdersSample.cs

Line 92 try that method

owenashurst commented 2 years ago

My issue is getting the orders, if I try line 42 instead, I get the same error.

If I try Line 92 for getting order items, then I get {"Application do not have access to some or all requested resource"}

abuzuhri commented 2 years ago

Do you change the order Id ?

gcuadrado commented 2 years ago

My issue is getting the orders, if I try line 42 instead, I get the same error.

If I try Line 92 for getting order items, then I get {"Application do not have access to some or all requested resource"}

If I remember it well, you can't request buyerInfo permission for GetOrders method, try to use only shippingAddress.

owenashurst commented 2 years ago

@gcuadrado Thanks for your reply, however unfortunately I still get {"Application does not have access to one or more requested data elements: [shippingAddress]"}.

@abuzuhri I didn't, but I would have expected another error about it not finding the orderId. My problem is, I don't know the OrderId's until I make the call in the first place, that's what is confusing. I would have expected the PII information to come back in the call to get the orders.

abuzuhri commented 2 years ago

Hi ,

Try to change order ID With any order in your store.

You can get order list without DTR , please read here

https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/tokens-api-use-case-guide/tokens-API-use-case-guide-2021-03-01.md

owenashurst commented 2 years ago

Good news. I've just tried again this morning and the call is now working fine. It seems like there must be some sort of delay for permissions to be updated in Amazon's side. Here is my final code;

public OrderList GetOrderList()
    {
        var parameterOrderList = new ParameterOrderList
        {
            CreatedAfter = DateTime.UtcNow.AddHours(-24),
            OrderStatuses = new List<OrderStatuses> { OrderStatuses.Unshipped },
            MarketplaceIds = _amazonSettings.Value.Marketplaces,
            IsNeedRestrictedDataToken = true,
            RestrictedDataTokenRequest = new CreateRestrictedDataTokenRequest
            {
                restrictedResources = new List<RestrictedResource>
                {
                    new RestrictedResource
                    {
                        method = Method.GET.ToString(),
                        path = ApiUrls.OrdersApiUrls.Orders,
                        dataElements = new List<string> { "buyerInfo", "shippingAddress" }
                    }
                }
            }
        };

        var orders = _amazonConnection.Orders.GetOrders(parameterOrderList);

        return orders;
    }
abuzuhri commented 2 years ago

since this work with @owenashurst and @gcuadrado

I will close this bug

kevinvenclovas commented 2 years ago

@owenashurst do you get the BuyerTaxInfo with your code?

owenashurst commented 2 years ago

@owenashurst do you get the BuyerTaxInfo with your code?

@kevinvenclovas I don't unfortunately, I only get the name and email within BuyerInfo.

kevinvenclovas commented 2 years ago

Here some helpful answer from amazon:

Hello,

I understand that you are concerned about not receiving the BuyerTaxInfo when calling the orders API.

I would like to inform you that we have reached out to the engineering team with this issue.

We have come to know that this is a known issue existing in our systems, and the engineering team is aware of it and working on it.

I have provided this particular instance as well.

Unfortunately, we do not have an estimated time for the rectification of the issue.

We regret the inconvenience, and appreciate your understanding in this matter.

Please let us know how we did.

Were you satisfied with the support provided?
owenashurst commented 2 years ago

Thanks @kevinvenclovas, hopefully they get back in touch soon.