Tutorial: How to create Amazon Fulfillment order using php?

Follow my steps and you will get working service:

1. First, you need php framework which you can download here: https://developer.amazonservices.ca/doc/fba/outbound/v20101001/php.html/181-2401128-3222006

2. Assuming your vhost root is at /var/www/amazon, unpack content to /var/www/amazon/FBAOutboundServiceMWS so you will have Client.php at /var/www/amazon/FBAOutboundServiceMWS\Client.php

3. Create /var/www/amazon/index.php file with such content:

Here is some description of used constants:
APPLICATION_NAME – it can be whatever you want, it is used by Amazon to debug your calls
APPLICATION_VERSION – same as above, when you need to talk with tech support, you should give them app name and version so they can easy track your requests
MERCHANT_ID – merchant ID given by amazon, to get it go to item from seller you want (f.e. http://www.amazon.com/Sushi-Everyone-Andy-Matsuda/dp/061521018X/ref=aag_m_pw_dp?ie=UTF8), then in right frame click “Sold by XXX” and you will get link like: http://www.amazon.com/gp/aag/main?ie=UTF8&asin=&isAmazonFulfilled=1&isCBA=&marketplaceID=ATVPDKIKX0DER&orderID=&seller=AXF7Y6KWIGBC – last parameter is your seller ID
MARKETPLACE_ID – it is identifier used by amazon, for europe, you can find them here: http://docs.developer.amazonservices.com/en_US/feeds/Feeds_Overview.html#Feeds_EU_Global_Seller
AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY are the values which you will get when creating user account on AWS

4. Now we have to add some more code to our index.php file:

So what happens here?
$serviceUrl – is URL where you will send your request, they are different for some regions but given one is for Europe
FBAOutboundServiceMWS_Client – is our class for handling requests/responses to and from amazon
FBAOutboundServiceMWS_Model_Address – this class is used to create delivery address
FBAOutboundServiceMWS_Model_CreateFulfillmentOrderItem – using this you can create shipped items and add them to request, setSellerSKU and setSellerFulfillmentOrderItemId can be same
FBAOutboundServiceMWS_Model_CreateFulfillmentOrderRequest – is main request class, setSellerFulfillmentOrderId and setDisplayableOrderId should be the same, setDisplayableOrderDateTime should be created using php’s date(“c”)

5. Last part is to add function which will do real request and handle response, so at bottom of index.php add:

This last part sends your request, if in response you will see something like:

where xxxxx will be more like unique identifier – its working, if not, there will be error description.

Keep in mind that order needs ca. 15 mins to show in your panel, but you can use search for checking if its working.

7 comments

  1. hi,

    Thanks for post.

    But i am not getting output as required. it is showing a string. is i am doing something wrong? Please suggest.

     

  2. thanks,

    but i have error message like this

    (Caught Exception: Seller is not registered for Basic fulfillment. Response Status Code: 400 )

Leave a Reply