Reputation: 383
I am Amazon seller using FBA. I started playing with MWS.
1st question is:
Which api is best (orders or reports) for "Reports/Fulfilment by Amazon/All Orders" and Reports/Payments/ Date range reports"
2nd
I downloaded PHP Library for "ORDERS" from https://developer.amazonservices.co.uk/gp/mws/api.html?ie=UTF8&group=orders§ion=orders&version=latest
... and of course problems
in config.inc.php I set up all data and additionally:
//set_include_path(get_include_path() . PATH_SEPARATOR . '../../.');
$path = 'http://MYWEBSITE/amazon-mws/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
and I test file "ListOrdersSample1"
<?php
/**
* List Orders Sample
*/
require_once('.config.inc.php');
/************************************************************************
* Instantiate Implementation of MarketplaceWebServiceOrders
*
* AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY constants
* are defined in the .config.inc.php located in the same
* directory as this sample
***********************************************************************/
// More endpoints are listed in the MWS Developer Guide
// North America:
//$serviceUrl = "https://mws.amazonservices.com/Orders/2013-09-01";
// Europe
$serviceUrl = "https://mws-eu.amazonservices.com/Orders/2013-09-01";
// Japan
//$serviceUrl = "https://mws.amazonservices.jp/Orders/2013-09-01";
// China
//$serviceUrl = "https://mws.amazonservices.com.cn/Orders/2013-09-01";
$config = array (
'ServiceURL' => $serviceUrl,
'ProxyHost' => null,
'ProxyPort' => -1,
'ProxyUsername' => null,
'ProxyPassword' => null,
'MaxErrorRetry' => 3,
);
$service = new MarketplaceWebServiceOrders_Client(
AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY,
APPLICATION_NAME,
APPLICATION_VERSION,
$config);
/************************************************************************
* Uncomment to try out Mock Service that simulates MarketplaceWebServiceOrders
* responses without calling MarketplaceWebServiceOrders service.
*
* Responses are loaded from local XML files. You can tweak XML files to
* experiment with various outputs during development
*
* XML files available under MarketplaceWebServiceOrders/Mock tree
*
***********************************************************************/
$service = new MarketplaceWebServiceOrders_Mock();
/************************************************************************
* Setup request parameters and uncomment invoke to try out
* sample for List Orders Action
***********************************************************************/
// @TODO: set request. Action can be passed as MarketplaceWebServiceOrders_Model_ListOrders
$request = new MarketplaceWebServiceOrders_Model_ListOrdersRequest();
$request->setSellerId(MERCHANT_ID);
// object or array of parameters
invokeListOrders($service, $request);
/**
* Get List Orders Action Sample
* Gets competitive pricing and related information for a product identified by
* the MarketplaceId and ASIN.
*
* @param MarketplaceWebServiceOrders_Interface $service instance of MarketplaceWebServiceOrders_Interface
* @param mixed $request MarketplaceWebServiceOrders_Model_ListOrders or array of parameters
*/
function invokeListOrders(MarketplaceWebServiceOrders_Interface $service, $request)
{
try {
$response = $service->ListOrders($request);
echo ("Service Response\n");
echo ("=============================================================================\n");
$dom = new DOMDocument();
$dom->loadXML($response->toXML());
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
echo $dom->saveXML();
echo("ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
} catch (MarketplaceWebServiceOrders_Exception $ex) {
echo("Caught Exception: " . $ex->getMessage() . "\n");
echo("Response Status Code: " . $ex->getStatusCode() . "\n");
echo("Error Code: " . $ex->getErrorCode() . "\n");
echo("Error Type: " . $ex->getErrorType() . "\n");
echo("Request ID: " . $ex->getRequestId() . "\n");
echo("XML: " . $ex->getXML() . "\n");
echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
}
}
I try to use for testing
$service = new MarketplaceWebServiceOrders_Mock();
but nothing happens. Is the path correct in config? I do not understand this
$serviceUrl = "https://mws-eu.amazonservices.com/Orders/2013-09-01";
Should I change the date?
I need small working example to start.
Thank you very much
Upvotes: 1
Views: 2779
Reputation: 587
It depends on what you are trying to accomplish. I think the Orders API is beneficial if you need to do something actionable with the order such as ship it yourself (merchant fulfilled rather than FBA).
The reports API is more useful if you are mainly using the data for reporting. One of the main reports I use is _GET_AMAZON_FULFILLED_SHIPMENTS_DATA_
because it gives the sales data after it has actually shipped. Just because someone ordered something does not mean that they will actually get the item. Sometimes orders fail due to credit card being denied, or them cancelling it quickly, etc.
The date is their version of the API you are using. That would stay 2013-09-01. I would highly recommend playing with the scratchpad to see that type of data returned for each kind of request. It also helps visualize what kind of parameters you need to provide. to get the expected results. I always start here before coding anything. https://mws.amazonservices.co.uk/scratchpad/index.html (change co.uk to whatever you want, .de, etc)
Upvotes: 1