acm-uiuc / acm-uiuc/core

Write checkout creation logic

Open
#328 0 comments 0 reactions 2 assignees Claimed by @raranj View on GitHub
Dominant language
TypeScript
Stars
5
Forks
0
Avg merge
3h 58m
Merged PRs (30d)
10

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:
```typescript
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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.