Write checkout creation logic
- 主要言語
- TypeScript
- スター
- 5
- フォーク
- 0
- 平均マージ
- 3時間 58分
- マージ済み PR(30日)
- 10
説明
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`.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。