Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Amazon Mws Laravel Package

sonnenglas/laravel-amazon-mws

Laravel package for integrating Amazon Marketplace Web Service (MWS). It offers a convenient wrapper for querying orders, products, reports, and feeds, with configurable credentials and Laravel service container support.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install into a Laravel 7 project (this fork’s constraint):
    composer require sonnenglas/laravel-amazon-mws
    
  2. Publish the package config using the provider/tag documented in the package README. In this fork, confirm the facade namespace/alias in composer.json and README.md; most examples use the AmazonMws facade or inject the underlying client.
  3. Fill the published config/amazon-mws.php and .env with MWS credentials:
    AMAZON_MWS_MERCHANT_ID=your-seller-id
    AMAZON_MWS_MARKETPLACE_ID=ATVPDKIKX0DER
    AMAZON_MWS_KEY_ID=your-aws-access-key
    AMAZON_MWS_SECRET_KEY=your-aws-secret
    AMAZON_MWS_AUTH_TOKEN=your-mws-auth-token
    AMAZON_MWS_SERVICE_URL=https://mws.amazonservices.com
    
    Use the correct regional endpoint, e.g. https://mws-eu.amazonservices.com for Europe.
  4. Look first at:
    • config/amazon-mws.php for credential/key names.
    • The package README for the exact setService()->setOperation()->setParams()->run() chain.
    • Amazon MWS API docs for operation names, service versions, and parameter shapes. The package is a thin transport wrapper; MWS documentation is the real reference.
  5. First use case: pull recent orders. This verifies credentials, signing, endpoint, and response parsing in one call:
    use AmazonMws;
    
    $response = AmazonMws::setService('Orders', '2013-09-01')
        ->setOperation('ListOrders')
        ->setParams([
            'MarketplaceId.Id.1' => config('amazon-mws.marketplace_id'),
            'CreatedAfter' => now()->subDays(2)->toIso8601String(),
            'OrderStatuses.Status.1' => 'Unshipped',
        ])
        ->run();
    
    dd($response);
    
    Inspect the raw response before writing mapping code. MWS often returns XML errors inside a normal response, so check for ErrorResponse/Error nodes as well as success payloads.

Implementation Patterns

  • Wrap MWS calls in application services rather than calling the facade throughout controllers. Example services: AmazonOrderSync, AmazonProductService, AmazonReportService, AmazonFeedService.
  • Orders sync pattern:
    • Call ListOrders with CreatedAfter/LastUpdatedAfter.
    • Follow NextToken with ListOrdersByNextToken until exhausted.
    • For each order, call ListOrderItems and upsert by AmazonOrderId.
    • Make the job idempotent because retries and overlapping schedules are common.
  • Reports pattern for bulk data:
    • RequestReport to create the report.
    • Poll GetReportRequestList until _DONE_.
    • GetReportList, then GetReport to download content.
    • Store raw reports in storage/app/amazon-mws/reports and process in queued jobs.
  • Feeds pattern for price/inventory updates:
    • Build the feed XML.
    • Compute ContentMD5Header as base64 MD5 of the feed body.
    • SubmitFeed, then poll GetFeedSubmissionList and inspect GetFeedSubmissionResult.
    • Treat feed submission and feed processing as two separate async stages.
  • Product/pricing pattern:
    • Use GetMatchingProduct, GetCompetitivePricingForASIN, or GetLowestOfferListingsForASIN.
    • Chunk ASIN lists to MWS limits instead of sending one large list.
    • Persist normalized product data locally; do not call MWS on every page render.
  • Multi-account or multi-marketplace:
    • Keep seller/marketplace credentials in a database/config repository.
    • Create a fresh client or reset the resolved instance per seller if the facade caches config.
    • Pass marketplace IDs explicitly via MarketplaceId.Id.1, MarketplaceId.Id.2, etc.
  • Operational pattern:
    • Run syncs through queued Artisan commands.
    • Rate-limit with Laravel’s queue/Redis throttle.
    • Log operation, RequestId, duration, HTTP status, MWS error code, and a truncated response. Never log secrets or auth tokens.
  • Testing pattern:
    • Wrap the package behind your own interface and fake that interface in feature tests.
    • Keep XML fixtures for success, throttling, and validation-error responses.
    • Avoid live MWS calls in the default test suite.

Gotchas and Tips

  • Laravel version constraint: this package targets Laravel ^7.x. Composer will likely block installation on Laravel 8+. Isolate it in a Laravel 7 service or fork/upgrade it before using it in a modern application.
  • Amazon MWS is legacy. Plan migration to the Selling Partner API (SP-API); do not build new long-term architecture assumptions around MWS.
  • MWS list parameters are usually flattened with numeric suffixes, e.g. MarketplaceId.Id.1, OrderStatuses.Status.1, ASINList.ASIN.1. If the package does not expand arrays for you, flatten them yourself.
  • Service versions matter. Use the documented version for each section, e.g. Orders 2013-09-01, Products 2011-10-01, Reports 2009-01-01, Feeds 2009-01-01.
  • MWS can return HTTP 200 with an error XML body. Check for ErrorResponse, Error, and error codes in addition to transport-level success.
  • Throttling is normal. Retry RequestThrottled and transient 5xx responses with exponential backoff and jitter. Do not retry validation or signature errors indefinitely.
  • Signature errors are often clock skew. Ensure the server clock is synchronized; MWS requires a reasonably fresh timestamp.
  • Pagination is not automatic. Handle NextToken yourself for operations such as ListOrders and ListOrderItems.
  • Reports and feeds are asynchronous. Do not block a web request waiting for completion; queue polling jobs with sensible timeouts.
  • Feed submissions require correct content type and MD5 header. For XML feeds, use the MWS-documented content type and base64-encoded MD5.
  • Report payloads may be gzip-compressed and large. Stream to disk and decompress carefully instead of loading everything into memory.
  • Config caching can hide .env changes. Run php artisan config:clear after changing MWS credentials.
  • Multi-seller usage needs care: the MWS auth token is per seller, and Marketplace IDs differ by region. Do not assume one global config works for all accounts.
  • Preserve RequestId from responses. Amazon support and debugging are much easier when you can cite the request ID.
  • Extension point: publish and edit the package config, then wrap the client in your own service. If you need stronger typing or retries, bind your own client implementation and keep package-specific code at the boundary.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels