Order Items from an Order

feature

#1

Has the endpoint to retrieve order items with an order id been developed yet for v2?


#2

Hi @cthompson

Our shiny new docs cover how to do this.

Simply provide the ORDER_ID and you will get the associated order items.

curl -X GET https://api.moltin.com/v2/orders/{ORDER_ID}/items \
  -H "Authorization: Bearer XXXX"

Hopefully this answers your question :slight_smile:


#3

Awesome! Is this implemented in the JS-SDK as well?


#4

@cthompson this is currently possible but not documented, which I will make sure is fixed :slight_smile:

There are two ways you can do this using the SDK.

  1. Get the Order with items:
Moltin.Orders.With("items").Get("{ORDER_ID}").then((order) => {
  // Do something...
});
  1. Get only the Order Items:
Moltin.Orders.Items("{ORDER_ID}").then((items) => {
  // Do something...
});

I hope this helps :slight_smile:


#5

I assume this will require client_credentials. Do I need to pass those in there, as well?


#6

@cthompson that’s correct. You will need a client_credentials access token and the token passed inside the request header as shown below:

curl -X "POST" "https://api.moltin.com/oauth/access_token" \
  -d "client_id=XXXX" \
  -d "client_secret=XXXX" \
  -d "grant_type=client_credentials"

Or using the JS SDK you will need to pass both the client_id and client_secret to obtain correct authorization.

const Moltin = MoltinGateway({
  client_id: "XXXX",
  client_secret: "XXXX"
});

The API reference covers this in more detail.

:slight_smile:


#8