Placing Amazon Orders via API using TypeScript and Rye
Guide to programmatically submit Amazon orders for fulfillment using TypeScript and Rye’s e-commerce API
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
- Create a Rye cart with the Amazon items (
createCart
mutation) - Collect payment from the customer based on the cart’s cost field
- Tokenize your own credit card to let Rye place the order (Spreedly guide)
- Submit the Amazon order with the
submitCart
mutation
Pre-reqs:
- Make sure to replace
<Authorization>
,<Shopper-IP>
andPRODUCTION_PAYMENT_GATEWAY_HEADERS
with your actual values from the Rye Console. - 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:
To run the example, use the following command:
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.
Was this page helpful?