sp-api-sdk icon indicating copy to clipboard operation
sp-api-sdk copied to clipboard

Return value of AmazonPHP\SellingPartner\Model\Orders\Address::getName() must be of the type string, null returned

Open axsweet opened this issue 3 years ago • 11 comments

V: amazon-php/sp-api-sdk 4.0.12 Amazon Selling Partner API - PHP SDK PHP V ~7.4

Some address is null so on jsonSerialize() I get this error... seems the data has a null and wants a string.

TypeError

Return value of AmazonPHP\SellingPartner\Model\Orders\Address::getName() must be of the type string, null returned

at vendor/amazon-php/sp-api-sdk/src/AmazonPHP/SellingPartner/Model/Orders/Address.php:282 278▕ * Gets name. 279▕ / 280▕ public function getName() : string 281▕ { ➜ 282▕ return $this->container['name']; 283▕ } 284▕ 285▕ /* 286▕ * Sets name.

  +6 vendor frames

7 app/Console/Commands/AmazonCommands.php:660 AmazonPHP\SellingPartner\Model\Orders\GetOrdersResponse::jsonSerialize()

axsweet avatar Feb 01 '23 23:02 axsweet

any answers on this ?

fawsan avatar Feb 04 '23 03:02 fawsan

I removed the strict types requirement on the ask file.

But ultimately i beliehe i didn't have the approval (still waiting) to get the customer info. Found it funnny I can get 85% but need advanced approval for the name but. Anyway.

axsweet avatar Feb 04 '23 14:02 axsweet

I had the same problem.

I solved it by adding ? in string return type on getName method from Address class

like this: before: public function getName(): string after: public function getName(): ?string

stdmedoth avatar Feb 23 '23 20:02 stdmedoth

Yeah i worked around it similarly by either A removing strict type declaration or just the return type. except for the fact that the information in the fields i wanted is infact coming as null because i need extra permissions they wont grant it to be in dev vetting so we are working on that. its frsutratig since we get that info now from MWS already.

A

On Thu, Feb 23, 2023 at 3:04 PM Calisto @.***> wrote:

I had the same problem.

I solved it by adding ? in string return type on getName method from Address class

like this: before: public function getName(): string after: public function getName(): ?string

— Reply to this email directly, view it on GitHub https://github.com/amazon-php/sp-api-sdk/issues/328#issuecomment-1442363222, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALF5SJHBEUPXVK2P6I6AHODWY67GDANCNFSM6AAAAAAUOKK37Y . You are receiving this because you authored the thread.Message ID: @.***>

axsweet avatar Feb 24 '23 14:02 axsweet

got the same error.

xiaoguo0426 avatar Feb 27 '23 07:02 xiaoguo0426

It's weird that there were tons of commits since the 2nd of February, but this issue is still not fixed: https://github.com/amazon-php/sp-api-sdk/blob/cda85c7ad9f9fdcd537d4e25d532b022f33feaad/src/AmazonPHP/SellingPartner/Model/Orders/Address.php#L291

The API clearly returns NULL values for the address.name, so this library is not compatible with the Amazon SP-API.

bolner avatar Apr 12 '23 11:04 bolner

Amazon will not fix this. The privacy of Amazon avoid to return the name, address, phone, etc...

sergisolanellas avatar Apr 12 '23 14:04 sergisolanellas

I think the privacy part is where you need to be approved for PII. I had no problem with our MWS app but now making this new one I think it needs to be approved.

johncarlson21 avatar May 25 '23 04:05 johncarlson21

Yeah shoudlnt throw an error though should have error handling for permissions. Would save devs time.

Anyway i only wanted to make the app for myself (my company) they wont approve my dev access again. Dk why keep saying same reply have zero idea.

On Thu, May 25, 2023 at 12:48 AM John Carlson @.***> wrote:

I think the privacy part is where you need to be approved for PII. I had no problem with our MWS app but now making this new one I think it needs to be approved.

— Reply to this email directly, view it on GitHub https://github.com/amazon-php/sp-api-sdk/issues/328#issuecomment-1562260830, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALF5SJEJUTXNK73KCCLOLFLXH3QDDANCNFSM6AAAAAAUOKK37Y . You are receiving this because you authored the thread.Message ID: @.***>

axsweet avatar May 25 '23 13:05 axsweet

I think the privacy part is where you need to be approved for PII. I had no problem with our MWS app but now making this new one I think it needs to be approved.

Hi! Can you explain how it's possible to contact to Amazon to give the permission of receive all data of the orders?

Thanks

sergisolanellas avatar May 25 '23 13:05 sergisolanellas

Apply for developer access

On Thu, May 25, 2023 at 9:46 AM Sergi Solanellas @.***> wrote:

I think the privacy part is where you need to be approved for PII. I had no problem with our MWS app but now making this new one I think it needs to be approved.

Hi! Can you explain how it's possible to contact to Amazon to give the permission of receive all data of the orders?

Thanks

— Reply to this email directly, view it on GitHub https://github.com/amazon-php/sp-api-sdk/issues/328#issuecomment-1562939786, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALF5SJEBLUI3YCWCNVQB5VTXH5PCHANCNFSM6AAAAAAUOKK37Y . You are receiving this because you authored the thread.Message ID: @.***>

axsweet avatar May 25 '23 15:05 axsweet

This method returns string or null and shouldn't throw the error anymore.

jasonhebert avatar Jul 09 '24 16:07 jasonhebert