Simple Amazon Marketplace Web Service API Package for Laravel
This package is under development. Currently we have only implemented the endpoints we are using. Feel free to add the endpoints you need (contribute). A List of all available endpoints you can see under the endpoint road map.
Link to the Official Amazon MWS Documentation
This package requires PHP 7.3 and Laravel 8.0 or higher. For older laravel versions install the latest 0.1.x version.
Require the package using composer:
composer require looxis/laravel-amazon-mws
The package will automatically register itself.
Add your Environment Variables for MWS to your .env File. The variable names are listed in the amazon-mws.php config file.
To successfully authenticate with the Amazon Marketplace Web Service you need to add the Environment variables to your .env
File. The variable names are listed in the amazon-mws.php config file.
Also you can set a default marketplace.
You can optionally publish the configuration with:
$ php artisan vendor:publish --provider="Looxis\LaravelAmazonMWS\AmazonMWSServiceProvider" --tag="config"
This will create an amazon-mws.php
in your config directory.
Config file content with the env variables:
<?php
return [
'access_key_id' => env('MWS_ACCESS_KEY_ID'),
'secret_key' => env('MWS_SECRET_KEY'),
'seller_id' => env('MWS_SELLER_ID'),
'mws_auth_token' => env('MWS_AUTH_TOKEN'),
'default_market_place' => env('MWS_DEFAULT_MARKET_PLACE', 'DE'),
];
Amazon MWS authenticates you via the Canonicalized Query String. The Laravel Amazon MWS Package handles this for you and adds the string for each request. You just have to add your seller specific credentials to your .env file (configuration).
If you need to change the marketplaces just set the country/countries in your code via the MWS Facade. For simplicity the package chooses the right endpoint and market place id via the given country. You do not have to set them by yourself. (Amazon MWS endpoints and Market Place IDS Overview) If something is missing do not hesitate to create an issue.
AmazonMWS::setMarketplaces('FR');
AmazonMWS::setMarketplaces('DE', 'FR'); //to append multiple marketplaces to your request query strings.
Retrieve order information that you need. Amazon MWS Orders Documentation Overview
Returns orders created or updated during a time frame that you specify. MWS List Orders Documentation
$response = AmazonMWS::orders()->list([
'CreatedAfter' => '2020-04-09T18:56:29+02:00'
]);
// List Order By Next Token
$response = AmazonMWS::orders()->list([
'NextToken' => '27u07N+WSfaaJkJYLDm0ZAmQazDrhw3C...'
]);
- maximum request quota of six and a restore rate of one request every minute. MWS Throttling Algorithm
- Throws a ServerException with
Request is throttled
Returns orders based on the AmazonOrderId values that you specify. MWS Get Order Documentation
$response = AmazonMWS::orders()->get("1234-1234-1234"); //get amazon order by id
$response = AmazonMWS::orders()->get("1234-1234-1234", "123-123-123"); //get multiple orders
- maximum request quota of six and a restore rate of one request every minute. MWS Throttling Algorithm
- Throws a ServerException with
Request is throttled
Returns order items based on the AmazonOrderId that you specify. MWS List Order Items Documentation
$response = AmazonMWS::orders()->getItems("1234-1234-1234");
- ListOrderItems and ListOrderItemsByNextToken share same throttling
- maximum request quota of 30 and a restore rate of one request every two seconds. MWS Throttling Algorithm
- Throws a ServerException with
Request is throttled
The Feeds API lets you upload inventory and order data to Amazon Amazon MWS Orders Documentation Overview
Uploads a feed for processing by Amazon MWS.
You must set the feed type and content to successfully submit the feed. The content for the xml depends on the FeedType
$feedXmlContent = '<?xml version="1.0"?> ...';
$response = AmazonMWS::feeds()
->setType("_POST_ORDER_ACKNOWLEDGEMENT_DATA_")
->setContent($xml)
->submit();
- maximum request quota of 15 and a restore rate of one request every two minutes.
- Hourly request quote: 30 MWS Throttling Algorithm
- Throws a ServerException with
Request is throttled
The Amazon MWS XML responses are parsed and will be casted into a convenient array structure. For checking if the Feed was successful you need to check the result via the GetSubmissionFeedResult endpoint.
SubmitFeedResponse Example:
[
"request_id" => "e86f7299-9712-43e3-b290-b659da85b527"
"data" => [
"FeedSubmissionId" => "2291326430"
"FeedType" => "_POST_ORDER_ACKNOWLEDGEMENT_DATA_"
"SubmittedDate" => "2020-03-04T14:54:14+00:00"
"FeedProcessingStatus" => "_SUBMITTED_"
]
]
Returns the feed processing report and the Content-MD5 header.
Pass the Feed Submission Id as a parameter to retrieve the feed result Amazon MWS Description GetFeedSubmissionResult
$response = AmazonMWS::feeds()
->getFeedSubmissionResult($feedSubmissionId);
- maximum request quota of 15 and a restore rate of one request every minute.
- Hourly request quote: 60 MWS Throttling Algorithm
- Throws a ServerException with
Request is throttled
The Feed Submission Result responses are parsed and will be casted into a convenient structure.
SubmitFeedResponse Example:
[
"status_code" => "Complete",
"processing_summary" => [
"MessagesProcessed" => "2"
"MessagesSuccessful" => "2"
"MessagesWithError" => "0"
"MessagesWithWarning" => "0"
],
"result" => null
]
Response Format Documentation The Amazon MWS XML responses are parsed and will be casted into a convenient array structure. GetOrder Response Example:
[
"request_id" => "be781aff-3c63-485a-aec8-951ed3be2ba4",
"data" => [
"AmazonOrderId" => "902-3159896-1390916",
...
]
]
The Laravel Amazon MWS package does not catch the Exceptions returned by guzzle. For Example for throttling ServerExceptions or missing Parameter Client Exceptions.
Laravel Amazon MWS is still under development. We have only added the endpoints we currently are using ourselfs. We decided to ship it in this early stage so you can help to add some endpoits or use the already existing.
Endpoint List:
- Orders (MWS Documentation Overview)
- ListOrders
- ListOrdersByNextToken
- GetOrder
- ListOrderItems
- ListOrderItemsByNextToken
- GetServiceStatus
- Orders Datatypes
- Feeds (MWS Documentation Overview)
- SubmitFeed
- GetFeedSubmissionList
- GetFeedSubmissionListByNextToken
- GetFeedSubmissionCount
- CancelFeedSubmissions
- GetFeedSubmissionResult
- Easy Ship (MWS Documentation Overview)
- Finances (MWS Documentation Overview)
- FulFillment Inbound Shipment (MWS Documentation Overview)
- FulFillment Inventory (MWS Documentation Overview)
- FulFillment Outbound Shipment (MWS Documentation Overview)
- Merchant Fulfillment (MWS Documentation Overview)
- Products (MWS Documentation Overview)
- Recommendations (MWS Documentation Overview)
- Reports (MWS Documentation Overview)
- Sellers (MWS Documentation Overview)
- Shipment Invoicing (MWS Documentation Overview)
- Subscriptions (MWS Documentation Overview)
composer test
Please see CHANGELOG for more information on what has changed recently.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
LOOXIS GmbH based in Minden, Germany.
LOOXIS is a manufacturer of personalised gift articles, which are sold throughout Europe in (photo) specialist shops and via our online shop under www.looxis.com.