acm-uiuc / acm-uiuc/core

Write checkout creation logic

Aperta
#328 0 commenti 0 reazioni 2 assegnatari Rivendicata da @raranj Vedi su GitHub
Lingua principale
TypeScript
Stelle
5
Fork
0
Merge medio
3h 58m
PR unite (30g)
10

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.