首页 > 解决方案 > 亚马逊 MWS - 使用 GetMyFeesEstimate (PHP/Laravel)

问题描述

我将以下包用于 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 秘密访问密钥和签名方法。请参阅服务文档了解详情。”

我已经玩了几个小时,广泛查看了文档: http: //docs.developer.amazonservices.com/en_US/products/Products_GetMyFeesEstimate.html http://docs.developer.amazonservices.com/ en_US/products/Products_Datatypes.html#FeesEstimateRequest

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

标签: phplaravelamazon-mws

解决方案


好的,我又查看了文档并想出了这个(它有效):

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;
    }

推荐阅读