Open pokusman opened 1 day ago
Using version 5.10.1 - getting the same response since yesterday.
same issue here even after upgrading to 5.10.2. Have also tried: 5.8.3 and same issue.
@dv336699 & @pokusman if you need a quick resolution, in TaxCollection.php:264 add
if($responsible_party == ""){
return $allowedValues[0];
}
Looking into the root cause now.
@adamtoms A more elegant solution ;-)
so I can see the payload contains an empty string. Going to look at the amazon docs to see whats required.
{#2133 ▼ // vendor/jlevers/selling-partner-api/lib/Api/OrdersV0Api.php:1543
+"payload": {#2124 ▼
+"OrderItems": array:1 [▼
0 => {#2129 ▼
+"TaxCollection": {#2142 ▼
+"Model": "MarketplaceFacilitator"
+"ResponsibleParty": ""
}
UPDATE: Looks like it's optional: https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference#taxcollection
So just need the enforecement check removed from setResponsibleParty.
As quick fix, based on adamtoms' solution, I simply modify TaxCollection.php (selling-partner-api\lib\Model\Orders\TaxCollection.php) by adding false&& in the condition of the public function setResponsibleParty like this:
if (false&&!is_null($responsible_party) &&!in_array(strtoupper($responsible_party), $allowedValues, true)) {
Now it works again :)
@dv336699 & @pokusman if you need a quick resolution, in TaxCollection.php:264 add
if($responsible_party == ""){ return $allowedValues[0]; }
Looking into the root cause now.
Thanks @adamtoms for the quick fix! Worked for me
Manu thanks for your issue, I investigate also yesterday and find your solutions. That unbelievable that Amazon's technical service won't inform us for change in theirs only one OrderV0 !
Any solution to a problem is better than none, especially when you really need it badly. There are more elegant solutions than mine, but the important thing was that it worked and helped to find better solutions by people who have more experience with coding than me. We all know how Amazon Support works :-D
My understanding is that this is an optional field so I went with skipping validation if the value is an empty string for now.
edit: raised a draft PR for it here: https://github.com/jlevers/selling-partner-api/pull/802
if (
// Amazon may send this optional field as an empty string so we have to cater for that scenario here
// @see https://github.com/jlevers/selling-partner-api/issues/799
$responsible_party !== ''
&& !is_null($responsible_party)
&& !in_array(strtoupper($responsible_party), $allowedValues, true)
) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value '%s' for 'responsible_party', must be one of '%s'",
$responsible_party,
implode("', '", $allowedValues)
)
);
}
Amazon made a small unannounced change in SP API yesterday and the 'getOrderItems' function. The called function returns incomplete data, namely 'ResponsibleParty' which is sometimes empty and end up as throws exception. In this case I recommend to just disable validation in '/vendor/jlevers/selling-partner-api/lib/Model/OrdersV0/TaxCollection.php
Fatal error: Uncaught InvalidArgumentException: Invalid value '' for 'responsible_party', must be one of 'AMAZON SERVICES, INC.', 'AMAZON COMMERCIAL SERVICES PTY LTD' in ..../vendor/jlevers/selling-partner-api/lib/Model/OrdersV0/TaxCollection.php:265 Stack trace: #0 ..../vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php(385): SellingPartnerApi\Model\OrdersV0\TaxCollection->setResponsibleParty('') #1 ..../vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php(385): SellingPartnerApi\ObjectSerializer::deserialize(Object(stdClass), '\SellingPartner...', NULL) #2 ..../vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php(276): SellingPartnerApi\ObjectSerializer::deserialize(Object(stdClass), '\SellingPartner...', NULL) #3 ..../vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php(385): SellingPartnerApi\ObjectSerializer::deserialize(Array, '\SellingPartner...', NULL) #4 ..../vendor/jlevers/selling-partner-api/lib/ObjectSerializer.php(385): SellingPartnerApi\ObjectSerializer::deserialize(Object(stdClass), '\SellingPartner...', NULL) #5 ..../vendor/jlevers/selling-partner-api/lib/Api/OrdersV0Api.php(1543): SellingPartnerApi\ObjectSerializer::deserialize(Object(stdClass), '\SellingPartner...', Array) #6 ..../vendor/jlevers/selling-partner-api/lib/Api/OrdersV0Api.php(1472): SellingPartnerApi\Api\OrdersV0Api->getOrderItemsWithHttpInfo('171-7392580-949...', '', Array) #7 ..../servers/Amazons/GetOrders.php(438): SellingPartnerApi\Api\OrdersV0Api->getOrderItems('171-7392580-949...', '', Array) #8 {main} thrown in ..../vendor/jlevers/selling-partner-api/lib/Model/OrdersV0/TaxCollection.php on line 265
Solution: