PHP code example of looxis / laravel-amazon-mws

1. Go to this page and download the library: Download looxis/laravel-amazon-mws library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

looxis / laravel-amazon-mws example snippets




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'),
];

AmazonMWS::setMarketplaces('FR');

AmazonMWS::setMarketplaces('DE', 'FR');  //to append multiple marketplaces to your request query strings.

$response = AmazonMWS::orders()->list([
    'CreatedAfter' => '2020-04-09T18:56:29+02:00'
]);

// List Order By Next Token
$response = AmazonMWS::orders()->list([
    'NextToken' => '27u07N+WSfaaJkJYLDm0ZAmQazDrhw3C...'
]);

$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

$response = AmazonMWS::orders()->getItems("1234-1234-1234");

$feedXmlContent = '<?xml version="1.0"

// File Content
$invoiceFileContent = \File::get(storage_path('invoice.pdf'));

// Feed Options
$params = [
    'orderid' => 'XXX-XXXXXXX-XXXXXXX', //Amazon Order Id
    'invoicenumber' => 'R21-1234', //Your Invoice Number
    'documenttype' => 'Invoice'
];

// Generate Feed Option metadata from params
$feedOptions = collect($params)->map(function($param, $key) {
            return "metadata:{$key}={$param}";
        })->values()->implode(';');
        
// Submit
$response = AmazonMWS::feeds()
                ->setType("_UPLOAD_VAT_INVOICE_")
                ->setContent($invoiceFileContent)
                ->setParams([
                    'FeedOptions' => $feedOptions
                ])
                ->submit();

[
    "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_"
    ]
]

$response = AmazonMWS::feeds()
                ->getFeedSubmissionResult($feedSubmissionId);

[
    "status_code" => "Complete",
    "processing_summary" => [
        "MessagesProcessed" => "2"
        "MessagesSuccessful" => "2"
        "MessagesWithError" => "0"
        "MessagesWithWarning" => "0"
    ],
    "result" => null
]

$params = [
    'ShipmentRequestDetails' => [...],
    'ShippingOfferingFilter' => [...]
];
$response = AmazonMWS::merchantFulfillment()->getEligibleShippingServices($params);

$response = AmazonMWS::merchantFulfillment()->getShipment($shipmentId);

$data = [
    'ShippingServiceId' => 'shipment-service-id', //get the shipment id with getEligibleShippingServices()
    'ShipmentRequestDetails' => [...],
];
$response = AmazonMWS::merchantFulfillment()->createShipment($data);

$shipmentId = '1234xx1231xx1234';
$response = AmazonMWS::merchantFulfillment()->cancelShipment($shipmentId);

$data = [
    'OrderId' => 'XXX-XXXXXXX-XXXXXXX',
    'ShippingServiceId' => 'shipment-service-id', //get the shipment id with getEligibleShippingServices()
    'ShippingFromAddress' => [...],
];
$response = AmazonMWS::merchantFulfillment()->getAdditionalSellerInputs($data);

$response = AmazonMWS::merchantFulfillment()->getServiceStatus();

[
    "request_id" => "be781aff-3c63-485a-aec8-951ed3be2ba4",
    "data" => [
        "AmazonOrderId" => "902-3159896-1390916",
        ...
    ]
]