-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
From design doc:
When creating checkout sessions, we do a transact write item to first sanity check available inventory and then create a cart entry. We also check the variant limit. Enforce that one cart can’t have more than 25 items to prevent requiring multiple transactions. Check membership in the appropriate lists and then create the checkout session with preauth only and the right price IDs. Add the Order ID into the metadata of the stripe checkout so we can get the data we need. And create the order in table 2.
Implement the two functions checkItemSellable and createCheckoutSession in functions/store.ts
Roughly:
export async function createCheckoutSession({username, productId, variantId, stripeApiKey, dynamoClient}) {
// pull data from dynamodb
// call checkItemSellable
// call createCheckoutSession in stripe file with capture mode manual
}
export async function checkItemSellable({username, productId, variantId, dynamoClient}) {
// pull data from dynamodb
// enforce constraints
// throw ItemNotSellable error with message on why not, if the item is not sellable.
// reasons may include doesn't match limit, isn't open yet/doesn't exist, etc.
}You will also need to create a new error for ItemNotSellable.