jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
398 stars 185 forks source link

Can't get order address info in sandbox env. #65

Closed Abbotton closed 3 years ago

Abbotton commented 3 years ago

Hi, jlevers. Sorry, my English is very bad.

In the SP-API sandbox environment, I can get the order list and order details, but I cannot get the buyer information and delivery address information. Below I list some relevant information, please help me. Thank you.

These are the permissions of my app: 微信截图_20210727230847

This is the code that I ran while testing (using the parameters provided by the official documentation):

$config = [];
$app = new OrdersApi($config);
$result = $app->getOrderAddress('TEST_CASE_200');
dd($result);

This is the information returned by SP-API:

"""
[403] {
  "errors": [
    {
      "message": "Access to requested resource is denied.",
     "code": "Unauthorized",
     "details": "The access token you provided is revoked, malformed or invalid."
    }
  ]
}
"""

At the same time, I checked this issue, but the amazon support team hasn't responded yet.

In addition, my seller account did not get access to PII when applying for MWS.

Now I want to ask three questions: 1, Is this situation related to my account not having access to PII? 2, Is the code running during my test correct?

  1. Can you share the code you used when accessing buyer information in the sandbox environment?

Thank you very much.

jlevers commented 3 years ago
  1. Yes, you need access to PII in order to get order addresses.
  2. The $config parameter to OrdersApi needs to be a Configuration object, per the documentation.
  3. I get the same response as you when I try to call getOrderAddress via the sandbox. I think this may be an error on Amazon's end? Here's the code I'm using:
    
    use SellingPartnerApi\Api\OrdersApi;
    use SellingPartnerApi\Configuration;
    use SellingPartnerApi\Endpoint;

$config = new Configuration([ 'lwaClientId' => 'amzn1.application-oa2-client....', 'lwaClientSecret' => 'df4e....', 'lwaRefreshToken' => 'Atzr|IwEB....', 'awsAccessKeyId' => 'AKIA....', 'awsSecretAccessKey' => '4oi1q....', 'endpoint' => Endpoint::NA_SANDBOX, ]); $ordersApi = new OrdersApi($config); $response = $ordersApi->getOrderAddress('TEST_CASE_200'); var_dump($response);

Abbotton commented 3 years ago

OK, thanks jlevers.