亚马逊MWS-卡在GetMyFeesEstimate(PHP / Laravel)

时间:2018-07-20 20:28:28

标签: php laravel amazon-mws

我正在将以下软件包用于Amazon MWS,以便在Laravel项目(https://packagist.org/packages/mcs/amazon-mws)中使用。它工作得很漂亮,但是缺少我需要的一种关键方法GetMyFeesEstimate。

现在,我尝试自己扩展代码: 在MWSEndPoint.php中,我输入:

 'GetMyFeesEstimate'=> [
        'method' => 'POST',
        'action' => 'GetMyFeesEstimate',
        'path' => '/Products/2011-10-01',
        'date' => '2011-10-01'

    ],

在MWSClient.php中,我尝试了以下操作:

public function GetMyFeesEstimate($type, $idvalue, $price, $fba)
    {

        $array = [
            'MarketplaceId' => $this->config['Marketplace_Id']
        ];

        $feesEstimateRequest = [
            'IdType' => $type,
            'IdValue' => $idvalue,
            'PriceToEstimateFees' => array('ListingPrice'=>array('Amount',floatval($price))),
            'Identifier' => null,
            'IsAmazonFulfilled' => $fba
        ];

        $array['FeesEstimateRequestList'] = array($feesEstimateRequest);

        $response = $this->request(
            'GetMyFeesEstimate',
            $array

        );
        dd($response);
    }

但是,我遇到以下错误,并且不确定要去哪里: “我们计算出的请求签名与您提供的签名不匹配。请检查您的AWS Secret Access密钥和签名方法。有关详细信息,请参阅服务文档。”

我已经研究了几个小时,并仔细阅读了以下文档: http://docs.developer.amazonservices.com/en_US/products/Products_GetMyFeesEstimate.html http://docs.developer.amazonservices.com/en_US/products/Products_Datatypes.html#FeesEstimateRequest

...但是没有成功。有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

好的,我再看了一些文档,并提出了这个建议(有效):

public function GetMyFeesEstimate($idtype, $idvalue, $price, $currency, $fba)
    {


        $query = [
            'MarketplaceId' => $this->config['Marketplace_Id']
        ];


        $query['FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId'] = $this->config['Marketplace_Id'];
        $query['FeesEstimateRequestList.FeesEstimateRequest.1.IdType'] = $idtype;
        $query['FeesEstimateRequestList.FeesEstimateRequest.1.IdValue'] = $idvalue;
        $query['FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount'] = floatval($price);
        $query['FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode'] = $currency;
        $query['FeesEstimateRequestList.FeesEstimateRequest.1.Identifier'] = gmdate(self::DATE_FORMAT, time());
        $query['FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled'] = $fba;

        $response = $this->request(
            'GetMyFeesEstimate',
            $query

        );

        return $response;
    }