php 这个来自github的销售伙伴API库有什么问题吗?

yi0zb3m4  于 2023-02-18  发布在  PHP
关注(0)|答案(1)|浏览(183)

我正在使用Amazon销售合作伙伴API的商家订单履行部分,该API位于https://github.com/jlevers/selling-partner-api/
我有其他部分的工作...即订单下降和报告上升。但我使用相同的技术和商家履行API不工作。我得到的回应表明,它没有收到我发送给它的数据。
我哪里做错了?

// North America Live
$NA = [
    'url' => 'https://sellingpartnerapi-na.amazon.com',
    'region' => 'us-east-1',
];

// North America Sandbox
// $NA = [
//  'url' => 'https://sandbox.sellingpartnerapi-na.amazon.com',
//  'region' => 'us-east-1',
// ];
    
$config = new SellingPartnerApi\Configuration([
    "lwaClientId" => $lwaClientId,
    "lwaClientSecret" => $lwaClientSecret,
    "lwaRefreshToken" => $lwaRefreshToken,
    "awsAccessKeyId" => $awsAccessKeyId,
    "awsSecretAccessKey" => $awsSecretAccessKey,
    "endpoint" => $NA  // or another endpoint from lib/Endpoint.php
]); 

$apiInstance = new SellingPartnerApi\Api\MerchantFulfillmentApi($config);

$body = new \SellingPartnerApi\Model\MerchantFulfillment\GetEligibleShipmentServicesRequest(
[
    "shipment_request_details"  =>  
        [
        "amazon_order_id" => "XXX-XXXXXXXX-XXXXXXXX",
        "item_list" => 
            [
            "order_item_id" => "XXXXXXXXXXXXXXX",
            "quantity" => 1,
            ],
        "ship_from_address" => 
            [
            "name" => "XXXXXXX",
            "address_line1" => "XXXXXXXXXX",    
            "email" => "XXXXX@XXXXX.COM",
            "city" => "XXXXXXXXX",
            "postal_code" => "XXXXXX",
            "country_code" => "US",
            "phone" => "XXXXXXXXXXXX",  
            ],
        "weight" => 
            [
            "value" => 7,
            "unit" => "oz",  
            ],
        "shipping_service_options" => 
            [
            "delivery_experience" => "DeliveryConfirmationWithSignature",  
            "carrier_will_pick_up" => true,  
            ]
        ]   
]
);
try {
    $result = $apiInstance->getEligibleShipmentServices($body);
    d($result);
} catch (Exception $e) {
    echo "<PRE>";
    echo 'Exception when calling MerchantFulfillmentV0Api->getEligibleShipmentServices: <BR>', wordwrap($e->getMessage(),80,"<br>\n",TRUE), PHP_EOL;
    echo "</PRE>";
}

我得到的$响应是:

Exception when calling MerchantFulfillmentV0Api->getEligibleShipmentServices: 
[400] {
  "errors": [
    {
      "code": "InvalidInput",
      "message": "5

validation errors detected: Value \u0027\u0027 at

\u0027shipmentRequestDetails.shipFromAddress.email\u0027 failed to satisfy

constraint: Member must satisfy regular expression pattern: .+@.+; Value

\u0027\u0027 at \u0027shipmentRequestDetails.amazonOrderId\u0027 failed to

satisfy constraint: Member must satisfy regular expression pattern:

[0-9A-Z]{3}-[0-9]{7}-[0-9]{7}; Value \u0027\u0027 at

\u0027shipmentRequestDetails.weight.unit\u0027 failed to satisfy constraint:

Member must satisfy enum value set: [g, ounces, oz, grams]; Value null at

\u0027shipmentRequestDetails.weight.value\u0027 failed to satisfy constraint:

Member must not be null; Value \u0027[]\u0027 at

\u0027shipmentRequestDetails.itemList\u0027 failed to satisfy constraint: Member

must have length greater than or equal to 1",
      "details": ""
    }
  ]
}
k5ifujac

k5ifujac1#

在运输服务选项中....需要将其设置为假。“carrier_will_pick_up”=〉真,
如果它设置为真,那么它将不工作。我认为它与发送一个皮卡的请求承运人...似乎违反直觉,设置为假...但这是什么使它工作!

相关问题