Skip to main content

Requirements


Let’s begin!

1

Initialize GQL client with your API key

Use your API Key to initialize authorization headers for your GQL client.
2

Add external product to Rye inventory

Adding product data to inventory may take a few seconds, but the product ID will be returned immediately. You can then use this product ID to fetch product data in the next step. You can also do this via the Rye Console, under the “Requests” tab.
3

Fetch product data from Rye inventory

The product ID can be found in the response to the requestAmazonProductByURL mutation’s response.
4

Create a cart

We can create a cart containing the Amazon product we just requested.
5

Use a fragment

In the previous step our GraphQL document was extremely long. We can cut down on duplication by extracting our selected fields out as a reusable fragment, like so:
6

Add more products to your cart

Add more products to your cart with the product IDs and the cart ID of the desired cart, using the addCartItems mutation.
7

Fetch cart shipping methods and cost

Check if your cart looks good, and fetch the estimated checkout cost and available shipping methods for the cart.
8

Update buyer identity

Update buyer identity information if it was not provided during cart creation as it is required to be able to submit the cart.
9

Submit your cart

10

Display the results of the transaction

After submitting your cart, you can either poll the checkoutByCartID endpoint, or listen for Rye’s order update webhooks. In some cases there may have been some errors during the submission of the cart, and these can be inspected on the result object.Errors can occur on the Cart level and the Store level:
  • For the cart level: result.errors will provide an array of errors related to submitting the cart with appropriate error messages and codes
  • For the store level: result.cart.stores[idx].errors will provide an array of errors related to submitting the order to the store with appropriate error messages and codes
It is important to remember that submitting a cart is an async operation. It is possible for errors to occur after you have submitted the cart. Read more about checkout lifecycle here.
11

Cart management

  • To update the number of existing products in the cart, use the updateCartItems mutation.
  • To remove existing products from the cart, use the deleteCartItems mutation.
  • To remove the entire cart, use the removeCart mutation.

Next steps