aqibjr1
aqibjr1

Reputation: 594

Amazon MWS - Stuck with GetMyFeesEstimate (PHP/Laravel)

I'm using the following package for Amazon MWS for use in a Laravel project (https://packagist.org/packages/mcs/amazon-mws). It works beautifully but it lacks one critical method which I need, GetMyFeesEstimate.

Now, I've tried to extend the code myself: In MWSEndPoint.php, I've put:

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

    ],

And in MWSClient.php, I've tried the following:

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

However, I'm getting the following error and I'm not sure where I'm going wrong: "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."

I have played around with it for a couple of hours, having extensively looked at the documentation: http://docs.developer.amazonservices.com/en_US/products/Products_GetMyFeesEstimate.html http://docs.developer.amazonservices.com/en_US/products/Products_Datatypes.html#FeesEstimateRequest

...but without success. Please can someone help me with this?

Upvotes: 1

Views: 345

Answers (1)

aqibjr1
aqibjr1

Reputation: 594

Okay so, I looked at the documentation a bit more and came up with this (it works):

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

Upvotes: 1

Related Questions