Overview

Rye’s API allows you to place Amazon orders entirely through backend TypeScript code. By offloading order processing to Rye, you can easily submit Amazon purchases for fulfillment via API calls. This guide covers the key steps in the process. For a complete TypeScript code example, check out our demo. Python documentation coming soon.

Key Steps

  1. Create a Rye cart with the Amazon items (createCart mutation)
  2. Collect payment from the customer based on the cart’s cost field
  3. Tokenize your own credit card to let Rye place the order (Spreedly guide)
  4. Submit the Amazon order with the submitCart mutation

Pre-reqs:

  1. Make sure to replace <Authorization>, <Shopper-IP> and PRODUCTION_PAYMENT_GATEWAY_HEADERS with your actual values from the Rye Console.
  2. Modify the product details, buyer identity, and credit card information as needed to suit your specific use case.

If everything is set up correctly, you should see the order submission status and response logged in the console.

How to run:

To run this example, you’ll need to install the necessary dependencies using Yarn:

yarn add @rye-api/rye-sdk axios ts-node typescript

To run the example, use the following command:

yarn run ts-node index.ts

The index.ts file contains the main logic for creating an order. It creates a new cart with an Amazon product, tokenizes the credit card using the tokenizeCreditCard function, and submits the cart to create an order. The order submission status and response are logged to the console.

The tokenization.ts file defines the tokenizeCreditCard function, which uses the Spreedly API to tokenize the credit card details and returns the payment token. Make sure to replace <Authorization> with your actual authorization token from the Rye Console.