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
590 stars 728 forks source link

Simple Question: I Want to Check By Order ID If an Order was Refunded Or Not #2141

Closed jaradc closed 1 year ago

jaradc commented 2 years ago

I want to use the API to check if an order was refunded based on Order ID ("Refund applied" is usually the status in the interface).

I am using a Python package PYTHON-AMAZON-SP-API.

In that package, here is the simple code:

from sp_api.api import Finances

credentials=dict(
    refresh_token="Atzr|IwE...",
    lwa_app_id='amzn1.applica...1e',
    lwa_client_secret='1e9...5',
    aws_access_key="A...5M",
    aws_secret_key="VF...rT",
    role_arn='arn:aws:iam::...MyRole',
)

order_id = "<123-45..658>."
f = Finances(marketplace=Marketplaces.US, credentials=credentials)
events = f.get_financial_events_for_order(order_id)

This code works until I get to the events line.

sp_api.base.exceptions.SellingApiForbiddenException: [
    {'message': 'Access to requested resource is denied.', 'code': 'Unauthorized', 'details': ''}
]

My simple questions:

  1. This is a 403 error, Unauthorized. How do I know if this error is caused by my IAM permissions or from the Selling Partner API?
  2. Does access to the Finances API require access to a restricted category in my Selling Partner Developer profile? I have: "Brand Analytics", "Direct-to-Consumer Shipping", "Tax Invoicing", and "Tax Remittance" unchecked. All other roles in my "Developer profile" are checked.
  3. Any general tips on how to fix this problem? It's obviously because of some authorization issue, but I'm lost on where to focus my efforts.

For the record, other calls to the API with my credentials work fine. For example, get_order(<order_id_string_here>).

rohitdobariya commented 2 years ago

It might be an issue with how you call the finances API internally in python. Let me know if you need any help will help you.

jaradc commented 2 years ago

I resolved it. I think the problem was the roles I selected inside the private app. I had only some checked. To be sure, I checked them all. After that, my code worked. Another thing I did was regenerate a refresh token after I had added the new roles. I am not sure this was necessary but was just trying everything I could think of.

rohitdobariya commented 2 years ago

@jaradc pefect

PriyamJha0124 commented 2 years ago

Hello. Jaradc. thank you for posting this question. Actually I have a problem with my credentials . Hope you give me help for this.

I am amazon seller and some customers wants to return delivered products and get refunded. I need to get these orders and their buyer information include address. Doe it require restricted data ? and How to get that then?

PriyamJha0124 commented 2 years ago

I want to use the API to check if an order was refunded based on Order ID ("Refund applied" is usually the status in the interface).

I am using a Python package PYTHON-AMAZON-SP-API.

In that package, here is the simple code:

from sp_api.api import Finances

credentials=dict(
    refresh_token="Atzr|IwE...",
    lwa_app_id='amzn1.applica...1e',
    lwa_client_secret='1e9...5',
    aws_access_key="A...5M",
    aws_secret_key="VF...rT",
    role_arn='arn:aws:iam::...MyRole',
)

order_id = "<123-45..658>."
f = Finances(marketplace=Marketplaces.US, credentials=credentials)
events = f.get_financial_events_for_order(order_id)

This code works until I get to the events line.

sp_api.base.exceptions.SellingApiForbiddenException: [
    {'message': 'Access to requested resource is denied.', 'code': 'Unauthorized', 'details': ''}
]

My simple questions:

  1. This is a 403 error, Unauthorized. How do I know if this error is caused by my IAM permissions or from the Selling Partner API?
  2. Does access to the Finances API require access to a restricted category in my Selling Partner Developer profile? I have: "Brand Analytics", "Direct-to-Consumer Shipping", "Tax Invoicing", and "Tax Remittance" unchecked. All other roles in my "Developer profile" are checked.
  3. Any general tips on how to fix this problem? It's obviously because of some authorization issue, but I'm lost on where to focus my efforts.

For the record, other calls to the API with my credentials work fine. For example, get_order(<order_id_string_here>).

I think that I didn't check 'Direct-to-Consumer Shipping" , "Tax invoicing", "Tax Remittance".. Do I have to check them all?

PriyamJha0124 commented 2 years ago

Can we co-operate in this project? I want to implement lot's of functions by using selling partner api .

PriyamJha0124 commented 2 years ago

Were u able to get buyer information with get_order()?

github-actions[bot] commented 1 year ago

This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please feel free to open a new issue and make a reference to this one.

github-actions[bot] commented 1 year ago

closed for inactivity