More in Learn

Amazon FBA

Fulfilment by Amazon (FBA) is a service that helps businesses grow by providing access to Amazon's logistics network. Businesses send products to Amazon fulfilment centers, and when a customer makes a purchase, they handle receiving, packing, shipping, customer service, and returns for that order. Effective, reliable eCommerce fulfilment delights customers.

Prerequisites

To get started with Amazon FBA and connect it to Crystallize, you first need access to your Amazon Seller account and an AWS account.

Creating an AWS IAM User and Role

Follow the steps described in the Amazon Web Services (AWS) Seller API Developer docs to create an Identity and Access Management (IAM) User and IAM Role. Make sure you save the Access ID and Access Token of the created user or download the .csv file generated upon the user’s creation. As pointed out in the Seller API docs, you should save the created IAM Role Amazon Resource Name (ARN). This role will be associated with your created Seller Application and allows you to invoke the API via the IAM Policy you created in Step 3. 

Note: We use these credentials to authorize the requests and create a connection to the AWS Seller API later.

Register as a Seller Partner API Developer (for private seller applications)

  1. Sign into Seller Central using the credentials that you want to associate with your developer account.
  2. In the Partner Network menu, click Develop Apps.
  3. The Developer Central page appears.
  4. If you have not yet completed a developer profile for this selling account, click the Proceed to Developer Profile button. Otherwise click the Your Developer Profile link.
  5. Complete the form. In the Data Access section, in the dropdown box, select My organization sells on Amazon, and I only want to integrate to manage my own business only.

Ensure you select only the mandatory fields for this integration: Amazon Fulfillment, Product Listing, Pricing, and Inventory and Order Tracking. No Amazon information is shared, and all Security controls are in place. After your developer profile is created, you can proceed to create an app.

Note: If you have questions regarding filling out the form, reach out to us via email or our community slack channel.

Create Your Seller Application

Follow the steps to register your application. In this step, you want to link the IAM Role you created in the AWS IAM interface in the previous steps. To do that, add the IAM Role’s ARN when registering your application.

After you fill out the rest of the form and your application is created, you want to save the Client Identifier and Client Secret tokens that are generated. Once your application is completed, you also want to generate your Login with Amazon (LWA) credentials. You can do that by selecting View under LWA Credentials in Developer central, as shown below.

Set up Service API and a Crystallize Webhook

After setting up your Seller application, you can connect Crystallize to Seller Central via the Service API. If you are not familiar with the Service API, you can learn more here

Once your Service API is set up, the next step is to create a Crystallize Webhook and listen to new Order events. The Webhook should be a POST request to your deployed Service API’s FBA handling endpoint (e.g., http://my-service-api-deployment/api/webhooks/order/created-fba).

Note: If you have not yet deployed your Service API, you can use ngrok to create a tunnel and make your local Service API accessible to external services, like Crystallize.

In order to have the full data required by Amazon Seller API as payload, you can use the query below:

query GET_CREATED_ORDER_DETAILS($id: ID!) {
order {
get(id: $id) {
id
customer{
firstName
lastName
identifier
email
companyName
phone
addresses{
type
firstName
lastName
phone
street
street2
postalCode
city
state
country
}
externalReferences{
key
value
}
}
cart{
sku
name
quantity
price{
currency
gross
net
}
}
}
}
}

Feel free to include more order details if you would like, or even authentication headers to your webhook request.

Personalising the Code

The existing code uses the Amazon Sandbox Seller API and does not use real authentication credentials. To add your authentication credentials, visit the code under /src/services/fulfillment-service/amazon-fba.js and replace the values in the respective fields. The function’s argument payload includes the data retrieved via the GraphQL query we used above in the new Order webhook. It can be used to replace the values of the Sandbox API call body.

Before you can POST your first request, make sure you populate the credentials’ fields. It is a necessary step to allow authentication.

credentials: {
SELLING_PARTNER_APP_CLIENT_ID: "YOUR_APP_CLIENT_ID",
SELLING_PARTNER_APP_CLIENT_SECRET: "YOUR_APP_CLIENT_SECRET",
AWS_ACCESS_KEY_ID: "YOUR_ACCESS_KEY",
AWS_SECRET_ACCESS_KEY: "YOUR_KEY_SECRET",
AWS_SELLING_PARTNER_ROLE: "YOUR_SELLING_PARTNER_ROLE_ARN",
},
refresh_token: "YOUR_APP_REFRESH_TOKEN",
People showing thumbs up

Need further help?

Join and ask our
slack community.

Join our slack community